summaryrefslogtreecommitdiffstats
path: root/contrib/mingw/rtems-tools.nsi
blob: bb3185930d608d6043d5563447d8582a229c4e1e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
; RTEMS Tools Installer.
;
; Copyright Chris Johns (chrisj@rtems.org)
;

;!define EMPTY_INSTALLER

!define PRODUCT_NAME      "RTEMS Tools"
!define PRODUCT_VERSION   ${RTEMS_VERSION}
!define PRODUCT_PUBLISHER "RTEMS Project Team"
!define PRODUCT_WEB_SITE  "http://www.rtems.org/"
!ifdef COMMON_FILES
!define PRODUCT_TITLE     "${PRODUCT_NAME} ${PRODUCT_VERSION} (Build ${RTEMS_BUILD_VERSION})"
!else
!define PRODUCT_TITLE     "${PRODUCT_NAME} ${PRODUCT_VERSION} (${RTEMS_TARGET})"
!endif
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_TITLE}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"

; MUI 1.66 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_FUNCTION_GUIINIT
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\win-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\win-uninstall.ico"

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${RTEMS_LOGO}"

!define MUI_COMPONENTSPAGE_SMALLDESC

!ifdef COMMON_FILES
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; Details of what will happen.
Page custom RTEMSMessage
; License page
!insertmacro MUI_PAGE_LICENSE "${RTEMS_LICENSE_FILE}"
; Components page
!insertmacro MUI_PAGE_COMPONENTS

; Directory page
!define MUI_PAGE_HEADER_SUBTEXT "Choose the folder in which to install the RTEMS Tools."
!define MUI_DIRECTORYPAGE_TEXT_TOP "${PRODUCT_NAME} will install RTEMS Tools in the following directory. To install in a different folder click Browse and select another folder. Click Next to continue."
!insertmacro MUI_PAGE_DIRECTORY
!endif

; Start menu page
!ifndef COMMON_FILES
!include "${RTEMS_SOURCE}/sm-dummy.nsi"
!endif
var smfolder
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "RTEMS ${PRODUCT_VERSION}"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!ifdef COMMON_FILES
!insertmacro MUI_PAGE_STARTMENU Application $smfolder
!else
!insertmacro MUI_PAGE_STARTMENU_DUMMY Application $smfolder
!endif

; Instfiles page
!insertmacro MUI_PAGE_INSTFILES

!ifdef COMMON_FILES
; Finish page
!insertmacro MUI_PAGE_FINISH
!endif

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

; MUI end ------

ReserveFile "rtems.ini"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

!ifdef COMMON_FILES
Name "${PRODUCT_NAME} ${PRODUCT_VERSION} (Build ${RTEMS_BUILD_VERSION})"
OutFile "${RTEMS_BINARY}/rtems${PRODUCT_VERSION}-tools-${RTEMS_BUILD_VERSION}.exe"
BrandingText "RTEMS Tools v${PRODUCT_VERSION}"
AutoCloseWindow false
!else
Name "${PRODUCT_NAME} ${PRODUCT_VERSION} (${RTEMS_TARGET})"
OutFile "${RTEMS_BINARY}/${RTEMS_OUTFILE}"
BrandingText "RTEMS ${RTEMS_TARGET} Tools v${PRODUCT_VERSION}"
AutoCloseWindow true
!endif
InstallDir "C:\opt\rtems-${PRODUCT_VERSION}"
ShowInstDetails show
ShowUnInstDetails show
AllowRootDirInstall false
CRCCheck force

!include "${RTEMS_SOURCE}/instance-check.nsi"
!include "${RTEMS_SOURCE}/msys-path.nsi"
!include "${RTEMS_SOURCE}/options.nsi"
!include "${RTEMS_SOURCE}/filewrite.nsi"

Section -SecFiles
 AddSize ${RTEMS_TOOLS_SIZE}
 !insertmacro RTEMS_INSTALL_FILES
SectionEnd

