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