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