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