!ifdef COMMON_FILES
Section -SecCommon
 SetOutPath "$INSTDIR"
 File "${RTEMS_SOURCE}/AUTHORS"
 File "${RTEMS_SOURCE}/COPYING"
 File "${RTEMS_SOURCE}/README"
SectionEnd
!endif

Function .onInit
  ;Check if we are the correct instance for our mode.
  Call CheckInstance
  ;Extract InstallOptions INI files
  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "rtems.ini"
  ;Handle the Command line options
  Call CheckSilent
  Call CheckDebug
  Call MSYSFstabUpdate
FunctionEnd

Function RTEMSMessage
  !insertmacro MUI_HEADER_TEXT \
               "RTEMS Tools (Build ${RTEMS_BUILD_VERSION})" \
               "A tool set for the RTEMS operating system."

  ;Display the Install Options dialog

  Push $R0
  Push $R1
  Push $R2

  InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\rtems.ini"
  Pop $R0

  GetDlgItem $R1 $R0 1200 ;1200 + Field number - 1
  ;$R1 contains the HWND of the first field
  CreateFont $R2 "Tahoma" "8" "300"
  SendMessage $R1 ${WM_SETFONT} $R2 0
      
  GetDlgItem $R1 $R0 1201 ;1200 + Field number - 1
  ;$R1 contains the HWND of the first field
  CreateFont $R2 "Tahoma" "12" "700"
  SendMessage $R1 ${WM_SETFONT} $R2 0
      
  GetDlgItem $R1 $R0 1202 ;1200 + Field number - 1
  ;$R1 contains the HWND of the first field
  CreateFont $R2 "Tahoma" "8" "300"
  SendMessage $R1 ${WM_SETFONT} $R2 0
      
  GetDlgItem $R1 $R0 1203 ;1200 + Field number - 1
  ;$R1 contains the HWND of the first field
  CreateFont $R2 "Tahoma" "8" "300"
  SendMessage $R1 ${WM_SETFONT} $R2 0
      
  GetDlgItem $R1 $R0 1204 ;1200 + Field number - 1
  ;$R1 contains the HWND of the first field
  CreateFont $R2 "Tahoma" "8" "300"
  SendMessage $R1 ${WM_SETFONT} $R2 0
      
  GetDlgItem $R1 $R0 1205 ;1200 + Field number - 1
  ;$R1 contains the HWND of the first field
  CreateFont $R2 "Tahoma" "8" "300"
  SendMessage $R1 ${WM_SETFONT} $R2 0
      
  GetDlgItem $R1 $R0 1206 ;1200 + Field number - 1
  ;$R1 contains the HWND of the first field
  CreateFont $R2 "Tahoma" "8" "300"
  SendMessage $R1 ${WM_SETFONT} $R2 0
      
  InstallOptions::show
  Pop $R0
  Pop $R2
  Pop $R1
  Pop $R0
FunctionEnd

