*** empty log message ***
[mono.git] / monowiz.win32.nsi
1 ; =================================================================
2 ; mono.nsi - This NSIS script creates Mono Setup wizard for Windows
3 ;
4 ;            Requires NSIS 2.0 (Nullsoft Scriptable Install System)
5 ;            From http://nsis.sourceforge.net/site/index.php
6 ; =================================================================
7 ;
8 ; (C) Copyright 2003 by Johannes Roith
9 ; (C) Copyright 2003, 2004 by Daniel Morgan
10 ;
11 ; Authors: 
12 ;       Johannes Roith <johannes@jroith.de>
13 ;       Daniel Morgan <danielmorgan@verizon.net>
14 ;       Urs C Muff <umuff@quark.com>
15 ;
16 ; This .nsi includes code from the NSIS Archives:
17 ; function StrReplace and VersionCheck 
18 ; by Hendri Adriaens
19 ; HendriAdriaens@hotmail.com
20
21 ; =====================================================
22 ;
23 ; This script can build a binary setup wizard of mono.
24 ; It is released under the GNU GPL.
25 ;
26 ; =====================================================
27 ; SET MILESTONE & SOURCE DIR
28 ; =====================================================
29 ; set by makefile!!
30
31 ;!define MILESTONE 0.91
32 ;!define SOURCE_INSTALL_DIR ..\install\*.* 
33 !define PROFILE_VERSION 1.0
34
35 ; =====================================================
36 ; SET LOGO
37 ; =====================================================
38 ;
39 ;  Beautification:
40 ;
41 ;  This adds a Mono-specific Image on the left
42 ;  You can choose between the light or dark one.
43 ;  
44 ;  If you wish no mono-specifi logo, please outcomment
45 ;  the lines.
46 ;  
47 ;  "light" is enabled.
48 ;
49 ;  !define MUI_SPECIALBITMAP "mono-win32-setup-dark.bmp"
50    !define MUI_SPECIALBITMAP "mono-win32-setup-light.bmp"
51
52 ; =====================================================
53 ; BUILDING
54 ; =====================================================
55 ;
56 ; 1. Build mono to a clean directory prefix.
57 ;
58 ; 2. In your install directory, delete the *.a files.
59 ;     Most people won't need them and it saves ~ 4 MB.
60 ;
61 ; 3. Type "make win32setup"
62 ;
63 ; 4. The output file is mono-[MILESTONE]-win32-1.exe
64 ;
65 ;
66 ; =====================================================
67 ; MONO & REGISTRY / DETECTING MONO
68 ; =====================================================
69 ;
70 ;
71 ; This setup creates several Registry Keys:
72 ;
73 ; HKEY_LOCAL_MACHINE SOFTWARE\Mono DefaultCLR
74 ; HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} SdkInstallRoot
75 ; HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} FrameworkAssemblyDirectory
76 ; HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} MonoConfigDir
77 ;
78 ; =====================================================
79 ;
80 ; To get the current Mono Install Directory:
81 ;
82 ; 1. Get DefaultCLR
83 ; 2. Get HKEY_LOCAL_MACHINE SOFTWARE\Mono\$THE_DEFAULT_CLR_VALUE SdkInstallRoot
84 ;
85 ; =====================================================
86 ;
87 ; To get the current Mono assembly Directory:
88 ;
89 ; 1. Get DefaultCLR
90 ; 2. Get HKEY_LOCAL_MACHINE SOFTWARE\Mono\$THE_DEFAULT_CLR_VALUE FrameworkAssemblyDirectory
91
92 ; =====================================================
93 ; Do not edit below
94 ; =====================================================
95 ;
96 ;
97 ; =====================================================
98 ; GENERAL SETTING - NEED NOT TO BE CHANGED
99 ; =====================================================
100
101 !define NAME "Mono" 
102 !define TARGET_INSTALL_DIR "$PROGRAMFILES\Mono-${MILESTONE}" 
103 !define OUTFILE mono-${MILESTONE}-win32-1.exe
104
105 Name ${NAME}\r
106 Caption "Mono ${MILESTONE} Setup"\r
107
108 !include "MUI.nsh"\r
109 !include "Sections.nsh"\r
110
111 SetCompressor bzip2\r
112 SilentInstall normal\r
113 ShowInstDetails show\r
114 SetDateSave on\r
115 SetDatablockOptimize on\r
116 CRCCheck on\r
117 BGGradient 000000 800000 FFFFFF\r
118 InstallColors FF8080 000030\r
119 XPStyle on\r
120 AutoCloseWindow false
121
122 ; =====================================================
123 ; SCRIPT
124 ; =====================================================
125
126 #!define MUI_WELCOMEPAGE
127 #!define MUI_DIRECTORYPAGE
128 #!define MUI_DIRECTORYSELECTIONPAGE
129  
130 !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Mono for Windows.\r\n\r\n\r\n$_CLICK"\r
131 \r
132 !insertmacro MUI_PAGE_WELCOME\r
133 !insertmacro MUI_PAGE_DIRECTORY\r
134 !insertmacro MUI_PAGE_INSTFILES\r
135 \r
136 !define MUI_FINISHPAGE_LINK "Visit Mono's website for the latest news"\r
137 !define MUI_FINISHPAGE_LINK_LOCATION "http://www.go-mono.com/"\r
138 \r
139 !define MUI_FINISHPAGE_NOREBOOTSUPPORT\r
140 \r
141 !insertmacro MUI_PAGE_FINISH\r
142 \r
143 !insertmacro MUI_UNPAGE_CONFIRM\r
144 !insertmacro MUI_UNPAGE_INSTFILES\r
145  
146 !insertmacro MUI_LANGUAGE "ENGLISH"
147
148 AutoCloseWindow false\r
149 ShowInstDetails show
150
151 OutFile ${OUTFILE}
152 InstallDir "${TARGET_INSTALL_DIR}"
153
154 ;========================
155 ; Uninstaller
156 ;========================
157
158 Section "Uninstall"
159
160   MessageBox MB_YESNO "Are you sure you want to uninstall Mono from your system?" IDNO NoUnInstall
161
162   Delete $INSTDIR\Uninst.exe ; delete Uninstaller
163   DeleteRegKey HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mono-${MILESTONE} ; Remove Entry in Software List
164
165   MessageBox MB_YESNO "Mono was installed into $INSTDIR. Should this directory be removed completly?" IDNO GoNext1
166   RMDir /r $INSTDIR
167   GoNext1:
168
169   DeleteRegKey HKLM SOFTWARE\Mono\${MILESTONE}
170
171   ; If the Default-Key is the current Milestone, we just remove the wrappers
172
173   ReadRegStr $0 HKEY_LOCAL_MACHINE SOFTWARE\Mono\ DefaultCLR
174   StrCmp $0 ${MILESTONE} DeleteWrappers
175
176   MessageBox MB_YESNO "Mono ${MILESTONE} has been removed, but the default installation of Mono differs form this version. Should the wrappers and the Mono registry key be still be removed? This could disable other Mono installations." IDNO GoNext2
177
178   DeleteWrappers:
179
180   ; Complete Uninstall
181
182   DeleteRegKey HKLM SOFTWARE\Mono
183   Delete $WINDIR\monobasepath.bat
184   Delete $WINDIR\mcs.bat
185   Delete $WINDIR\mbas.bat
186   Delete $WINDIR\mint.bat
187   Delete $WINDIR\mono.bat
188   Delete $WINDIR\monodis.bat
189   Delete $WINDIR\monoilasm.bat
190   Delete $WINDIR\sqlsharp.bat
191   Delete $WINDIR\secutil.bat
192   Delete $WINDIR\cert2spc.bat
193   Delete $WINDIR\monoresgen.bat
194   Delete $WINDIR\monosn.bat
195   Delete $WINDIR\cilc.bat
196   Delete $WINDIR\monop.bat
197   Delete $WINDIR\xsp.bat
198
199   GoNext2:
200   NoUnInstall:
201
202 SectionEnd
203
204
205  Section
206
207  ; Warn people if a newer Mono is already installed
208
209  ReadRegStr $0 HKEY_LOCAL_MACHINE SOFTWARE\Mono\ DefaultCLR
210  Push $0
211  Push ${MILESTONE} 
212  Call VersionCheck
213  Pop $0
214  StrCmp $0 0 NoAskInstall
215  StrCmp $0 2 NoAskInstall
216  MessageBox MB_YESNO "A newer Mono version is already installed. Still continue?" IDNO NoInstall
217
218  NoAskInstall:
219
220  DetailPrint "Installing Mono Files..."
221  SetOverwrite on
222  SetOutPath $INSTDIR
223  File /r ${SOURCE_INSTALL_DIR}
224
225  WriteUninstaller Uninst.exe
226
227  WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} SdkInstallRoot $INSTDIR
228  WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} FrameworkAssemblyDirectory $INSTDIR\lib
229  WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} MonoConfigDir $INSTDIR\etc\mono
230  ;WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono\${MILESTONE} GtkSharpLibPath $INSTDIR\lib
231  WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Mono DefaultCLR ${MILESTONE}
232
233  ; Mono Uninstall Entry in Windows Software List in the Control panel
234  WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mono-${MILESTONE} DisplayName "Mono ${MILESTONE}"
235  WriteRegStr HKEY_LOCAL_MACHINE SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mono-${MILESTONE} UninstallString $INSTDIR\uninst.exe
236
237  ;original string is like C:\mono-0.20\install
238  StrCpy $5 $INSTDIR 
239  Push $5
240  Push "\" ;search for this string
241  Push "/" ;replace with this string
242  Call StrReplace
243  ;resulting string which is like C:/mono-0.20/install
244  Pop $6
245
246 ;
247 ; These wrappers are copied to the windows directory.
248 ;
249
250 ;========================
251 ; Write the path file
252 ;========================
253
254 Push "mint"
255 Call windowsBatCore
256
257 Push "mono"
258 Call windowsBatCore
259
260 Push "mcs"
261 Call windowsBatProfile
262
263 Push "mbas"
264 Call windowsBat
265
266 Push "monodis"
267 Call windowsBat
268
269 Push "monoilasm"
270 Call windowsBat
271
272 Push "sqlsharp"
273 Call windowsBat
274
275 Push "secutil"
276 Call windowsBat
277
278 Push "cert2spec"
279 Call windowsBat
280
281 Push "monoresgen"
282 Call windowsBat
283
284 Push "monosn"
285 Call windowsBat
286
287 Push "cilc"
288 Call windowsBat
289
290 Push "monop"
291 Call windowsBat
292
293 Push "xsp"
294 Call windowsBat
295
296 ; ============= glib-2.0.pc ===============\r
297 FileOpen $0 "$INSTDIR\lib\pkgconfig\glib-2.0.pc" "w"\r
298 FileWrite $0 "prefix=$6$\r$\n"\r
299 FileWrite $0 "exec_prefix=$${prefix}$\r$\n"\r
300 FileWrite $0 "libdir=$${exec_prefix}/lib$\r$\n"\r
301 FileWrite $0 "includedir=$${prefix}/include$\r$\n"\r
302 FileWrite $0 "$\r$\n"\r
303 FileWrite $0 "glib_genmarshal=glib-genmarshal$\r$\n"\r
304 FileWrite $0 "gobject_query=gobject-query$\r$\n"\r
305 FileWrite $0 "glib_mkenums=glib-mkenums$\r$\n"\r
306 FileWrite $0 "$\r$\n"\r
307 FileWrite $0 "Name: GLib$\r$\n"\r
308 FileWrite $0 "Description: C Utility Library$\r$\n"\r
309 FileWrite $0 "Version: 2.0.4$\r$\n"\r
310 FileWrite $0 "Libs: -L$${libdir} -lglib-2.0 -lintl -liconv $\r$\n"\r
311 FileWrite $0 "Cflags: -I$${includedir}/glib-2.0 -I$${libdir}/glib-2.0/include $\r$\n"\r
312 FileClose $0
313 \r
314 ; ============= gmodule-2.0.pc ===============\r
315 FileOpen $0 "$INSTDIR\lib\pkgconfig\gmodule-2.0.pc" "w"\r
316 FileWrite $0 "prefix=$6$\r$\n"\r
317 FileWrite $0 "exec_prefix=$${prefix}$\r$\n"\r
318 FileWrite $0 "libdir=$${exec_prefix}/lib$\r$\n"\r
319 FileWrite $0 "includedir=$${prefix}/include$\r$\n"\r
320 FileWrite $0 "$\r$\n"\r
321 FileWrite $0 "gmodule_supported=true$\r$\n"\r
322 FileWrite $0 "$\r$\n"\r
323 FileWrite $0 "Name: GModule$\r$\n"\r
324 FileWrite $0 "Description: Dynamic module loader for GLib$\r$\n"\r
325 FileWrite $0 "Requires: glib-2.0$\r$\n"\r
326 FileWrite $0 "Version: 2.0.4$\r$\n"\r
327 FileWrite $0 "Libs: -L$${libdir} -lgmodule-2.0 $\r$\n"\r
328 FileWrite $0 "Cflags:$\r$\n"\r
329 FileClose $0\r
330 \r
331 ; ============= gobject-2.0.pc ===============\r
332 FileOpen $0 "$INSTDIR\lib\pkgconfig\gobject-2.0.pc" "w"\r
333 FileWrite $0 "prefix=$6$\r$\n"\r
334 FileWrite $0 "exec_prefix=$${prefix}$\r$\n"\r
335 FileWrite $0 "libdir=$${exec_prefix}/lib$\r$\n"\r
336 FileWrite $0 "includedir=$${prefix}/include$\r$\n"\r
337 FileWrite $0 "$\r$\n"\r
338 FileWrite $0 "Name: GObject$\r$\n"\r
339 FileWrite $0 "Description: GLib Type, Object, Parameter and Signal Library$\r$\n"\r
340 FileWrite $0 "Requires: glib-2.0$\r$\n"\r
341 FileWrite $0 "Version: 2.0.4$\r$\n"\r
342 FileWrite $0 "Libs: -L$${libdir} -lgobject-2.0$\r$\n"\r
343 FileWrite $0 "Cflags:$\r$\n"\r
344 FileClose $0\r
345 \r
346 ; ============= gthread-2.0.pc ===============\r
347 FileOpen $0 "$INSTDIR\lib\pkgconfig\gthread-2.0.pc" "w"\r
348 FileWrite $0 "prefix=$6$\r$\n"\r
349 FileWrite $0 "exec_prefix=$${prefix}$\r$\n"\r
350 FileWrite $0 "libdir=$${exec_prefix}/lib$\r$\n"\r
351 FileWrite $0 "includedir=$${prefix}/include$\r$\n"\r
352 FileWrite $0 "$\r$\n"\r
353 FileWrite $0 "Name: GThread$\r$\n"\r
354 FileWrite $0 "Description: Thread support for GLib$\r$\n"\r
355 FileWrite $0 "Requires: glib-2.0$\r$\n"\r
356 FileWrite $0 "Version: 2.0.4$\r$\n"\r
357 FileWrite $0 "Libs: -L$${libdir} -lgthread-2.0 $\r$\n"\r
358 FileWrite $0 "Cflags: -D_REENTRANT$\r$\n"\r
359 FileClose $0\r
360
361 ; ============= libintl.pc ===============\r
362 FileOpen $0 "$INSTDIR\lib\pkgconfig\libintl.pc" "w"\r
363 FileWrite $0 "prefix=$6$\r$\n"\r
364 FileWrite $0 "exec_prefix=$${prefix}$\r$\n"\r
365 FileWrite $0 "libdir=$${exec_prefix}/lib$\r$\n"\r
366 FileWrite $0 "includedir=$${prefix}/include$\r$\n"\r
367 FileWrite $0 "$\r$\n"\r
368 FileWrite $0 "Name: libintl$\r$\n"\r
369 FileWrite $0 "Description: The intl library from GNU gettext$\r$\n"\r
370 FileWrite $0 "Version: 0.10.40-tml$\r$\n"\r
371 FileWrite $0 "Libs: -L$${libdir} -lintl$\r$\n"\r
372 FileWrite $0 "Cflags: -I$${includedir}$\r$\n"\r
373 FileClose $0\r
374
375 NoInstall:
376 SectionEnd
377
378 Function windowsBatCore
379         Exch $1 ;core exe name
380
381         FileOpen $0 "$WINDIR\$1.bat" "w"
382         FileWrite $0 "@ECHO OFF$\r$\n"
383         FileWrite $0 "SET MONOARGS=$\r$\n"
384         FileWrite $0 ":loop$\r$\n"
385         FileWrite $0 "IF x%1 == x goto :done$\r$\n"
386         FileWrite $0 "SET MONOARGS=%MONOARGS% %1$\r$\n"
387         FileWrite $0 "SHIFT$\r$\n"
388         FileWrite $0 "GOTO loop$\r$\n"
389         FileWrite $0 ":done$\r$\n"
390         FileWrite $0 "SETLOCAL$\r$\n"
391         FileWrite $0 'SET PATH="$INSTDIR\bin;$INSTDIR\lib;%PATH%"$\r$\n'
392         FileWrite $0 '"$INSTDIR\bin\$1.exe" %MONOARGS%$\r$\n'
393         FileWrite $0 "EXIT /B %ERRORLEVEL%$\r$\n"
394         FileWrite $0 "ENDLOCAL$\r$\n"
395         FileClose $0
396
397         FileOpen $0 "$INSTDIR\bin\$1" "w"
398         FileWrite $0 "#!/bin/sh$\r$\n"
399         FileWrite $0 'exec $6/bin/$1.exe "$$@"$\r$\n'
400         FileClose $0
401
402         Pop $1
403 FunctionEnd
404
405 Function windowsBat
406         Exch $1 ;tool name
407
408         FileOpen $0 "$WINDIR\$1.bat" "w"
409         FileWrite $0 "@ECHO OFF$\r$\n"
410         FileWrite $0 "SET MONOARGS=$\r$\n"
411         FileWrite $0 ":loop$\r$\n"
412         FileWrite $0 "IF x%1 == x GOTO :done$\r$\n"
413         FileWrite $0 "SET MONOARGS=%MONOARGS% %1$\r$\n"
414         FileWrite $0 "SHIFT$\r$\n"
415         FileWrite $0 "GOTO loop$\r$\n"
416         FileWrite $0 ":done$\r$\n"
417         FileWrite $0 "SETLOCAL$\r$\n"
418         FileWrite $0 'SET PATH="$INSTDIR\bin;$INSTDIR\lib;%PATH%"$\r$\n'
419         FileWrite $0 '"$INSTDIR\bin\mono.exe" "$INSTDIR\lib\$1.exe" %MONOARGS%$\r$\n'
420         FileWrite $0 "EXIT /B %ERRORLEVEL%$\r$\n"
421         FileWrite $0 "ENDLOCAL$\r$\n"
422         FileClose $0
423
424         FileOpen $0 "$INSTDIR\bin\$1" "w"
425         FileWrite $0 "#!/bin/sh$\r$\n"
426         FileWrite $0 'exec $6/bin/mono.exe $6/lib/$1.exe "$$@"$\r$\n'
427         FileClose $0
428
429         Pop $1
430 FunctionEnd
431
432 Function windowsBatProfile
433         Exch $1 ;tool name
434
435         FileOpen $0 "$WINDIR\$1.bat" "w"
436         FileWrite $0 "@ECHO OFF$\r$\n"
437         FileWrite $0 "SET MONOARGS=$\r$\n"
438         FileWrite $0 ":loop$\r$\n"
439         FileWrite $0 "IF x%1 == x GOTO :done$\r$\n"
440         FileWrite $0 "SET MONOARGS=%MONOARGS% %1$\r$\n"
441         FileWrite $0 "SHIFT$\r$\n"
442         FileWrite $0 "GOTO loop$\r$\n"
443         FileWrite $0 ":done$\r$\n"
444         FileWrite $0 "SETLOCAL$\r$\n"
445         FileWrite $0 'SET PATH="$INSTDIR\bin;$INSTDIR\lib;%PATH%"$\r$\n'
446         FileWrite $0 '"$INSTDIR\bin\mono.exe" "$INSTDIR\lib\mono\${PROFILE_VERSION}\$1.exe" %MONOARGS%$\r$\n'
447         FileWrite $0 "EXIT /B %ERRORLEVEL%$\r$\n"
448         FileWrite $0 "ENDLOCAL$\r$\n"
449         FileClose $0
450
451         FileOpen $0 "$INSTDIR\bin\$1" "w"
452         FileWrite $0 "#!/bin/sh$\r$\n"
453         FileWrite $0 'exec $6/bin/mono.exe $6/lib/mono/${PROFILE_VERSION}/$1.exe "$$@"$\r$\n'
454         FileClose $0
455
456         Pop $1
457 FunctionEnd
458
459 ; function StrReplace
460 ; by Hendri Adriaens
461 ; HendriAdriaens@hotmail.com
462 ; found in the NSIS Archives
463 function StrReplace
464   Exch $0 ;this will replace wrong characters
465   Exch
466   Exch $1 ;needs to be replaced
467   Exch
468   Exch 2
469   Exch $2 ;the orginal string
470   Push $3 ;counter
471   Push $4 ;temp character
472   Push $5 ;temp string
473   Push $6 ;length of string that need to be replaced
474   Push $7 ;length of string that will replace
475   Push $R0 ;tempstring
476   Push $R1 ;tempstring
477   Push $R2 ;tempstring
478   StrCpy $3 "-1"
479   StrCpy $5 ""
480   StrLen $6 $1
481   StrLen $7 $0
482   Loop:
483   IntOp $3 $3 + 1
484   StrCpy $4 $2 $6 $3
485   StrCmp $4 "" ExitLoop
486   StrCmp $4 $1 Replace
487   Goto Loop
488   Replace:
489   StrCpy $R0 $2 $3
490   IntOp $R2 $3 + $6
491   StrCpy $R1 $2 "" $R2
492   StrCpy $2 $R0$0$R1
493   IntOp $3 $3 + $7
494   Goto Loop
495   ExitLoop:
496   StrCpy $0 $2
497   Pop $R2
498   Pop $R1
499   Pop $R0
500   Pop $7
501   Pop $6
502   Pop $5
503   Pop $4
504   Pop $3
505   Pop $2
506   Pop $1
507   Exch $0
508 FunctionEnd
509
510 Function VersionCheck
511   Exch $0 ;second versionnumber
512   Exch
513   Exch $1 ;first versionnumber
514   Push $R0 ;counter for $0
515   Push $R1 ;counter for $1
516   Push $3 ;temp char
517   Push $4 ;temp string for $0
518   Push $5 ;temp string for $1
519   StrCpy $R0 "-1"
520   StrCpy $R1 "-1"
521   Start:
522   StrCpy $4 ""
523   DotLoop0:
524   IntOp $R0 $R0 + 1
525   StrCpy $3 $0 1 $R0
526   StrCmp $3 "" DotFound0
527   StrCmp $3 "." DotFound0
528   StrCpy $4 $4$3
529   Goto DotLoop0
530   DotFound0:
531   StrCpy $5 ""
532   DotLoop1:
533   IntOp $R1 $R1 + 1
534   StrCpy $3 $1 1 $R1
535   StrCmp $3 "" DotFound1
536   StrCmp $3 "." DotFound1
537   StrCpy $5 $5$3
538   Goto DotLoop1
539   DotFound1:
540   Strcmp $4 "" 0 Not4
541     StrCmp $5 "" Equal
542     Goto Ver2Less
543   Not4:
544   StrCmp $5 "" Ver2More
545   IntCmp $4 $5 Start Ver2Less Ver2More
546   Equal:
547   StrCpy $0 "0"
548   Goto Finish
549   Ver2Less:
550   StrCpy $0 "1"
551   Goto Finish
552   Ver2More:
553   StrCpy $0 "2"
554   Finish:
555   Pop $5
556   Pop $4
557   Pop $3
558   Pop $R1
559   Pop $R0
560   Pop $1
561   Exch $0
562 FunctionEnd