sdcc-build:
[fw/sdcc] / support / scripts / sdcc.nsi
1 # sdcc.nsi - NSIS installer script for SDCC
2 #
3 # Copyright (c) 2003-2008 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-rrrr.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 it to DOS format:
35 #   unix2dos COPYING.TXT
36 # - copy readline5.dll to PKGDIR/bin/readline5.dll
37 # - run NSIS installer from PKGDIR directory:
38 #   "c:\Program Files\NSIS\makensis.exe" -DVER_MAJOR=<SDCC_VER_MAJOR> -DVER_MINOR=<SDCC_VER_MINOR> -DVER_REVISION=<SDCC_VER_DEVEL> -DVER_BUILD=<SDCC_REVISION> sdcc.nsi
39 #   replace <VER_XXX> with the appropriate values, for example for SDCC 2.7.4:
40 #   <SDCC_VER_MAJOR> = 2
41 #   <SDCC_VER_MINOR> = 7
42 #   <SDCC_VER_DEVEL> = 4
43 #   replace <SDCC_REVISION> with the current svn revision number
44 # - A setup file setup.exe is created in PKGDIR directory.
45 #   Rename it to sdcc-yyyymmdd-rrrr-setup.exe and upload it
46 #   to sdcc download repository at sourceforge.net
47 #
48 #
49 # How to create WIN32 release setup.exe package
50 #
51 # - unpack WIN32 mingw daily snapshot sdcc-snapshot-i586-mingw32msvc-yyyymmdd-rrrr.zip
52 #   to a clean directory (the option to create directories should be enabled).
53 #   A sub directory sdcc is created (referenced as PKGDIR in continuation).
54 # - remove the PKGDIR/doc/README.TXT file
55 # - unpack sdcc-doc-yyyymmdd-rrrr.zip to the PKGDIR/doc directory
56 # - copy files sdcc/support/scripts/sdcc.ico and sdcc/support/scripts/sdcc.nsi
57 #   (this file) from the sdcc Subversion snapshot to the PKGDIR directory
58 # - copy file COPYING from the sdcc Subversion snapshot to the PKGDIR directory,
59 #   rename it to COPYING.TXT and it to DOS format:
60 #   unix2dos COPYING.TXT
61 # - copy readline5.dll to PKGDIR/bin/readline5.dll
62 # - run NSIS installer from PKGDIR directory:
63 #   "c:\Program Files\NSIS\makensis.exe" -DFULL_DOC -DVER_MAJOR=<VER_MAJOR> -DVER_MINOR=<VER_MINOR> -DVER_REVISION=<VER_PATCH> -DVER_BUILD=<REVISION> sdcc.nsi
64 # - A setup file setup.exe is created in PKGDIR directory.
65 #   Rename it to sdcc-x.x.x-setup.exe and upload it
66 #   to sdcc download repository at sourceforge.net
67 #
68 # How to upload secc setup.exe tosourceforge.net
69 #
70 # Execute following commands from the cmd prompt:
71 # - sftp sdcc.sourceforge.net
72 # - cd /home/groups/s/sd/sdcc/htdocs/snapshots/i586-mingw32msvc-setup
73 # - put sdcc_yyyymmdd_setup.exe
74 # - quit
75
76
77 !define PRODUCT_NAME "SDCC"
78
79 ; Version
80 !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD
81   !define PRODUCT_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}"
82 !else
83   !define PRODUCT_VERSION "XX.XX"
84 !endif
85
86 SetCompressor /SOLID lzma
87
88 !define SDCC_ROOT "."
89
90 !define DEV_ROOT "${SDCC_ROOT}"
91
92 !system "unix2dos ${SDCC_ROOT}\doc\ChangeLog_head.txt" = 0
93 !system "unix2dos ${SDCC_ROOT}\doc\README.TXT" = 0
94
95 InstType "Full (Bin, ucSim, SDCDB, Doc, Lib, Src)"
96 InstType "Medium (Bin, ucSim, SDCDB, Doc, Lib)"
97 InstType "Compact (Bin, ucSim, SDCDB, Doc)"
98
99 ;--------------------------------
100 ; Header Files
101
102 !include "MUI2.nsh"
103 !include "WordFunc.nsh"
104
105 ;--------------------------------
106 ; Functions
107
108 !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD
109   !insertmacro VersionCompare
110 !endif
111
112 ;--------------------------------
113 ; Configuration
114
115 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
116
117 ;--------------------------------
118 ; Configuration
119
120 ; MUI Settings
121 !define MUI_ABORTWARNING
122
123 ; Welcome page
124 !insertmacro MUI_PAGE_WELCOME
125
126 ; License page
127 !insertmacro MUI_PAGE_LICENSE "${SDCC_ROOT}\COPYING.TXT"
128
129 ; Uninstall/reinstall page
130 !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD
131 Page custom PageReinstall PageLeaveReinstall
132 !endif
133
134 ; StartMenu page
135 !define MUI_STARTMENUPAGE_DEFAULTFOLDER ${PRODUCT_NAME}
136 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
137 !define MUI_STARTMENUPAGE_REGISTRY_KEY ${PRODUCT_UNINST_KEY}
138 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "NSIS:StartMenuDir"
139 !define MUI_STARTMENUPAGE_NODISABLE
140 Var MUI_STARTMENUPAGE_VARIABLE
141 !insertmacro MUI_PAGE_STARTMENU Application $MUI_STARTMENUPAGE_VARIABLE
142
143 ; Components page
144 !define MUI_COMPONENTSPAGE_SMALLDESC
145 !insertmacro MUI_PAGE_COMPONENTS
146
147 ; Directory page
148 !insertmacro MUI_PAGE_DIRECTORY
149
150 ; Instfiles page
151 !insertmacro MUI_PAGE_INSTFILES
152
153 ; Finish page
154 !define MUI_FINISHPAGE_SHOWREADME_TEXT "Add $INSTDIR\bin to the PATH"
155 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION AddBinToPath
156 !define MUI_FINISHPAGE_SHOWREADME
157 !insertmacro MUI_PAGE_FINISH
158
159 ; Uninstaller pages
160 !insertmacro MUI_UNPAGE_CONFIRM
161 !insertmacro MUI_UNPAGE_INSTFILES
162
163 ; Language files
164 !insertmacro MUI_LANGUAGE "English"
165
166 Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
167 BrandingText ""
168 OutFile "setup.exe"
169 InstallDir "$PROGRAMFILES\SDCC"
170 ;;;;ShowInstDetails show
171 ;;;;ShowUnInstDetails show
172
173 !ifndef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD
174 ; Old unistallation method
175 Function .onInit
176   ;Uninstall the old version, if present
177   ReadRegStr $R0 HKLM \
178   "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" \
179   "UninstallString"
180   StrCmp $R0 "" inst
181
182   MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
183   "$(^Name) is already installed. $\n$\nClick 'OK' to remove the \
184   previous version or 'Cancel' to cancel this upgrade." \
185   IDOK uninst
186   Abort
187
188 uninst:
189   ; Run the uninstaller
190   ClearErrors
191   ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
192
193   Goto done
194 inst:
195
196   ; Install the new version
197   MessageBox MB_YESNO|MB_ICONQUESTION "This will install $(^Name). Do you wish to continue?" IDYES +2
198   Abort
199
200 done:
201 FunctionEnd
202 !endif
203
204 Section -Common
205   SetOutPath "$INSTDIR"
206   File ".\sdcc.ico"
207   File "${SDCC_ROOT}\COPYING.TXT"
208 SectionEnd
209
210 Section "SDCC application files" SEC01
211   SectionIn 1 2 3 RO
212   SetOutPath "$INSTDIR\bin"
213   File "${SDCC_ROOT}\bin\as-gbz80.exe"
214   File "${SDCC_ROOT}\bin\as-hc08.exe"
215   File "${SDCC_ROOT}\bin\as-z80.exe"
216   File "${SDCC_ROOT}\bin\asx8051.exe"
217   File "${SDCC_ROOT}\bin\aslink.exe"
218   File "${SDCC_ROOT}\bin\link-gbz80.exe"
219   File "${SDCC_ROOT}\bin\link-hc08.exe"
220   File "${SDCC_ROOT}\bin\link-z80.exe"
221   File "${SDCC_ROOT}\bin\makebin.exe"
222   File "${SDCC_ROOT}\bin\packihx.exe"
223   File "${SDCC_ROOT}\bin\sdcc.exe"
224   File "${SDCC_ROOT}\bin\sdcclib.exe"
225   File "${SDCC_ROOT}\bin\sdcpp.exe"
226   File "${SDCC_ROOT}\bin\readline5.dll"
227 SectionEnd
228
229 Section "ucSim application files" SEC02
230   SectionIn 1 2 3
231   SetOutPath "$INSTDIR\bin"
232   File "${SDCC_ROOT}\bin\s51.exe"
233   File "${SDCC_ROOT}\bin\savr.exe"
234   File "${SDCC_ROOT}\bin\shc08.exe"
235   File "${SDCC_ROOT}\bin\sz80.exe"
236 SectionEnd
237
238 Section "SDCDB files" SEC03
239   SectionIn 1 2 3
240   File "${SDCC_ROOT}\bin\sdcdb.exe"
241   File "${SDCC_ROOT}\bin\sdcdb.el"
242   File "${SDCC_ROOT}\bin\sdcdbsrc.el"
243 SectionEnd
244
245 Section "SDCC documentation" SEC04
246   SectionIn 1 2 3
247   SetOutPath "$INSTDIR\doc"
248 !ifdef FULL_DOC
249   File /r "${SDCC_ROOT}\doc\*"
250 !else
251   File "${SDCC_ROOT}\doc\ChangeLog_head.txt"
252   File "${SDCC_ROOT}\doc\README.TXT"
253 !endif
254 SectionEnd
255
256 Section "SDCC include files" SEC05
257   SectionIn 1 2
258   SetOutPath "$INSTDIR\include\asm\default"
259   File "${DEV_ROOT}\include\asm\default\features.h"
260   SetOutPath "$INSTDIR\include\asm\ds390"
261   File "${DEV_ROOT}\include\asm\ds390\features.h"
262   SetOutPath "$INSTDIR\include\asm\gbz80"
263   File "${DEV_ROOT}\include\asm\gbz80\features.h"
264   SetOutPath "$INSTDIR\include\asm\mcs51"
265   File "${DEV_ROOT}\include\asm\mcs51\features.h"
266   SetOutPath "$INSTDIR\include\asm\pic"
267   File "${DEV_ROOT}\include\asm\pic\features.h"
268   SetOutPath "$INSTDIR\include\asm\pic16"
269   File "${DEV_ROOT}\include\asm\pic16\features.h"
270   SetOutPath "$INSTDIR\include\asm\z80"
271   File "${DEV_ROOT}\include\asm\z80\features.h"
272   SetOutPath "$INSTDIR\include\hc08"
273   File "${DEV_ROOT}\include\hc08\*.h"
274   SetOutPath "$INSTDIR\include\mcs51"
275   File "${DEV_ROOT}\include\mcs51\*.h"
276   SetOutPath "$INSTDIR\include\pic"
277   File "${DEV_ROOT}\include\pic\*.h"
278   File "${DEV_ROOT}\include\pic\*.txt"
279   File "${DEV_ROOT}\include\pic\*.inc"
280   SetOutPath "$INSTDIR\include\pic16"
281   File "${DEV_ROOT}\include\pic16\*.h"
282   SetOutPath "$INSTDIR\include\z80"
283   File "${DEV_ROOT}\include\z80\*.h"
284   SetOutPath "$INSTDIR\include"
285   File "${DEV_ROOT}\include\*.h"
286 SectionEnd
287
288 Section "SDCC DS390 library" SEC06
289   SectionIn 1 2
290   SetOutPath "$INSTDIR\lib\ds390"
291   File "${DEV_ROOT}\lib\ds390\*.rel"
292   File "${DEV_ROOT}\lib\ds390\*.lib"
293 SectionEnd
294
295 Section "SDCC DS400 library" SEC07
296   SectionIn 1 2
297   SetOutPath "$INSTDIR\lib\ds400"
298   File "${DEV_ROOT}\lib\ds400\*.rel"
299   File "${DEV_ROOT}\lib\ds400\*.lib"
300 SectionEnd
301
302 Section "SDCC GBZ80 library" SEC08
303   SectionIn 1 2
304   SetOutPath "$INSTDIR\lib\gbz80"
305   File "${DEV_ROOT}\lib\gbz80\*.o"
306   File "${DEV_ROOT}\lib\gbz80\*.lib"
307 SectionEnd
308
309 Section "SDCC Z80 library" SEC09
310   SectionIn 1 2
311   SetOutPath "$INSTDIR\lib\z80"
312   File "${DEV_ROOT}\lib\z80\*.o"
313   File "${DEV_ROOT}\lib\z80\*.lib"
314 SectionEnd
315
316 Section "SDCC small model library" SEC10
317   SectionIn 1 2
318   SetOutPath "$INSTDIR\lib\small"
319   File "${DEV_ROOT}\lib\small\*.rel"
320   File "${DEV_ROOT}\lib\small\*.lib"
321 SectionEnd
322
323 Section "SDCC medium model library" SEC11
324   SectionIn 1 2
325   SetOutPath "$INSTDIR\lib\medium"
326   File "${DEV_ROOT}\lib\medium\*.rel"
327   File "${DEV_ROOT}\lib\medium\*.lib"
328 SectionEnd
329
330 Section "SDCC large model library" SEC12
331   SectionIn 1 2
332   SetOutPath "$INSTDIR\lib\large"
333   File "${DEV_ROOT}\lib\large\*.rel"
334   File "${DEV_ROOT}\lib\large\*.lib"
335 SectionEnd
336
337 Section "SDCC small-stack-auto model library" SEC13
338   SectionIn 1 2
339   SetOutPath "$INSTDIR\lib\small-stack-auto"
340   File "${DEV_ROOT}\lib\small-stack-auto\*.rel"
341   File "${DEV_ROOT}\lib\small-stack-auto\*.lib"
342 SectionEnd
343
344 Section "SDCC HC08 library" SEC14
345   SectionIn 1 2
346   SetOutPath "$INSTDIR\lib\hc08"
347   File "${DEV_ROOT}\lib\hc08\*.rel"
348   File "${DEV_ROOT}\lib\hc08\*.lib"
349 SectionEnd
350
351 Section "SDCC PIC16 library" SEC15
352   SectionIn 1 2
353   SetOutPath "$INSTDIR\lib\pic16"
354   File "${DEV_ROOT}\lib\pic16\*.o"
355   File "${DEV_ROOT}\lib\pic16\*.lib"
356 SectionEnd
357
358 Section "SDCC PIC library" SEC16
359   SectionIn 1 2
360   SetOutPath "$INSTDIR\lib\pic"
361   File "${DEV_ROOT}\lib\pic\*.lib"
362 SectionEnd
363
364 Section "SDCC library sources" SEC17
365   SectionIn 1
366   SetOutPath "$INSTDIR\lib\src\ds390\examples"
367   File "${DEV_ROOT}\lib\src\ds390\examples\MOVED"
368
369   SetOutPath "$INSTDIR\lib\src\ds390"
370   File "${DEV_ROOT}\lib\src\ds390\*.c"
371 #  File "${DEV_ROOT}\lib\src\ds390\Makefile"
372
373   SetOutPath "$INSTDIR\lib\src\ds400"
374   File "${DEV_ROOT}\lib\src\ds400\*.c"
375 #  File "${DEV_ROOT}\lib\src\ds400\Makefile"
376
377   SetOutPath "$INSTDIR\lib\src\gbz80"
378   File "${DEV_ROOT}\lib\src\gbz80\*.c"
379   File "${DEV_ROOT}\lib\src\gbz80\*.s"
380 #  File "${DEV_ROOT}\lib\src\gbz80\Makefile"
381
382   SetOutPath "$INSTDIR\lib\src\z80"
383   File "${DEV_ROOT}\lib\src\z80\*.c"
384   File "${DEV_ROOT}\lib\src\z80\*.s"
385 #  File "${DEV_ROOT}\lib\src\z80\Makefile"
386
387   SetOutPath "$INSTDIR\lib\src\hc08"
388   File "${DEV_ROOT}\lib\src\hc08\*.c"
389 #  File "${DEV_ROOT}\lib\src\hc08\Makefile"
390
391   SetOutPath "$INSTDIR\lib\src\mcs51"
392   File "${DEV_ROOT}\lib\src\mcs51\*.asm"
393 #  File "${DEV_ROOT}\lib\src\mcs51\Makefile"
394
395   SetOutPath "$INSTDIR\lib\src\small"
396 #  File "${DEV_ROOT}\lib\src\small\Makefile"
397
398   SetOutPath "$INSTDIR\lib\src\medium"
399 #  File "${DEV_ROOT}\lib\src\medium\Makefile"
400
401   SetOutPath "$INSTDIR\lib\src\large"
402 #  File "${DEV_ROOT}\lib\src\large\Makefile"
403
404   SetOutPath "$INSTDIR\lib\src\pic"
405 #  File "${DEV_ROOT}\lib\src\pic\configure"
406 #  File "${DEV_ROOT}\lib\src\pic\configure.in"
407 #  File "${DEV_ROOT}\lib\src\pic\GPL"
408 #  File "${DEV_ROOT}\lib\src\pic\LGPL"
409 #  File "${DEV_ROOT}\lib\src\pic\Makefile"
410 #  File "${DEV_ROOT}\lib\src\pic\Makefile.common"
411 #  File "${DEV_ROOT}\lib\src\pic\Makefile.common.in"
412 #  File "${DEV_ROOT}\lib\src\pic\Makefile.rules"
413 #  File "${DEV_ROOT}\lib\src\pic\Makefile.subdir"
414 #  File "${DEV_ROOT}\lib\src\pic\NEWS"
415 #  File "${DEV_ROOT}\lib\src\pic\README"
416   File "${DEV_ROOT}\lib\src\pic\TEMPLATE.c"
417   File "${DEV_ROOT}\lib\src\pic\TEMPLATE.S"
418
419   SetOutPath "$INSTDIR\lib\src\pic\libsdcc"
420   File "${DEV_ROOT}\lib\src\pic\libsdcc\*.c"
421   File "${DEV_ROOT}\lib\src\pic\libsdcc\*.S"
422   File "${DEV_ROOT}\lib\src\pic\libsdcc\*.inc"
423 #  File "${DEV_ROOT}\lib\src\pic\libsdcc\Makefile"
424   
425   SetOutPath "$INSTDIR\lib\src\pic\libdev"
426   File "${DEV_ROOT}\lib\src\pic\libdev\*.c"
427 #  File "${DEV_ROOT}\lib\src\pic\libdev\Makefile"
428
429   SetOutPath "$INSTDIR\lib\src\pic\libm"
430   File "${DEV_ROOT}\lib\src\pic\libm\*.c"
431
432   SetOutPath "$INSTDIR\lib\src\pic16"
433 #  File "${DEV_ROOT}\lib\src\pic16\configure"
434 #  File "${DEV_ROOT}\lib\src\pic16\configure.in"
435 #  File "${DEV_ROOT}\lib\src\pic16\COPYING"
436 #  File "${DEV_ROOT}\lib\src\pic16\Makefile"
437 #  File "${DEV_ROOT}\lib\src\pic16\Makefile.common"
438 #  File "${DEV_ROOT}\lib\src\pic16\Makefile.common.in"
439 #  File "${DEV_ROOT}\lib\src\pic16\Makefile.rules"
440 #  File "${DEV_ROOT}\lib\src\pic16\Makefile.subdir"
441 #  File "${DEV_ROOT}\lib\src\pic16\pics.all"
442 #  File "${DEV_ROOT}\lib\src\pic16\pics.build"
443 #  File "${DEV_ROOT}\lib\src\pic16\README"
444
445   SetOutPath "$INSTDIR\lib\src\pic16\debug"
446 #  File "${DEV_ROOT}\lib\src\pic16\debug\Makefile"
447
448   SetOutPath "$INSTDIR\lib\src\pic16\debug\gstack"
449 #  File "${DEV_ROOT}\lib\src\pic16\debug\gstack\Makefile"
450   File "${DEV_ROOT}\lib\src\pic16\debug\gstack\*.c"
451
452   SetOutPath "$INSTDIR\lib\src\pic16\libc"
453 #  File "${DEV_ROOT}\lib\src\pic16\libc\Makefile"
454
455   SetOutPath "$INSTDIR\lib\src\pic16\libc\ctype"
456   File "${DEV_ROOT}\lib\src\pic16\libc\ctype\*.c"
457 #  File "${DEV_ROOT}\lib\src\pic16\libc\ctype\Makefile"
458
459   SetOutPath "$INSTDIR\lib\src\pic16\libc\delay"
460   File "${DEV_ROOT}\lib\src\pic16\libc\delay\*.S"
461 #  File "${DEV_ROOT}\lib\src\pic16\libc\delay\Makefile"
462
463   SetOutPath "$INSTDIR\lib\src\pic16\libc\stdio"
464   File "${DEV_ROOT}\lib\src\pic16\libc\stdio\*.c"
465 #  File "${DEV_ROOT}\lib\src\pic16\libc\stdio\Makefile"
466
467   SetOutPath "$INSTDIR\lib\src\pic16\libc\stdlib"
468   File "${DEV_ROOT}\lib\src\pic16\libc\stdlib\*.c"
469   File "${DEV_ROOT}\lib\src\pic16\libc\stdlib\*.S"
470 #  File "${DEV_ROOT}\lib\src\pic16\libc\stdlib\Makefile"
471
472   SetOutPath "$INSTDIR\lib\src\pic16\libc\string"
473   File "${DEV_ROOT}\lib\src\pic16\libc\string\*.c"
474 #  File "${DEV_ROOT}\lib\src\pic16\libc\string\Makefile"
475
476   SetOutPath "$INSTDIR\lib\src\pic16\libc\utils"
477   File "${DEV_ROOT}\lib\src\pic16\libc\utils\*.S"
478 #  File "${DEV_ROOT}\lib\src\pic16\libc\utils\Makefile"
479
480   SetOutPath "$INSTDIR\lib\src\pic16\libdev"
481   File "${DEV_ROOT}\lib\src\pic16\libdev\*.c"
482 #  File "${DEV_ROOT}\lib\src\pic16\libdev\Makefile"
483
484   SetOutPath "$INSTDIR\lib\src\pic16\libio"
485   File "${DEV_ROOT}\lib\src\pic16\libio\*.ignore"
486 #  File "${DEV_ROOT}\lib\src\pic16\libio\Makefile"
487
488   SetOutPath "$INSTDIR\lib\src\pic16\libio\adc"
489   File "${DEV_ROOT}\lib\src\pic16\libio\adc\*.c"
490 #  File "${DEV_ROOT}\lib\src\pic16\libio\adc\Makefile"
491
492   SetOutPath "$INSTDIR\lib\src\pic16\libio\i2c"
493   File "${DEV_ROOT}\lib\src\pic16\libio\i2c\*.c"
494 #  File "${DEV_ROOT}\lib\src\pic16\libio\i2c\Makefile"
495
496   SetOutPath "$INSTDIR\lib\src\pic16\libio\usart"
497   File "${DEV_ROOT}\lib\src\pic16\libio\usart\*.c"
498 #  File "${DEV_ROOT}\lib\src\pic16\libio\usart\Makefile"
499
500   SetOutPath "$INSTDIR\lib\src\pic16\libm"
501   File "${DEV_ROOT}\lib\src\pic16\libm\*.c"
502 #  File "${DEV_ROOT}\lib\src\pic16\libm\Makefile"
503
504   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc"
505 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\Makefile"
506
507   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\char"
508   File "${DEV_ROOT}\lib\src\pic16\libsdcc\char\*.c"
509 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\char\Makefile"
510
511   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\fixed16x16"
512   File "${DEV_ROOT}\lib\src\pic16\libsdcc\fixed16x16\*.c"
513   File "${DEV_ROOT}\lib\src\pic16\libsdcc\fixed16x16\*.S"
514 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\fixed16x16\Makefile"
515
516   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\float"
517   File "${DEV_ROOT}\lib\src\pic16\libsdcc\float\*.c"
518 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\float\Makefile"
519
520   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\gptr"
521   File "${DEV_ROOT}\lib\src\pic16\libsdcc\gptr\*.c"
522 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\gptr\Makefile"
523
524   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\int"
525   File "${DEV_ROOT}\lib\src\pic16\libsdcc\int\*.c"
526 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\int\Makefile"
527
528   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\long"
529   File "${DEV_ROOT}\lib\src\pic16\libsdcc\long\*.c"
530 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\long\Makefile"
531
532   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\lregs"
533   File "${DEV_ROOT}\lib\src\pic16\libsdcc\lregs\*.c"
534 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\lregs\Makefile"
535
536   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\stack"
537   File "${DEV_ROOT}\lib\src\pic16\libsdcc\stack\*.S"
538
539   SetOutPath "$INSTDIR\lib\src\pic16\startup"
540   File "${DEV_ROOT}\lib\src\pic16\startup\*.c"
541 #  File "${DEV_ROOT}\lib\src\pic16\startup\Makefile"
542 #  File "${DEV_ROOT}\lib\src\pic16\startup\README"
543
544   SetOutPath "$INSTDIR\lib\src"
545   File "${DEV_ROOT}\lib\src\*.c"
546 SectionEnd
547
548 ;--------------------------------
549 ;Descriptions
550
551 ;Language strings
552 LangString DESC_SEC01 ${LANG_ENGLISH} "SDCC application files"
553 LangString DESC_SEC02 ${LANG_ENGLISH} "ucSim application files"
554 LangString DESC_SEC03 ${LANG_ENGLISH} "SDCDB files"
555 LangString DESC_SEC04 ${LANG_ENGLISH} "SDCC documentation"
556 LangString DESC_SEC05 ${LANG_ENGLISH} "SDCC include files"
557 LangString DESC_SEC06 ${LANG_ENGLISH} "SDCC DS390 library"
558 LangString DESC_SEC07 ${LANG_ENGLISH} "SDCC DS400 library"
559 LangString DESC_SEC08 ${LANG_ENGLISH} "SDCC GBZ80 library"
560 LangString DESC_SEC09 ${LANG_ENGLISH} "SDCC Z80 library"
561 LangString DESC_SEC10 ${LANG_ENGLISH} "SDCC small model library"
562 LangString DESC_SEC11 ${LANG_ENGLISH} "SDCC medium model library"
563 LangString DESC_SEC12 ${LANG_ENGLISH} "SDCC large model library"
564 LangString DESC_SEC13 ${LANG_ENGLISH} "SDCC small-stack-auto model library"
565 LangString DESC_SEC14 ${LANG_ENGLISH} "SDCC HC08 library"
566 LangString DESC_SEC15 ${LANG_ENGLISH} "SDCC PIC16 library"
567 LangString DESC_SEC16 ${LANG_ENGLISH} "SDCC PIC library"
568 LangString DESC_SEC17 ${LANG_ENGLISH} "SDCC library sources"
569
570 ;Assign language strings to sections
571 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
572   !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $(DESC_SEC01)
573   !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} $(DESC_SEC02)
574   !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} $(DESC_SEC03)
575   !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} $(DESC_SEC04)
576   !insertmacro MUI_DESCRIPTION_TEXT ${SEC05} $(DESC_SEC05)
577   !insertmacro MUI_DESCRIPTION_TEXT ${SEC06} $(DESC_SEC06)
578   !insertmacro MUI_DESCRIPTION_TEXT ${SEC07} $(DESC_SEC07)
579   !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} $(DESC_SEC08)
580   !insertmacro MUI_DESCRIPTION_TEXT ${SEC09} $(DESC_SEC09)
581   !insertmacro MUI_DESCRIPTION_TEXT ${SEC10} $(DESC_SEC10)
582   !insertmacro MUI_DESCRIPTION_TEXT ${SEC11} $(DESC_SEC11)
583   !insertmacro MUI_DESCRIPTION_TEXT ${SEC12} $(DESC_SEC12)
584   !insertmacro MUI_DESCRIPTION_TEXT ${SEC13} $(DESC_SEC13)
585   !insertmacro MUI_DESCRIPTION_TEXT ${SEC14} $(DESC_SEC14)
586   !insertmacro MUI_DESCRIPTION_TEXT ${SEC15} $(DESC_SEC15)
587   !insertmacro MUI_DESCRIPTION_TEXT ${SEC16} $(DESC_SEC16)
588   !insertmacro MUI_DESCRIPTION_TEXT ${SEC17} $(DESC_SEC17)
589 !insertmacro MUI_FUNCTION_DESCRIPTION_END
590 ;--------------------------------
591
592 Section -Icons
593 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
594   CreateDirectory "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE"
595   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\SDCC on the Web.lnk" "$INSTDIR\sdcc.url" 
596   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Uninstall SDCC.lnk" "$INSTDIR\uninstall.exe" 
597   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Documentation.lnk" "$INSTDIR\doc\README.TXT" "" "$INSTDIR\sdcc.ico" "" "" "" ""
598   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Change Log.lnk" "$INSTDIR\doc\ChangeLog_head.txt" "" "$INSTDIR\sdcc.ico" "" "" "" ""
599   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\GPL 2 License.lnk" "$INSTDIR\COPYING.TXT" 
600 !insertmacro MUI_STARTMENU_WRITE_END
601 SectionEnd
602
603 Section -INI
604   WriteIniStr "$INSTDIR\sdcc.url" "InternetShortcut" "URL" "http://sdcc.sourceforge.net/"
605 SectionEnd
606
607 Section -PostInstall
608   WriteRegStr HKLM "Software\${PRODUCT_NAME}" "" $INSTDIR
609 !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD
610   WriteRegDword HKLM "Software\${PRODUCT_NAME}" "VersionMajor" "${VER_MAJOR}"
611   WriteRegDword HKLM "Software\${PRODUCT_NAME}" "VersionMinor" "${VER_MINOR}"
612   WriteRegDword HKLM "Software\${PRODUCT_NAME}" "VersionRevision" "${VER_REVISION}"
613   WriteRegDword HKLM "Software\${PRODUCT_NAME}" "VersionBuild" "${VER_BUILD}"
614 !endif
615
616   WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "DisplayName" "${PRODUCT_NAME}"
617   WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "UninstallString" "$INSTDIR\uninstall.exe"
618   WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "Publisher" "sdcc.sourceforge.net"
619   WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "URLInfoAbout" "http://sdcc.sourceforge.net/"
620   WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "HelpLink" "http://sdcc.sourceforge.net/"
621   WriteRegStr HKLM ${PRODUCT_UNINST_KEY} "URLUpdateInfo" "http://sdcc.sourceforge.net/"
622
623   WriteUninstaller "$INSTDIR\uninstall.exe"
624 SectionEnd
625
626
627 ;;;; Uninstaller code ;;;;
628
629 Section Uninstall
630   !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_STARTMENUPAGE_VARIABLE
631
632   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\GPL 2 License.lnk"
633   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Change Log.lnk"
634   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Documentation.lnk"
635   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Uninstall SDCC.lnk"
636   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\SDCC on the Web.lnk"
637
638   RMDir "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE"
639
640   Delete "$INSTDIR\lib\src\large\Makefile"
641
642   Delete "$INSTDIR\lib\src\medium\Makefile"
643
644   Delete "$INSTDIR\lib\src\small\Makefile"
645
646   Delete "$INSTDIR\lib\src\mcs51\*.asm"
647   Delete "$INSTDIR\lib\src\mcs51\Makefile"
648   Delete "$INSTDIR\lib\src\mcs51\README"
649
650   Delete "$INSTDIR\lib\src\hc08\*.c"
651   Delete "$INSTDIR\lib\src\hc08\hc08.lib"
652   Delete "$INSTDIR\lib\src\hc08\Makefile"
653
654   Delete "$INSTDIR\lib\src\z80\*.c"
655   Delete "$INSTDIR\lib\src\z80\*.s"
656   Delete "$INSTDIR\lib\src\z80\z80.lib"
657   Delete "$INSTDIR\lib\src\z80\README"
658   Delete "$INSTDIR\lib\src\z80\Makefile"
659
660   Delete "$INSTDIR\lib\src\gbz80\*.c"
661   Delete "$INSTDIR\lib\src\gbz80\*.s"
662   Delete "$INSTDIR\lib\src\gbz80\gbz80.lib"
663   Delete "$INSTDIR\lib\src\gbz80\README"
664   Delete "$INSTDIR\lib\src\gbz80\Makefile"
665
666   Delete "$INSTDIR\lib\src\ds390\*.c"
667   Delete "$INSTDIR\lib\src\ds390\libds390.lib"
668   Delete "$INSTDIR\lib\src\ds390\Makefile.dep"
669   Delete "$INSTDIR\lib\src\ds390\Makefile"
670   Delete "$INSTDIR\lib\src\ds390\examples\MOVED"
671
672   Delete "$INSTDIR\lib\src\ds400\*.c"
673   Delete "$INSTDIR\lib\src\ds400\libds400.lib"
674   Delete "$INSTDIR\lib\src\ds400\Makefile.dep"
675   Delete "$INSTDIR\lib\src\ds400\Makefile"
676
677   Delete "$INSTDIR\lib\src\*.c"
678
679   Delete "$INSTDIR\lib\pic\*.o"
680   Delete "$INSTDIR\lib\pic\*.lib"
681
682   Delete "$INSTDIR\lib\pic16\*.o"
683   Delete "$INSTDIR\lib\pic16\*.lib"
684
685   Delete "$INSTDIR\lib\hc08\*.rel"
686   Delete "$INSTDIR\lib\hc08\*.lib"
687
688   Delete "$INSTDIR\lib\z80\*.o"
689   Delete "$INSTDIR\lib\z80\*.lib"
690
691   Delete "$INSTDIR\lib\small\*.rel"
692   Delete "$INSTDIR\lib\small\*.lib"
693
694   Delete "$INSTDIR\lib\medium\*.rel"
695   Delete "$INSTDIR\lib\medium\*.lib"
696
697   Delete "$INSTDIR\lib\large\*.rel"
698   Delete "$INSTDIR\lib\large\*.lib"
699
700   Delete "$INSTDIR\lib\small-stack-auto\*.rel"
701   Delete "$INSTDIR\lib\small-stack-auto\*.lib"
702
703   Delete "$INSTDIR\lib\gbz80\*.o"
704   Delete "$INSTDIR\lib\gbz80\*.lib"
705
706   Delete "$INSTDIR\lib\ds390\*.rel"
707   Delete "$INSTDIR\lib\ds390\*.lib"
708
709   Delete "$INSTDIR\lib\ds400\*.rel"
710   Delete "$INSTDIR\lib\ds400\*.lib"
711
712   Delete "$INSTDIR\include\asm\z80\*.h"
713   Delete "$INSTDIR\include\asm\pic16\*.h"
714   Delete "$INSTDIR\include\asm\pic\*.h"
715   Delete "$INSTDIR\include\asm\mcs51\*.h"
716   Delete "$INSTDIR\include\asm\gbz80\*.h"
717   Delete "$INSTDIR\include\asm\ds390\*.h"
718   Delete "$INSTDIR\include\asm\default\*.h"
719   Delete "$INSTDIR\include\z80\*.h"
720   Delete "$INSTDIR\include\pic\*.h"
721   Delete "$INSTDIR\include\pic\*.txt"
722   Delete "$INSTDIR\include\pic\*.inc"
723   Delete "$INSTDIR\include\pic16\*.h"
724   Delete "$INSTDIR\include\mcs51\*.h"
725   Delete "$INSTDIR\include\hc08\*.h"
726   Delete "$INSTDIR\include\*.h"
727
728 !ifndef FULL_DOC
729   Delete "$INSTDIR\doc\README.TXT"
730   Delete "$INSTDIR\doc\ChangeLog_head.txt"
731 !endif
732
733   Delete "$INSTDIR\bin\as-gbz80.exe"
734   Delete "$INSTDIR\bin\as-hc08.exe"
735   Delete "$INSTDIR\bin\as-z80.exe"
736   Delete "$INSTDIR\bin\asx8051.exe"
737   Delete "$INSTDIR\bin\aslink.exe"
738   Delete "$INSTDIR\bin\link-gbz80.exe"
739   Delete "$INSTDIR\bin\link-hc08.exe"
740   Delete "$INSTDIR\bin\link-z80.exe"
741   Delete "$INSTDIR\bin\makebin.exe"
742   Delete "$INSTDIR\bin\packihx.exe"
743   Delete "$INSTDIR\bin\sdcc.exe"
744   Delete "$INSTDIR\bin\sdcclib.exe"
745   Delete "$INSTDIR\bin\sdcpp.exe"
746   Delete "$INSTDIR\bin\readline5.dll"
747
748
749   Delete "$INSTDIR\bin\s51.exe"
750   Delete "$INSTDIR\bin\savr.exe"
751   Delete "$INSTDIR\bin\shc08.exe"
752   Delete "$INSTDIR\bin\sz80.exe"
753
754   Delete "$INSTDIR\bin\sdcdb.exe"
755   Delete "$INSTDIR\bin\sdcdb.el"
756   Delete "$INSTDIR\bin\sdcdbsrc.el"
757
758   Delete "$INSTDIR\COPYING.TXT"
759   Delete "$INSTDIR\sdcc.ico"
760   Delete "$INSTDIR\sdcc.url"
761   Delete "$INSTDIR\uninstall.exe"
762
763   RMDir /r "$INSTDIR\lib\src\pic"
764   RMDir /r "$INSTDIR\lib\src\pic16"
765   RMDir "$INSTDIR\lib\src\small"
766   RMDir "$INSTDIR\lib\src\medium"
767   RMDir "$INSTDIR\lib\src\large"
768   RMDir "$INSTDIR\lib\src\mcs51"
769   RMDir "$INSTDIR\lib\src\z80"
770   RMDir "$INSTDIR\lib\src\gbz80"
771   RMDir "$INSTDIR\lib\src\ds390\examples"
772   RMDir "$INSTDIR\lib\src\ds390"
773   RMDir "$INSTDIR\lib\src\ds400"
774   RMDir "$INSTDIR\lib\src\hc08"
775   RMDir "$INSTDIR\lib\src"
776
777   RMDir "$INSTDIR\lib\pic"
778   RMDir "$INSTDIR\lib\pic16"
779   RMDir "$INSTDIR\lib\z80"
780   RMDir "$INSTDIR\lib\small"
781   RMDir "$INSTDIR\lib\medium"
782   RMDir "$INSTDIR\lib\large"
783   RMDir "$INSTDIR\lib\small-stack-auto"
784   RMDir "$INSTDIR\lib\gbz80"
785   RMDir "$INSTDIR\lib\ds390"
786   RMDir "$INSTDIR\lib\ds400"
787   RMDir "$INSTDIR\lib\hc08"
788   RMDir "$INSTDIR\lib"
789
790   RMDir "$INSTDIR\include\asm\z80"
791   RMDir "$INSTDIR\include\asm\pic16"
792   RMDir "$INSTDIR\include\asm\pic"
793   RMDir "$INSTDIR\include\asm\mcs51"
794   RMDir "$INSTDIR\include\asm\gbz80"
795   RMDir "$INSTDIR\include\asm\ds390"
796   RMDir "$INSTDIR\include\asm\default"
797   RMDir "$INSTDIR\include\asm"
798   RMDir "$INSTDIR\include\z80"
799   RMDir "$INSTDIR\include\pic"
800   RMDir "$INSTDIR\include\pic16"
801   RMDir "$INSTDIR\include\mcs51"
802   RMDir "$INSTDIR\include\hc08"
803   RMDir "$INSTDIR\include"
804
805 !ifdef FULL_DOC
806   RMDir /r "$INSTDIR\doc"
807 !else
808   RMDir "$INSTDIR\doc"
809 !endif
810
811   RMDir "$INSTDIR\bin"
812
813   RMDir "$INSTDIR"
814
815   Push "$INSTDIR\bin"
816   Call un.RemoveFromPath
817
818 ; Clean the registry
819   DeleteRegValue HKLM ${PRODUCT_UNINST_KEY} "NSIS:StartMenuDir"
820   DeleteRegKey HKLM "${PRODUCT_UNINST_KEY}"
821   DeleteRegKey HKLM "Software\${PRODUCT_NAME}"
822 ;;;;  SetAutoClose true
823 SectionEnd
824
825 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
826 ; Path Manipulation functions                                                 ;
827 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
828
829 !verbose 3
830 !include "WinMessages.nsh"
831 !verbose 4
832
833 Function AddBinToPath
834     Push "$INSTDIR\bin"
835     Call AddToPath
836 FunctionEnd
837
838 ; AddToPath - Adds the given dir to the search path.
839 ;        Input - head of the stack
840 ;        Note - Win9x systems requires reboot
841
842 Function AddToPath
843   Exch $0
844   Push $1
845   Push $2
846   Push $3
847   Push $4
848
849   ; don't add if the path doesn't exist
850   IfFileExists $0 "" AddToPath_done
851
852   Call IsNT
853   Pop $4
854   StrCmp $4 1 +3
855     ; Not on NT: read PATH from environment variable
856     ReadEnvStr $1 PATH
857     Goto +2
858     ; On NT: read PATH from registry
859     ReadRegStr $1 HKCU "Environment" "PATH"
860   Push "$1;"
861   Push "$0;"
862   Call StrStr
863   Pop $2
864   StrCmp $2 "" "" AddToPath_done
865   Push "$1;"
866   Push "$0\;"
867   Call StrStr
868   Pop $2
869   StrCmp $2 "" "" AddToPath_done
870   GetFullPathName /SHORT $3 $0
871   Push "$1;"
872   Push "$3;"
873   Call StrStr
874   Pop $2
875   StrCmp $2 "" "" AddToPath_done
876   Push "$1;"
877   Push "$3\;"
878   Call StrStr
879   Pop $2
880   StrCmp $2 "" "" AddToPath_done
881
882   StrCmp $4 1 AddToPath_NT
883     ; Not on NT
884     StrCpy $1 $WINDIR 2
885     FileOpen $1 "$1\autoexec.bat" a
886     FileSeek $1 -1 END
887     FileReadByte $1 $2
888     IntCmp $2 26 0 +2 +2 ; DOS EOF
889       FileSeek $1 -1 END ; write over EOF
890     FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
891     FileClose $1
892     SetRebootFlag true
893     Goto AddToPath_done
894
895   AddToPath_NT:
896     ReadRegStr $1 HKCU "Environment" "PATH"
897     StrCpy $2 $1 1 -1  ; copy last char
898     StrCmp $2 ";" 0 +2 ; if last char == ;
899       StrCpy $1 $1 -1  ; remove last char
900     StrCmp $1 "" AddToPath_NTdoIt
901       StrCpy $0 "$1;$0"
902     AddToPath_NTdoIt:
903       WriteRegExpandStr HKCU "Environment" "PATH" $0
904       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
905
906   AddToPath_done:
907     Pop $4
908     Pop $3
909     Pop $2
910     Pop $1
911     Pop $0
912 FunctionEnd
913
914 ; RemoveFromPath - Remove a given dir from the path
915 ;     Input: head of the stack
916
917 Function un.RemoveFromPath
918   Exch $0
919   Push $1
920   Push $2
921   Push $3
922   Push $4
923   Push $5
924   Push $6
925
926   IntFmt $6 "%c" 26 ; DOS EOF
927
928   Call un.IsNT
929   Pop $1
930   StrCmp $1 1 unRemoveFromPath_NT
931     ; Not on NT
932     StrCpy $1 $WINDIR 2
933     FileOpen $1 "$1\autoexec.bat" r
934     GetTempFileName $4
935     FileOpen $2 $4 w
936     GetFullPathName /SHORT $0 $0
937     StrCpy $0 "SET PATH=%PATH%;$0"
938     Goto unRemoveFromPath_dosLoop
939
940     unRemoveFromPath_dosLoop:
941       FileRead $1 $3
942       StrCpy $5 $3 1 -1 ; read last char
943       StrCmp $5 $6 0 +2 ; if DOS EOF
944         StrCpy $3 $3 -1 ; remove DOS EOF so we can compare
945       StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
946       StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
947       StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
948       StrCmp $3 "" unRemoveFromPath_dosLoopEnd
949       FileWrite $2 $3
950       Goto unRemoveFromPath_dosLoop
951       unRemoveFromPath_dosLoopRemoveLine:
952         SetRebootFlag true
953         Goto unRemoveFromPath_dosLoop
954
955     unRemoveFromPath_dosLoopEnd:
956       FileClose $2
957       FileClose $1
958       StrCpy $1 $WINDIR 2
959       Delete "$1\autoexec.bat"
960       CopyFiles /SILENT $4 "$1\autoexec.bat"
961       Delete $4
962       Goto unRemoveFromPath_done
963
964   unRemoveFromPath_NT:
965     ReadRegStr $1 HKCU "Environment" "PATH"
966     StrCpy $5 $1 1 -1 ; copy last char
967     StrCmp $5 ";" +2  ; if last char != ;
968       StrCpy $1 "$1;" ; append ;
969     Push $1
970     Push "$0;"
971     Call un.StrStr    ; Find `$0;` in $1
972     Pop $2            ; pos of our dir
973     StrCmp $2 "" unRemoveFromPath_done
974       ; else, it is in path
975       ; $0 - path to add
976       ; $1 - path var
977       StrLen $3 "$0;"
978       StrLen $4 $2
979       StrCpy $5 $1 -$4   ; $5 is now the part before the path to remove
980       StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove
981       StrCpy $3 $5$6
982
983       StrCpy $5 $3 1 -1  ; copy last char
984       StrCmp $5 ";" 0 +2 ; if last char == ;
985         StrCpy $3 $3 -1  ; remove last char
986
987       StrCmp $3 "" +3
988         ; New PATH not empty: update the registry
989         WriteRegExpandStr HKCU "Environment" "PATH" $3
990         Goto +2
991         ; New PATH empty: remove from the registry
992         DeleteRegValue HKCU "Environment" "PATH"
993       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
994
995   unRemoveFromPath_done:
996     Pop $6
997     Pop $5
998     Pop $4
999     Pop $3
1000     Pop $2
1001     Pop $1
1002     Pop $0
1003 FunctionEnd
1004
1005 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1006 ; Utility Functions                                                           ;
1007 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1008
1009 ; IsNT
1010 ; no input
1011 ; output, top of the stack = 1 if NT or 0 if not
1012 ;
1013 ; Usage:
1014 ;   Call IsNT
1015 ;   Pop $R0
1016 ;  ($R0 at this point is 1 or 0)
1017
1018 !macro IsNT un
1019 Function ${un}IsNT
1020   Push $0
1021   ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
1022   StrCmp $0 "" 0 IsNT_yes
1023   ; we are not NT.
1024   Pop $0
1025   Push 0
1026   Return
1027
1028   IsNT_yes:
1029     ; NT!!!
1030     Pop $0
1031     Push 1
1032 FunctionEnd
1033 !macroend
1034 !insertmacro IsNT ""
1035 !insertmacro IsNT "un."
1036
1037 ; StrStr
1038 ; input, top of stack = string to search for
1039 ;        top of stack-1 = string to search in
1040 ; output, top of stack (replaces with the portion of the string remaining)
1041 ; modifies no other variables.
1042 ;
1043 ; Usage:
1044 ;   Push "this is a long ass string"
1045 ;   Push "ass"
1046 ;   Call StrStr
1047 ;   Pop $R0
1048 ;  ($R0 at this point is "ass string")
1049
1050 !macro StrStr un
1051 Function ${un}StrStr
1052 Exch $R1   ; st=haystack,old$R1, $R1=needle
1053   Exch     ; st=old$R1,haystack
1054   Exch $R2 ; st=old$R1,old$R2, $R2=haystack
1055   Push $R3
1056   Push $R4
1057   Push $R5
1058   StrLen $R3 $R1
1059   StrCpy $R4 0
1060   ; $R1=needle
1061   ; $R2=haystack
1062   ; $R3=len(needle)
1063   ; $R4=cnt
1064   ; $R5=tmp
1065   loop:
1066     StrCpy $R5 $R2 $R3 $R4
1067     StrCmp $R5 $R1 done
1068     StrCmp $R5 "" done
1069     IntOp $R4 $R4 + 1
1070     Goto loop
1071 done:
1072   StrCpy $R1 $R2 "" $R4
1073   Pop $R5
1074   Pop $R4
1075   Pop $R3
1076   Pop $R2
1077   Exch $R1
1078 FunctionEnd
1079 !macroend
1080 !insertmacro StrStr ""
1081 !insertmacro StrStr "un."
1082
1083 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1084 ;  Uninstall/Reinstall page functions                                         ;
1085 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1086
1087 !ifdef VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD
1088
1089 Var ReinstallPageCheck
1090
1091 Function PageReinstall
1092
1093   ReadRegStr $R0 HKLM "Software\${PRODUCT_NAME}" ""
1094
1095   ${If} $R0 == ""
1096     ReadRegStr $R0 HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
1097     ${If} $R0 == ""
1098       Abort
1099     ${EndIf}
1100   ${EndIf}
1101
1102   ReadRegDWORD $R0 HKLM "Software\${PRODUCT_NAME}" "VersionMajor"
1103   ReadRegDWORD $R1 HKLM "Software\${PRODUCT_NAME}" "VersionMinor"
1104   ReadRegDWORD $R2 HKLM "Software\${PRODUCT_NAME}" "VersionRevision"
1105   ReadRegDWORD $R3 HKLM "Software\${PRODUCT_NAME}" "VersionBuild"
1106   StrCpy $R0 $R0.$R1.$R2.$R3
1107
1108   ${VersionCompare} ${VER_MAJOR}.${VER_MINOR}.${VER_REVISION}.${VER_BUILD} $R0 $R0
1109   ${If} $R0 == 0
1110     StrCpy $R1 "${PRODUCT_NAME} ${PRODUCT_VERSION} is already installed. Select the operation you want to perform and click Next to continue."
1111     StrCpy $R2 "Add/Reinstall components"
1112     StrCpy $R3 "Uninstall ${PRODUCT_NAME}"
1113     !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose the maintenance option to perform."
1114     StrCpy $R0 "2"
1115   ${ElseIf} $R0 == 1
1116     StrCpy $R1 "An older version of ${PRODUCT_NAME} is installed on your system. It's recommended that you uninstall the current version before installing. Select the operation you want to perform and click Next to continue."
1117     StrCpy $R2 "Uninstall before installing"
1118     StrCpy $R3 "Do not uninstall"
1119     !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install ${PRODUCT_NAME}."
1120     StrCpy $R0 "1"
1121   ${ElseIf} $R0 == 2
1122     StrCpy $R1 "A newer version of ${PRODUCT_NAME} is already installed! It is not recommended that you install an older version. If you really want to install this older version, it's better to uninstall the current version first. Select the operation you want to perform and click Next to continue."
1123     StrCpy $R2 "Uninstall before installing"
1124     StrCpy $R3 "Do not uninstall"
1125     !insertmacro MUI_HEADER_TEXT "Already Installed" "Choose how you want to install ${PRODUCT_NAME}."
1126     StrCpy $R0 "1"
1127   ${Else}
1128     Abort
1129   ${EndIf}
1130
1131   nsDialogs::Create /NOUNLOAD 1018
1132
1133   ${NSD_CreateLabel} 0 0 100% 24u $R1
1134   Pop $R1
1135
1136   ${NSD_CreateRadioButton} 30u 50u -30u 8u $R2
1137   Pop $R2
1138   ${NSD_OnClick} $R2 PageReinstallUpdateSelection
1139
1140   ${NSD_CreateRadioButton} 30u 70u -30u 8u $R3
1141   Pop $R3
1142   ${NSD_OnClick} $R3 PageReinstallUpdateSelection
1143
1144   ${If} $ReinstallPageCheck != 2
1145     SendMessage $R2 ${BM_SETCHECK} ${BST_CHECKED} 0
1146   ${Else}
1147     SendMessage $R3 ${BM_SETCHECK} ${BST_CHECKED} 0
1148   ${EndIf}
1149
1150   nsDialogs::Show
1151
1152 FunctionEnd
1153
1154 Function PageReinstallUpdateSelection
1155
1156   Pop $R1
1157
1158   ${NSD_GetState} $R2 $R1
1159
1160   ${If} $R1 == ${BST_CHECKED}
1161     StrCpy $ReinstallPageCheck 1
1162   ${Else}
1163     StrCpy $ReinstallPageCheck 2
1164   ${EndIf}
1165
1166 FunctionEnd
1167
1168 Function PageLeaveReinstall
1169
1170   ${NSD_GetState} $R2 $R1
1171
1172   StrCmp $R0 "1" 0 +2
1173     StrCmp $R1 "1" reinst_uninstall reinst_done
1174
1175   StrCmp $R0 "2" 0 +3
1176     StrCmp $R1 "1" reinst_done reinst_uninstall
1177
1178   reinst_uninstall:
1179   ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString"
1180
1181   ;Run uninstaller
1182   HideWindow
1183
1184     ClearErrors
1185     ExecWait '$R1 _?=$INSTDIR'
1186
1187     IfErrors no_remove_uninstaller
1188     IfFileExists "$INSTDIR\bin\${PRODUCT_NAME}.exe" no_remove_uninstaller
1189
1190       Delete $R1
1191       RMDir $INSTDIR
1192
1193     no_remove_uninstaller:
1194
1195   StrCmp $R0 "2" 0 +2
1196     Quit
1197
1198   BringToFront
1199
1200   reinst_done:
1201
1202 FunctionEnd
1203
1204 !endif # VER_MAJOR & VER_MINOR & VER_REVISION & VER_BUILD