!ifdef COMMON_FILES
Section -BatchFiles
 FileOpen $9 $INSTDIR\rtems-env.bat w
 !insertmacro FILE_WRITE_LINE $9 "@echo off"
 !insertmacro FILE_WRITE_LINE $9 "rem RTEMS batch file: ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}"
 !insertmacro FILE_WRITE_LINE $9 "set PATH=$INSTDIR\bin;c:\mingw\bin;c:\msys\1.0\bin;%PATH%"
 !insertmacro FILE_WRITE_LINE $9 "set PROMPT=RTEMS $$P$$G"
 !insertmacro FILE_WRITE_LINE $9 "If $\"x%OS%x$\" == $\"xWindows_NTx$\" Goto WinNT_Title"
 !insertmacro FILE_WRITE_LINE $9 "doskey > Nul"
 !insertmacro FILE_WRITE_LINE $9 "goto Finished"
 !insertmacro FILE_WRITE_LINE $9 ":WinNT_Title"
 !insertmacro FILE_WRITE_LINE $9 "Title RTEMS ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}"
 !insertmacro FILE_WRITE_LINE $9 ":Finished"
 FileClose $9

 FileOpen $9 $INSTDIR\rtems.bat w
 !insertmacro FILE_WRITE_LINE $9 "@echo off"
 !insertmacro FILE_WRITE_LINE $9 "rem RTEMS batch file: ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}"
 !insertmacro FILE_WRITE_LINE $9 "If $\"x%OS%x$\" == $\"xWindows_NTx$\" Goto WinNT"
 !insertmacro FILE_WRITE_LINE $9 "start command.com /e:4096 /k $INSTDIR\rtems-env.bat %1 %2 %3 %4"
 !insertmacro FILE_WRITE_LINE $9 "exit"
 !insertmacro FILE_WRITE_LINE $9 ":WinNT"
 !insertmacro FILE_WRITE_LINE $9 "start cmd.exe /k $INSTDIR\rtems-env.bat %1 %2 %3 %4"
 !insertmacro FILE_WRITE_LINE $9 "exit"
 FileClose $9

 FileOpen $9 $INSTDIR\sh-run.bat w
 !insertmacro FILE_WRITE_LINE $9 "@echo off"
 !insertmacro FILE_WRITE_LINE $9 "rem RTEMS batch file: ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}"
 !insertmacro FILE_WRITE_LINE $9 "rem We can only handle 9 parameters. More is too hard."
 !insertmacro FILE_WRITE_LINE $9 "call $INSTDIR\rtems-env.bat"
 !insertmacro FILE_WRITE_LINE $9 "%1 %2 %3 %4 %5 %6 %7 %8 %9"
 FileClose $9

 FileOpen $9 $INSTDIR\vs-make.sh w
 !insertmacro FILE_WRITE_LINE $9 "#! /bin/sh"
 !insertmacro FILE_WRITE_LINE $9 "# RTEMS script: ${RTEMS_VERSION}-${RTEMS_BUILD_VERSION}"
 !insertmacro FILE_WRITE_LINE $9 "if [ ! -d $$1 ]; then"
 !insertmacro FILE_WRITE_LINE $9 " echo $\"error: no build directory found$\""
 !insertmacro FILE_WRITE_LINE $9 " exit 1"
 !insertmacro FILE_WRITE_LINE $9 "fi"
 !insertmacro FILE_WRITE_LINE $9 "cd $$1"
 !insertmacro FILE_WRITE_LINE $9 "shift"
 !insertmacro FILE_WRITE_LINE $9 "make $$* 2>&1 | sed -e 's/c:\([0-9]*\):/c(\1):/' \\"
 !insertmacro FILE_WRITE_LINE $9 "                   -e 's/h:\([0-9]*\):/h(\1):/' \\"
 !insertmacro FILE_WRITE_LINE $9 "                   -e 's/S:\([0-9]*\):/S(\1):/' \\"
 !insertmacro FILE_WRITE_LINE $9 "                   -e 's/s:\([0-9]*\):/s(\1):/'"
 FileClose $9
SectionEnd
!endif

Section -Post
!ifdef COMMON_FILES
 StrCpy $R0 "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-uninst.exe"
 StrCpy $R1 "RTEMS Tools.lnk"
!else
 StrCpy $R0 "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-${RTEMS_TARGET}-uninst.exe"
 StrCpy $R1 "RTEMS ${RTEMS_TARGET} Tools.lnk"
 !insertmacro MUI_STARTMENU_GETFOLDER "Application" $smfolder
!endif
 WriteUninstaller "$R0"
 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_TITLE}" \
                  "DisplayName" "$(^Name)"
 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_TITLE}" \
                  "UninstallString" "$R0"
 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_TITLE}" \
                  "DisplayVersion" "${PRODUCT_VERSION} Build-${RTEMS_BUILD_VERSION}"
 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_TITLE}" \
                  "URLInfoAbout" "${PRODUCT_WEB_SITE}"
 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_TITLE}" \
                  "Publisher" "${PRODUCT_PUBLISHER}"
 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
 CreateDirectory "$SMPROGRAMS\$smfolder"
