sdcc:
[fw/sdcc] / support / scripts / sdcc.nsi
1 # sdcc.nsi - NSIS installer script for SDCC
2 #
3 # Copyright (c) 2003-2006 Borut Razem
4 #
5 # This file is part of sdcc.
6 #
7 #  This software is provided 'as-is', without any express or implied
8 #  warranty.  In no event will the authors be held liable for any damages
9 #  arising from the use of this software.
10 #
11 #  Permission is granted to anyone to use this software for any purpose,
12 #  including commercial applications, and to alter it and redistribute it
13 #  freely, subject to the following restrictions:
14 #
15 #  1. The origin of this software must not be misrepresented; you must not
16 #     claim that you wrote the original software. If you use this software
17 #     in a product, an acknowledgment in the product documentation would be
18 #     appreciated but is not required.
19 #  2. Altered source versions must be plainly marked as such, and must not be
20 #     misrepresented as being the original software.
21 #  3. This notice may not be removed or altered from any source distribution.
22 #
23 #  Borut Razem
24 #  borut.razem@siol.net
25
26 # How to create WIN32 setup.exe
27 #
28 # - unpack WIN32 mingw daily snapshot sdcc-snapshot-i586-mingw32msvc-yyyymmdd.zip
29 #   to a clean directory (the option to create directories should be enabled).
30 #   A sub directory sdcc is created (referenced as PKGDIR in continuation).
31 # - copy files sdcc/support/scripts/sdcc.ico and sdcc/support/scripts/sdcc.nsi
32 #   (this file) from the sdcc Subversion snapshot to the PKGDIR directory
33 # - copy file COPYING from the sdcc Subversion snapshot to the PKGDIR directory,
34 #   rename it to COPYING.TXT and convert file COPYING to DOS format:
35 #   unix2dos COPYING.TXT
36 # - run NSIS installer from PKGDIR directory:
37 #   "c:\Program Files\NSIS\makensis.exe" sdcc.nsi
38 # - A setup file setup.exe is created in PKGDIR directory.
39 #   Rename it to sdcc_yyyymmdd_setup.exe and upload it
40 #   to sdcc download repository at sourceforge.net
41 #
42 #
43 # How to upload secc setup.exe tosourceforge.net
44 #
45 # Execute following commands from the cmd prompt:
46 # - sftp sdcc.sourceforge.net
47 # - cd /home/groups/s/sd/sdcc/htdocs/snapshots/i586-mingw32msvc-setup
48 # - put sdcc_yyyymmdd_setup.exe
49 # - quit
50
51
52 !include "MUI.nsh"
53
54 SetCompressor /SOLID lzma
55
56 !define SDCC_ROOT "."
57
58 !define DEV_ROOT "${SDCC_ROOT}"
59
60 !system "unix2dos ${SDCC_ROOT}\doc\ChangeLog_head.txt" = 0
61 !system "unix2dos ${SDCC_ROOT}\doc\README.TXT" = 0
62
63 InstType "Full (Bin, Doc, Lib, Src)"
64 InstType "Medium (Bin, Doc, Lib)"
65 InstType "Compact (Bin, Doc)"
66
67 ;--------------------------------
68 ;Variables
69
70 Var MUI_STARTMENUPAGE_VARIABLE
71
72 ;--------------------------------
73 !define MUI_ABORTWARNING
74
75 !insertmacro MUI_PAGE_WELCOME
76 !insertmacro MUI_PAGE_LICENSE "${SDCC_ROOT}\COPYING.TXT"
77 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "SDCC"
78 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
79 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC"
80 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "NSIS:StartMenuDir"
81 !define MUI_STARTMENUPAGE_NODISABLE
82 !insertmacro MUI_PAGE_STARTMENU Application $MUI_STARTMENUPAGE_VARIABLE
83 !insertmacro MUI_PAGE_COMPONENTS
84 !insertmacro MUI_PAGE_DIRECTORY
85 !insertmacro MUI_PAGE_INSTFILES
86 !insertmacro MUI_PAGE_FINISH
87
88 !insertmacro MUI_UNPAGE_INSTFILES
89
90 !insertmacro MUI_LANGUAGE "English"
91
92 Name "SDCC"
93 BrandingText ""
94 OutFile "setup.exe"
95 InstallDir "$PROGRAMFILES\SDCC"
96 ShowInstDetails show
97 ShowUnInstDetails show
98
99 Function .onInit
100   ;Uninstall the old version, if present
101   ReadRegStr $R0 HKLM \
102   "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" \
103   "UninstallString"
104   StrCmp $R0 "" inst
105
106   MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
107   "$(^Name) is already installed. $\n$\nClick 'OK' to remove the \
108   previous version or 'Cancel' to cancel this upgrade." \
109   IDOK uninst
110   Abort
111
112 uninst:
113   ; Run the uninstaller
114   ClearErrors
115   ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
116
117   ;IfErrors no_remove_uninstaller
118   ;  ;You can either use Delete /REBOOTOK in the uninstaller or add some code
119   ;  ;here to remove to remove the uninstaller. Use a registry key to check
120   ;  ;whether the user has chosen to uninstall. If you are using an uninstaller
121   ;  ;components page, make sure all sections are uninstalled.
122   ;no_remove_uninstaller:
123
124   Goto done
125 inst:
126
127   ; Install the new version
128   MessageBox MB_YESNO|MB_ICONQUESTION "This will install $(^Name). Do you wish to continue?" IDYES +2
129   Abort
130
131 done:
132 FunctionEnd
133
134 Section -Common
135   SetOutPath "$INSTDIR"
136   File ".\sdcc.ico"
137   File "${SDCC_ROOT}\COPYING.TXT"
138 SectionEnd
139
140 Section "SDCC application files"
141   SectionIn 1 2 3 RO
142   SetOutPath "$INSTDIR\bin"
143   File "${SDCC_ROOT}\bin\*.exe"
144 SectionEnd
145
146 Section "SDCC documentation"
147   SectionIn 1 2 3
148   SetOutPath "$INSTDIR\doc"
149 !ifdef FULL_DOC
150   File /r "${SDCC_ROOT}\doc\*"
151 !else
152   File "${SDCC_ROOT}\doc\ChangeLog_head.txt"
153   File "${SDCC_ROOT}\doc\README.TXT"
154 !endif
155 SectionEnd
156
157 Section "SDCC include files"
158   SectionIn 1 2
159   SetOutPath "$INSTDIR\include\asm\default"
160   File "${DEV_ROOT}\include\asm\default\features.h"
161   SetOutPath "$INSTDIR\include\asm\ds390"
162   File "${DEV_ROOT}\include\asm\ds390\features.h"
163   SetOutPath "$INSTDIR\include\asm\gbz80"
164   File "${DEV_ROOT}\include\asm\gbz80\features.h"
165   SetOutPath "$INSTDIR\include\asm\mcs51"
166   File "${DEV_ROOT}\include\asm\mcs51\features.h"
167   SetOutPath "$INSTDIR\include\asm\pic"
168   File "${DEV_ROOT}\include\asm\pic\features.h"
169   SetOutPath "$INSTDIR\include\asm\pic16"
170   File "${DEV_ROOT}\include\asm\pic16\features.h"
171   SetOutPath "$INSTDIR\include\asm\z80"
172   File "${DEV_ROOT}\include\asm\z80\features.h"
173   SetOutPath "$INSTDIR\include\hc08"
174   File "${DEV_ROOT}\include\hc08\*.h"
175   SetOutPath "$INSTDIR\include\mcs51"
176   File "${DEV_ROOT}\include\mcs51\*.h"
177   SetOutPath "$INSTDIR\include\pic"
178   File "${DEV_ROOT}\include\pic\*.h"
179   File "${DEV_ROOT}\include\pic\*.txt"
180   File "${DEV_ROOT}\include\pic\*.inc"
181   SetOutPath "$INSTDIR\include\pic16"
182   File "${DEV_ROOT}\include\pic16\*.h"
183   SetOutPath "$INSTDIR\include\z80"
184   File "${DEV_ROOT}\include\z80\*.h"
185   SetOutPath "$INSTDIR\include"
186   File "${DEV_ROOT}\include\*.h"
187 SectionEnd
188
189 Section "SDCC DS390 library"
190   SectionIn 1 2
191   SetOutPath "$INSTDIR\lib\ds390"
192   File "${DEV_ROOT}\lib\ds390\*.rel"
193   File "${DEV_ROOT}\lib\ds390\*.lib"
194 SectionEnd
195
196 Section "SDCC DS400 library"
197   SectionIn 1 2
198   SetOutPath "$INSTDIR\lib\ds400"
199   File "${DEV_ROOT}\lib\ds400\*.rel"
200   File "${DEV_ROOT}\lib\ds400\*.lib"
201 SectionEnd
202
203 Section "SDCC GBZ80 library"
204   SectionIn 1 2
205   SetOutPath "$INSTDIR\lib\gbz80"
206   File "${DEV_ROOT}\lib\gbz80\*.o"
207   File "${DEV_ROOT}\lib\gbz80\*.lib"
208 SectionEnd
209
210 Section "SDCC Z80 library"
211   SectionIn 1 2
212   SetOutPath "$INSTDIR\lib\z80"
213   File "${DEV_ROOT}\lib\z80\*.o"
214   File "${DEV_ROOT}\lib\z80\*.lib"
215 SectionEnd
216
217 Section "SDCC small model library"
218   SectionIn 1 2
219   SetOutPath "$INSTDIR\lib\small"
220   File "${DEV_ROOT}\lib\small\*.rel"
221   File "${DEV_ROOT}\lib\small\*.lib"
222 SectionEnd
223
224 Section "SDCC medium model library"
225   SectionIn 1 2
226   SetOutPath "$INSTDIR\lib\medium"
227   File "${DEV_ROOT}\lib\medium\*.rel"
228   File "${DEV_ROOT}\lib\medium\*.lib"
229 SectionEnd
230
231 Section "SDCC large model library"
232   SectionIn 1 2
233   SetOutPath "$INSTDIR\lib\large"
234   File "${DEV_ROOT}\lib\large\*.rel"
235   File "${DEV_ROOT}\lib\large\*.lib"
236 SectionEnd
237
238 Section "SDCC small-stack-auto model library"
239   SectionIn 1 2
240   SetOutPath "$INSTDIR\lib\small-stack-auto"
241   File "${DEV_ROOT}\lib\small-stack-auto\*.rel"
242   File "${DEV_ROOT}\lib\small-stack-auto\*.lib"
243 SectionEnd
244
245 Section "SDCC HC08 library"
246   SectionIn 1 2
247   SetOutPath "$INSTDIR\lib\hc08"
248   File "${DEV_ROOT}\lib\hc08\*.rel"
249   File "${DEV_ROOT}\lib\hc08\*.lib"
250 SectionEnd
251
252 Section "SDCC PIC16 library"
253   SectionIn 1 2
254   SetOutPath "$INSTDIR\lib\pic16"
255   File "${DEV_ROOT}\lib\pic16\*.o"
256   File "${DEV_ROOT}\lib\pic16\*.lib"
257 SectionEnd
258
259 Section "SDCC PIC library"
260   SectionIn 1 2
261   SetOutPath "$INSTDIR\lib\pic"
262   File "${DEV_ROOT}\lib\pic\*.lib"
263 SectionEnd
264
265 Section "SDCC library sources"
266   SectionIn 1
267   SetOutPath "$INSTDIR\lib\src\ds390\examples"
268   File "${DEV_ROOT}\lib\src\ds390\examples\MOVED"
269
270   SetOutPath "$INSTDIR\lib\src\ds390"
271   File "${DEV_ROOT}\lib\src\ds390\*.c"
272 #  File "${DEV_ROOT}\lib\src\ds390\Makefile"
273
274   SetOutPath "$INSTDIR\lib\src\ds400"
275   File "${DEV_ROOT}\lib\src\ds400\*.c"
276 #  File "${DEV_ROOT}\lib\src\ds400\Makefile"
277
278   SetOutPath "$INSTDIR\lib\src\gbz80"
279   File "${DEV_ROOT}\lib\src\gbz80\*.c"
280   File "${DEV_ROOT}\lib\src\gbz80\*.s"
281 #  File "${DEV_ROOT}\lib\src\gbz80\Makefile"
282
283   SetOutPath "$INSTDIR\lib\src\z80"
284   File "${DEV_ROOT}\lib\src\z80\*.c"
285   File "${DEV_ROOT}\lib\src\z80\*.s"
286 #  File "${DEV_ROOT}\lib\src\z80\Makefile"
287
288   SetOutPath "$INSTDIR\lib\src\hc08"
289   File "${DEV_ROOT}\lib\src\hc08\*.c"
290 #  File "${DEV_ROOT}\lib\src\hc08\Makefile"
291
292   SetOutPath "$INSTDIR\lib\src\mcs51"
293   File "${DEV_ROOT}\lib\src\mcs51\*.asm"
294 #  File "${DEV_ROOT}\lib\src\mcs51\Makefile"
295
296   SetOutPath "$INSTDIR\lib\src\small"
297 #  File "${DEV_ROOT}\lib\src\small\Makefile"
298
299   SetOutPath "$INSTDIR\lib\src\medium"
300 #  File "${DEV_ROOT}\lib\src\medium\Makefile"
301
302   SetOutPath "$INSTDIR\lib\src\large"
303 #  File "${DEV_ROOT}\lib\src\large\Makefile"
304
305   SetOutPath "$INSTDIR\lib\src\pic"
306 #  File "${DEV_ROOT}\lib\src\pic\configure"
307 #  File "${DEV_ROOT}\lib\src\pic\configure.in"
308 #  File "${DEV_ROOT}\lib\src\pic\GPL"
309 #  File "${DEV_ROOT}\lib\src\pic\LGPL"
310 #  File "${DEV_ROOT}\lib\src\pic\Makefile"
311 #  File "${DEV_ROOT}\lib\src\pic\Makefile.common"
312 #  File "${DEV_ROOT}\lib\src\pic\Makefile.common.in"
313 #  File "${DEV_ROOT}\lib\src\pic\Makefile.rules"
314 #  File "${DEV_ROOT}\lib\src\pic\Makefile.subdir"
315 #  File "${DEV_ROOT}\lib\src\pic\NEWS"
316 #  File "${DEV_ROOT}\lib\src\pic\README"
317   File "${DEV_ROOT}\lib\src\pic\TEMPLATE.c"
318   File "${DEV_ROOT}\lib\src\pic\TEMPLATE.S"
319
320   SetOutPath "$INSTDIR\lib\src\pic\libsdcc"
321   File "${DEV_ROOT}\lib\src\pic\libsdcc\*.c"
322   File "${DEV_ROOT}\lib\src\pic\libsdcc\*.S"
323   File "${DEV_ROOT}\lib\src\pic\libsdcc\*.inc"
324 #  File "${DEV_ROOT}\lib\src\pic\libsdcc\Makefile"
325   
326   SetOutPath "$INSTDIR\lib\src\pic\libdev"
327   File "${DEV_ROOT}\lib\src\pic\libdev\*.c"
328 #  File "${DEV_ROOT}\lib\src\pic\libdev\Makefile"
329
330   SetOutPath "$INSTDIR\lib\src\pic\libm"
331   File "${DEV_ROOT}\lib\src\pic\libm\*.c"
332
333   SetOutPath "$INSTDIR\lib\src\pic16"
334 #  File "${DEV_ROOT}\lib\src\pic16\configure"
335 #  File "${DEV_ROOT}\lib\src\pic16\configure.in"
336 #  File "${DEV_ROOT}\lib\src\pic16\COPYING"
337 #  File "${DEV_ROOT}\lib\src\pic16\Makefile"
338 #  File "${DEV_ROOT}\lib\src\pic16\Makefile.common"
339 #  File "${DEV_ROOT}\lib\src\pic16\Makefile.common.in"
340 #  File "${DEV_ROOT}\lib\src\pic16\Makefile.rules"
341 #  File "${DEV_ROOT}\lib\src\pic16\Makefile.subdir"
342 #  File "${DEV_ROOT}\lib\src\pic16\pics.all"
343 #  File "${DEV_ROOT}\lib\src\pic16\pics.build"
344 #  File "${DEV_ROOT}\lib\src\pic16\README"
345
346   SetOutPath "$INSTDIR\lib\src\pic16\debug"
347 #  File "${DEV_ROOT}\lib\src\pic16\debug\Makefile"
348
349   SetOutPath "$INSTDIR\lib\src\pic16\debug\gstack"
350 #  File "${DEV_ROOT}\lib\src\pic16\debug\gstack\Makefile"
351   File "${DEV_ROOT}\lib\src\pic16\debug\gstack\*.c"
352
353   SetOutPath "$INSTDIR\lib\src\pic16\libc"
354 #  File "${DEV_ROOT}\lib\src\pic16\libc\Makefile"
355
356   SetOutPath "$INSTDIR\lib\src\pic16\libc\ctype"
357   File "${DEV_ROOT}\lib\src\pic16\libc\ctype\*.c"
358 #  File "${DEV_ROOT}\lib\src\pic16\libc\ctype\Makefile"
359
360   SetOutPath "$INSTDIR\lib\src\pic16\libc\delay"
361   File "${DEV_ROOT}\lib\src\pic16\libc\delay\*.S"
362 #  File "${DEV_ROOT}\lib\src\pic16\libc\delay\Makefile"
363
364   SetOutPath "$INSTDIR\lib\src\pic16\libc\stdio"
365   File "${DEV_ROOT}\lib\src\pic16\libc\stdio\*.c"
366 #  File "${DEV_ROOT}\lib\src\pic16\libc\stdio\Makefile"
367
368   SetOutPath "$INSTDIR\lib\src\pic16\libc\stdlib"
369   File "${DEV_ROOT}\lib\src\pic16\libc\stdlib\*.c"
370   File "${DEV_ROOT}\lib\src\pic16\libc\stdlib\*.S"
371 #  File "${DEV_ROOT}\lib\src\pic16\libc\stdlib\Makefile"
372
373   SetOutPath "$INSTDIR\lib\src\pic16\libc\string"
374   File "${DEV_ROOT}\lib\src\pic16\libc\string\*.c"
375 #  File "${DEV_ROOT}\lib\src\pic16\libc\string\Makefile"
376
377   SetOutPath "$INSTDIR\lib\src\pic16\libc\utils"
378   File "${DEV_ROOT}\lib\src\pic16\libc\utils\*.S"
379 #  File "${DEV_ROOT}\lib\src\pic16\libc\utils\Makefile"
380
381   SetOutPath "$INSTDIR\lib\src\pic16\libdev"
382   File "${DEV_ROOT}\lib\src\pic16\libdev\*.c"
383 #  File "${DEV_ROOT}\lib\src\pic16\libdev\Makefile"
384
385   SetOutPath "$INSTDIR\lib\src\pic16\libio"
386   File "${DEV_ROOT}\lib\src\pic16\libio\*.ignore"
387 #  File "${DEV_ROOT}\lib\src\pic16\libio\Makefile"
388
389   SetOutPath "$INSTDIR\lib\src\pic16\libio\adc"
390   File "${DEV_ROOT}\lib\src\pic16\libio\adc\*.c"
391 #  File "${DEV_ROOT}\lib\src\pic16\libio\adc\Makefile"
392
393   SetOutPath "$INSTDIR\lib\src\pic16\libio\i2c"
394   File "${DEV_ROOT}\lib\src\pic16\libio\i2c\*.c"
395 #  File "${DEV_ROOT}\lib\src\pic16\libio\i2c\Makefile"
396
397   SetOutPath "$INSTDIR\lib\src\pic16\libio\usart"
398   File "${DEV_ROOT}\lib\src\pic16\libio\usart\*.c"
399 #  File "${DEV_ROOT}\lib\src\pic16\libio\usart\Makefile"
400
401   SetOutPath "$INSTDIR\lib\src\pic16\libm"
402   File "${DEV_ROOT}\lib\src\pic16\libm\*.c"
403 #  File "${DEV_ROOT}\lib\src\pic16\libm\Makefile"
404
405   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc"
406 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\Makefile"
407
408   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\char"
409   File "${DEV_ROOT}\lib\src\pic16\libsdcc\char\*.c"
410 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\char\Makefile"
411
412   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\fixed16x16"
413   File "${DEV_ROOT}\lib\src\pic16\libsdcc\fixed16x16\*.c"
414   File "${DEV_ROOT}\lib\src\pic16\libsdcc\fixed16x16\*.S"
415 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\fixed16x16\Makefile"
416
417   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\float"
418   File "${DEV_ROOT}\lib\src\pic16\libsdcc\float\*.c"
419 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\float\Makefile"
420
421   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\gptr"
422   File "${DEV_ROOT}\lib\src\pic16\libsdcc\gptr\*.c"
423 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\gptr\Makefile"
424
425   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\int"
426   File "${DEV_ROOT}\lib\src\pic16\libsdcc\int\*.c"
427 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\int\Makefile"
428
429   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\long"
430   File "${DEV_ROOT}\lib\src\pic16\libsdcc\long\*.c"
431 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\long\Makefile"
432
433   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\lregs"
434   File "${DEV_ROOT}\lib\src\pic16\libsdcc\lregs\*.c"
435 #  File "${DEV_ROOT}\lib\src\pic16\libsdcc\lregs\Makefile"
436
437   SetOutPath "$INSTDIR\lib\src\pic16\libsdcc\stack"
438   File "${DEV_ROOT}\lib\src\pic16\libsdcc\stack\*.S"
439
440   SetOutPath "$INSTDIR\lib\src\pic16\startup"
441   File "${DEV_ROOT}\lib\src\pic16\startup\*.c"
442 #  File "${DEV_ROOT}\lib\src\pic16\startup\Makefile"
443 #  File "${DEV_ROOT}\lib\src\pic16\startup\README"
444
445   SetOutPath "$INSTDIR\lib\src"
446   File "${DEV_ROOT}\lib\src\*.c"
447 SectionEnd
448
449 Section -Icons
450 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
451   CreateDirectory "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE"
452   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\SDCC on the Web.lnk" "$INSTDIR\sdcc.url" 
453   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Uninstall SDCC.lnk" "$INSTDIR\uninstall.exe" 
454   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Documentation.lnk" "$INSTDIR\doc\README.TXT" "" "$INSTDIR\sdcc.ico" "" "" "" ""
455   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Change Log.lnk" "$INSTDIR\doc\ChangeLog_head.txt" "" "$INSTDIR\sdcc.ico" "" "" "" ""
456   CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\GPL 2 License.lnk" "$INSTDIR\COPYING.TXT" 
457 !insertmacro MUI_STARTMENU_WRITE_END
458 SectionEnd
459
460 Section -INI
461   WriteIniStr "$INSTDIR\sdcc.url" "InternetShortcut" "URL" "http://sdcc.sourceforge.net/"
462 SectionEnd
463
464 Section -PostInstall
465   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "DisplayName" "SDCC"
466   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "UninstallString" "$INSTDIR\uninstall.exe"
467   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "Publisher" "sdcc.sourceforge.net"
468   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "URLInfoAbout" "http://sdcc.sourceforge.net/"
469   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "HelpLink" "http://sdcc.sourceforge.net/"
470   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "URLUpdateInfo" "http://sdcc.sourceforge.net/"
471   WriteUninstaller "$INSTDIR\uninstall.exe"
472 SectionEnd
473
474 Section -AddToPath
475   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Do you want to add $INSTDIR\bin to the PATH?" IDNO +3
476     Push "$INSTDIR\bin"
477     Call AddToPath
478 SectionEnd
479
480
481 ;;;; Uninstaller code ;;;;
482
483 Function un.onInit
484   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
485   Abort
486 FunctionEnd
487
488 Function un.onUninstSuccess
489   HideWindow
490   MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
491 FunctionEnd
492
493 Section Uninstall
494   !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_STARTMENUPAGE_VARIABLE
495
496   Delete "$INSTDIR\sdcc.url"
497
498   DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "NSIS:StartMenuDir"
499   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC"
500
501   Delete "$INSTDIR\uninstall.exe"
502   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\GPL 2 License.lnk"
503   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Change Log.lnk"
504   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Documentation.lnk"
505   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Uninstall SDCC.lnk"
506   Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\SDCC on the Web.lnk"
507
508   Delete "$INSTDIR\lib\src\large\Makefile"
509
510   Delete "$INSTDIR\lib\src\medium\Makefile"
511
512   Delete "$INSTDIR\lib\src\small\Makefile"
513
514   Delete "$INSTDIR\lib\src\mcs51\*.asm"
515   Delete "$INSTDIR\lib\src\mcs51\Makefile"
516   Delete "$INSTDIR\lib\src\mcs51\README"
517
518   Delete "$INSTDIR\lib\src\hc08\*.c"
519   Delete "$INSTDIR\lib\src\hc08\hc08.lib"
520   Delete "$INSTDIR\lib\src\hc08\Makefile"
521
522   Delete "$INSTDIR\lib\src\z80\*.c"
523   Delete "$INSTDIR\lib\src\z80\*.s"
524   Delete "$INSTDIR\lib\src\z80\z80.lib"
525   Delete "$INSTDIR\lib\src\z80\README"
526   Delete "$INSTDIR\lib\src\z80\Makefile"
527
528   Delete "$INSTDIR\lib\src\gbz80\*.c"
529   Delete "$INSTDIR\lib\src\gbz80\*.s"
530   Delete "$INSTDIR\lib\src\gbz80\gbz80.lib"
531   Delete "$INSTDIR\lib\src\gbz80\README"
532   Delete "$INSTDIR\lib\src\gbz80\Makefile"
533
534   Delete "$INSTDIR\lib\src\ds390\*.c"
535   Delete "$INSTDIR\lib\src\ds390\libds390.lib"
536   Delete "$INSTDIR\lib\src\ds390\Makefile.dep"
537   Delete "$INSTDIR\lib\src\ds390\Makefile"
538   Delete "$INSTDIR\lib\src\ds390\examples\MOVED"
539
540   Delete "$INSTDIR\lib\src\ds400\*.c"
541   Delete "$INSTDIR\lib\src\ds400\libds400.lib"
542   Delete "$INSTDIR\lib\src\ds400\Makefile.dep"
543   Delete "$INSTDIR\lib\src\ds400\Makefile"
544
545   Delete "$INSTDIR\lib\src\*.c"
546
547   Delete "$INSTDIR\lib\pic\*.o"
548   Delete "$INSTDIR\lib\pic\*.lib"
549
550   Delete "$INSTDIR\lib\pic16\*.o"
551   Delete "$INSTDIR\lib\pic16\*.lib"
552
553   Delete "$INSTDIR\lib\hc08\*.rel"
554   Delete "$INSTDIR\lib\hc08\*.lib"
555
556   Delete "$INSTDIR\lib\z80\*.o"
557   Delete "$INSTDIR\lib\z80\*.lib"
558
559   Delete "$INSTDIR\lib\small\*.rel"
560   Delete "$INSTDIR\lib\small\*.lib"
561
562   Delete "$INSTDIR\lib\medium\*.rel"
563   Delete "$INSTDIR\lib\medium\*.lib"
564
565   Delete "$INSTDIR\lib\large\*.rel"
566   Delete "$INSTDIR\lib\large\*.lib"
567
568   Delete "$INSTDIR\lib\small-stack-auto\*.rel"
569   Delete "$INSTDIR\lib\small-stack-auto\*.lib"
570
571   Delete "$INSTDIR\lib\gbz80\*.o"
572   Delete "$INSTDIR\lib\gbz80\*.lib"
573
574   Delete "$INSTDIR\lib\ds390\*.rel"
575   Delete "$INSTDIR\lib\ds390\*.lib"
576
577   Delete "$INSTDIR\lib\ds400\*.rel"
578   Delete "$INSTDIR\lib\ds400\*.lib"
579
580   Delete "$INSTDIR\include\asm\z80\*.h"
581   Delete "$INSTDIR\include\asm\pic16\*.h"
582   Delete "$INSTDIR\include\asm\pic\*.h"
583   Delete "$INSTDIR\include\asm\mcs51\*.h"
584   Delete "$INSTDIR\include\asm\gbz80\*.h"
585   Delete "$INSTDIR\include\asm\ds390\*.h"
586   Delete "$INSTDIR\include\asm\default\*.h"
587   Delete "$INSTDIR\include\z80\*.h"
588   Delete "$INSTDIR\include\pic\*.h"
589   Delete "$INSTDIR\include\pic\*.txt"
590   Delete "$INSTDIR\include\pic\*.inc"
591   Delete "$INSTDIR\include\pic16\*.h"
592   Delete "$INSTDIR\include\mcs51\*.h"
593   Delete "$INSTDIR\include\hc08\*.h"
594   Delete "$INSTDIR\include\*.h"
595
596 !ifndef FULL_DOC
597   Delete "$INSTDIR\doc\README.TXT"
598   Delete "$INSTDIR\doc\ChangeLog_head.txt"
599 !endif
600
601   Delete "$INSTDIR\bin\*.exe"
602
603   Delete "$INSTDIR\COPYING.TXT"
604   Delete "$INSTDIR\sdcc.ico"
605
606   RMDir "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE"
607
608   RMDir /r "$INSTDIR\lib\src\pic"
609   RMDir /r "$INSTDIR\lib\src\pic16"
610   RMDir "$INSTDIR\lib\src\small"
611   RMDir "$INSTDIR\lib\src\medium"
612   RMDir "$INSTDIR\lib\src\large"
613   RMDir "$INSTDIR\lib\src\mcs51"
614   RMDir "$INSTDIR\lib\src\z80"
615   RMDir "$INSTDIR\lib\src\gbz80"
616   RMDir "$INSTDIR\lib\src\ds390\examples"
617   RMDir "$INSTDIR\lib\src\ds390"
618   RMDir "$INSTDIR\lib\src\ds400"
619   RMDir "$INSTDIR\lib\src\hc08"
620   RMDir "$INSTDIR\lib\src"
621
622   RMDir "$INSTDIR\lib\pic"
623   RMDir "$INSTDIR\lib\pic16"
624   RMDir "$INSTDIR\lib\z80"
625   RMDir "$INSTDIR\lib\small"
626   RMDir "$INSTDIR\lib\medium"
627   RMDir "$INSTDIR\lib\large"
628   RMDir "$INSTDIR\lib\small-stack-auto"
629   RMDir "$INSTDIR\lib\gbz80"
630   RMDir "$INSTDIR\lib\ds390"
631   RMDir "$INSTDIR\lib\ds400"
632   RMDir "$INSTDIR\lib\hc08"
633   RMDir "$INSTDIR\lib"
634
635   RMDir "$INSTDIR\include\asm\z80"
636   RMDir "$INSTDIR\include\asm\pic16"
637   RMDir "$INSTDIR\include\asm\pic"
638   RMDir "$INSTDIR\include\asm\mcs51"
639   RMDir "$INSTDIR\include\asm\gbz80"
640   RMDir "$INSTDIR\include\asm\ds390"
641   RMDir "$INSTDIR\include\asm\default"
642   RMDir "$INSTDIR\include\asm"
643   RMDir "$INSTDIR\include\z80"
644   RMDir "$INSTDIR\include\pic"
645   RMDir "$INSTDIR\include\pic16"
646   RMDir "$INSTDIR\include\mcs51"
647   RMDir "$INSTDIR\include\hc08"
648   RMDir "$INSTDIR\include"
649
650 !ifdef FULL_DOC
651   RMDir /r "$INSTDIR\doc"
652 !else
653   RMDir "$INSTDIR\doc"
654 !endif
655
656   RMDir "$INSTDIR\bin"
657
658   RMDir "$INSTDIR"
659
660   Push "$INSTDIR\bin"
661   Call un.RemoveFromPath
662
663   SetAutoClose true
664 SectionEnd
665
666 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
667 ; Path Manipulation functions                                                 ;
668 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
669
670 !verbose 3
671 !include "WinMessages.nsh"
672 !verbose 4
673
674 ; AddToPath - Adds the given dir to the search path.
675 ;        Input - head of the stack
676 ;        Note - Win9x systems requires reboot
677
678 Function AddToPath
679   Exch $0
680   Push $1
681   Push $2
682   Push $3
683   Push $4
684
685   ; don't add if the path doesn't exist
686   IfFileExists $0 "" AddToPath_done
687
688   Call IsNT
689   Pop $4
690   StrCmp $4 1 +3
691     ; Not on NT: read PATH from environment variable
692     ReadEnvStr $1 PATH
693     Goto +2
694     ; On NT: read PATH from registry
695     ReadRegStr $1 HKCU "Environment" "PATH"
696   Push "$1;"
697   Push "$0;"
698   Call StrStr
699   Pop $2
700   StrCmp $2 "" "" AddToPath_done
701   Push "$1;"
702   Push "$0\;"
703   Call StrStr
704   Pop $2
705   StrCmp $2 "" "" AddToPath_done
706   GetFullPathName /SHORT $3 $0
707   Push "$1;"
708   Push "$3;"
709   Call StrStr
710   Pop $2
711   StrCmp $2 "" "" AddToPath_done
712   Push "$1;"
713   Push "$3\;"
714   Call StrStr
715   Pop $2
716   StrCmp $2 "" "" AddToPath_done
717
718   StrCmp $4 1 AddToPath_NT
719     ; Not on NT
720     StrCpy $1 $WINDIR 2
721     FileOpen $1 "$1\autoexec.bat" a
722     FileSeek $1 -1 END
723     FileReadByte $1 $2
724     IntCmp $2 26 0 +2 +2 ; DOS EOF
725       FileSeek $1 -1 END ; write over EOF
726     FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
727     FileClose $1
728     SetRebootFlag true
729     Goto AddToPath_done
730
731   AddToPath_NT:
732     ReadRegStr $1 HKCU "Environment" "PATH"
733     StrCpy $2 $1 1 -1  ; copy last char
734     StrCmp $2 ";" 0 +2 ; if last char == ;
735       StrCpy $1 $1 -1  ; remove last char
736     StrCmp $1 "" AddToPath_NTdoIt
737       StrCpy $0 "$1;$0"
738     AddToPath_NTdoIt:
739       WriteRegExpandStr HKCU "Environment" "PATH" $0
740       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
741
742   AddToPath_done:
743     Pop $4
744     Pop $3
745     Pop $2
746     Pop $1
747     Pop $0
748 FunctionEnd
749
750 ; RemoveFromPath - Remove a given dir from the path
751 ;     Input: head of the stack
752
753 Function un.RemoveFromPath
754   Exch $0
755   Push $1
756   Push $2
757   Push $3
758   Push $4
759   Push $5
760   Push $6
761
762   IntFmt $6 "%c" 26 ; DOS EOF
763
764   Call un.IsNT
765   Pop $1
766   StrCmp $1 1 unRemoveFromPath_NT
767     ; Not on NT
768     StrCpy $1 $WINDIR 2
769     FileOpen $1 "$1\autoexec.bat" r
770     GetTempFileName $4
771     FileOpen $2 $4 w
772     GetFullPathName /SHORT $0 $0
773     StrCpy $0 "SET PATH=%PATH%;$0"
774     Goto unRemoveFromPath_dosLoop
775
776     unRemoveFromPath_dosLoop:
777       FileRead $1 $3
778       StrCpy $5 $3 1 -1 ; read last char
779       StrCmp $5 $6 0 +2 ; if DOS EOF
780         StrCpy $3 $3 -1 ; remove DOS EOF so we can compare
781       StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
782       StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
783       StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
784       StrCmp $3 "" unRemoveFromPath_dosLoopEnd
785       FileWrite $2 $3
786       Goto unRemoveFromPath_dosLoop
787       unRemoveFromPath_dosLoopRemoveLine:
788         SetRebootFlag true
789         Goto unRemoveFromPath_dosLoop
790
791     unRemoveFromPath_dosLoopEnd:
792       FileClose $2
793       FileClose $1
794       StrCpy $1 $WINDIR 2
795       Delete "$1\autoexec.bat"
796       CopyFiles /SILENT $4 "$1\autoexec.bat"
797       Delete $4
798       Goto unRemoveFromPath_done
799
800   unRemoveFromPath_NT:
801     ReadRegStr $1 HKCU "Environment" "PATH"
802     StrCpy $5 $1 1 -1 ; copy last char
803     StrCmp $5 ";" +2  ; if last char != ;
804       StrCpy $1 "$1;" ; append ;
805     Push $1
806     Push "$0;"
807     Call un.StrStr    ; Find `$0;` in $1
808     Pop $2            ; pos of our dir
809     StrCmp $2 "" unRemoveFromPath_done
810       ; else, it is in path
811       ; $0 - path to add
812       ; $1 - path var
813       StrLen $3 "$0;"
814       StrLen $4 $2
815       StrCpy $5 $1 -$4   ; $5 is now the part before the path to remove
816       StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove
817       StrCpy $3 $5$6
818
819       StrCpy $5 $3 1 -1  ; copy last char
820       StrCmp $5 ";" 0 +2 ; if last char == ;
821         StrCpy $3 $3 -1  ; remove last char
822
823       StrCmp $3 "" +3
824         ; New PATH not empty: update the registry
825         WriteRegExpandStr HKCU "Environment" "PATH" $3
826         Goto +2
827         ; New PATH empty: remove from the registry
828         DeleteRegValue HKCU "Environment" "PATH"
829       SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
830
831   unRemoveFromPath_done:
832     Pop $6
833     Pop $5
834     Pop $4
835     Pop $3
836     Pop $2
837     Pop $1
838     Pop $0
839 FunctionEnd
840
841 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
842 ;            Utility Functions            ;
843 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
844
845 ; IsNT
846 ; no input
847 ; output, top of the stack = 1 if NT or 0 if not
848 ;
849 ; Usage:
850 ;   Call IsNT
851 ;   Pop $R0
852 ;  ($R0 at this point is 1 or 0)
853
854 !macro IsNT un
855 Function ${un}IsNT
856   Push $0
857   ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
858   StrCmp $0 "" 0 IsNT_yes
859   ; we are not NT.
860   Pop $0
861   Push 0
862   Return
863
864   IsNT_yes:
865     ; NT!!!
866     Pop $0
867     Push 1
868 FunctionEnd
869 !macroend
870 !insertmacro IsNT ""
871 !insertmacro IsNT "un."
872
873 ; StrStr
874 ; input, top of stack = string to search for
875 ;        top of stack-1 = string to search in
876 ; output, top of stack (replaces with the portion of the string remaining)
877 ; modifies no other variables.
878 ;
879 ; Usage:
880 ;   Push "this is a long ass string"
881 ;   Push "ass"
882 ;   Call StrStr
883 ;   Pop $R0
884 ;  ($R0 at this point is "ass string")
885
886 !macro StrStr un
887 Function ${un}StrStr
888 Exch $R1   ; st=haystack,old$R1, $R1=needle
889   Exch     ; st=old$R1,haystack
890   Exch $R2 ; st=old$R1,old$R2, $R2=haystack
891   Push $R3
892   Push $R4
893   Push $R5
894   StrLen $R3 $R1
895   StrCpy $R4 0
896   ; $R1=needle
897   ; $R2=haystack
898   ; $R3=len(needle)
899   ; $R4=cnt
900   ; $R5=tmp
901   loop:
902     StrCpy $R5 $R2 $R3 $R4
903     StrCmp $R5 $R1 done
904     StrCmp $R5 "" done
905     IntOp $R4 $R4 + 1
906     Goto loop
907 done:
908   StrCpy $R1 $R2 "" $R4
909   Pop $R5
910   Pop $R4
911   Pop $R3
912   Pop $R2
913   Exch $R1
914 FunctionEnd
915 !macroend
916 !insertmacro StrStr ""
917 !insertmacro StrStr "un."