!ifdef COMMON_FILES
 SetOutPath $INSTDIR
 WriteIniStr "$INSTDIR\RTEMS.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
 WriteIniStr "$INSTDIR\RTEMS-Wiki.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}wiki"
 WriteIniStr "$INSTDIR\RTEMS-Documentation.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}onlinedocs/releases/rtemsdocs-4.7.99.2/share/rtems/html/"
 WriteIniStr "$INSTDIR\RTEMS-Support.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}support.html"
 CreateShortCut "$SMPROGRAMS\$smfolder\RTEMS Tools.lnk" "$INSTDIR\rtems.bat"
 CreateShortCut "$SMPROGRAMS\$smfolder\RTEMS Website.lnk" "$INSTDIR\RTEMS.url"
 CreateShortCut "$SMPROGRAMS\$smfolder\RTEMS Wiki.lnk" "$INSTDIR\RTEMS-Wiki.url"
 CreateShortCut "$SMPROGRAMS\$smfolder\RTEMS Documentation.lnk" "$INSTDIR\RTEMS-Documentation.url"
 CreateShortCut "$SMPROGRAMS\$smfolder\RTEMS Support.lnk" "$INSTDIR\RTEMS-Support.url"
!endif
 CreateDirectory "$SMPROGRAMS\$smfolder\Uninstall"
 CreateShortCut "$SMPROGRAMS\$smfolder\Uninstall\$R1" "$R0"
 !insertmacro MUI_STARTMENU_WRITE_END
SectionEnd

Function un.onInit
 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 \
            "Are you sure you want to uninstall ${PRODUCT_TITLE} ?" IDYES +2
 Abort
FunctionEnd

Section Uninstall
 SetDetailsView show
 StrCpy $2 0
!ifdef COMMON_FILES
 FindFirst $0 $1 "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-*-uninst.exe"
 Uninstall_Targets:
  StrCmp $1 "" Uninstall_Targets_Done
  IntCmp $2 0 0 +3
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 \
             "You have tools installed. Are you sure you want to uninstall all RTEMS Tools ?" IDYES +2
    Abort
  StrCpy $2 1
  DetailPrint "Uninstalling $1"
  ExecWait '"$INSTDIR\$1" $SilentOption $DebugOption'
  Delete $1
  BringToFront
  FindNext $0 $1
  Goto Uninstall_Targets
 Uninstall_Targets_Done:
 FindClose $0
!endif
 DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
 DetailPrint "Delete the installed files"
 !insertmacro RTEMS_DELETE_FILES
 !insertmacro MUI_STARTMENU_GETFOLDER "Application" $smfolder
!ifdef COMMON_FILES
 Delete "$INSTDIR\AUTHORS"
 Delete "$INSTDIR\COPYING"
 Delete "$INSTDIR\README"
 Delete "$INSTDIR\rtems.bat"
 Delete "$INSTDIR\rtems-env.bat"
 Delete "$INSTDIR\sh-run.bat"
 Delete "$INSTDIR\vs-make.sh"
 Delete "$INSTDIR\RTEMS.url"
 Delete "$INSTDIR\RTEMS-Wiki.url"
 Delete "$INSTDIR\RTEMS-Documentation.url"
 Delete "$INSTDIR\RTEMS-Support.url"
 RMDir /r "$SMPROGRAMS\$smfolder"
 Delete "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-uninst.exe"
!else
 Delete "$SMPROGRAMS\$smfolder\Uninstall\RTEMS ${RTEMS_TARGET} Tools.lnk"
 Delete "$INSTDIR\rtems${PRODUCT_VERSION}-${RTEMS_BUILD_VERSION}-tools-${RTEMS_TARGET}-uninst.exe"
!endif
 RMDir "$INSTDIR"
 DetailPrint "All done."
!ifdef COMMON_FILES
 SetAutoClose false
!else
 SetAutoClose true
!endif
SectionEnd