More updates
[synfig.git] / synfig-core / trunk / win32inst.nsi.in
1 ; example2.nsi
2 ;
3 ; This script is based on example1.nsi, but it remember the directory, 
4 ; has uninstall support and (optionally) installs start menu shortcuts.
5 ;
6 ; It will install makensisw.exe into a directory that the user selects,
7
8 !include "MUI.nsh"
9
10 ;--------------------------------
11
12 ; The name of the installer
13 Name "@PACKAGE_NAME@ @PACKAGE_VERSION@"
14
15 !define PRODUCT_WEB_SITE "http://deepdarc.dnsalias.net/~darco/"
16
17 ; The file to write
18 OutFile "@PACKAGE_TARNAME@-@PACKAGE_VERSION@.exe"
19
20 ; The default installation directory
21 InstallDir $PROGRAMFILES\@PACKAGE_TARNAME@
22
23 ; Registry key to check for directory (so if you install again, it will 
24 ; overwrite the old one automatically)
25 InstallDirRegKey HKLM "Software\Voria_@PACKAGE_TARNAME@" "Install_Dir"
26
27 !define VERSION_MAJ "@VERSION_MAJ@"
28 !define VERSION_MIN "@VERSION_MIN@"
29 !define VERSION_REV "@VERSION_REV@"
30
31 !define SYNFIG_REG_KEY "Software\@PACKAGE_TARNAME@\@API_VERSION@"
32 !define SYNFIG_UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PACKAGE_TARNAME@"
33 !define SYNFIG_UNINSTALL_EXE "uninstall-@PACKAGE_TARNAME@.exe"
34
35 !define MUI_ABORTWARNING
36
37 ;--------------------------------
38
39 ; Pages
40
41 #Page components
42 #Page directory
43 #Page instfiles
44
45 #UninstPage uninstConfirm
46 #UninstPage instfiles
47
48 ;CustomGuiInit
49
50 !insertmacro MUI_PAGE_WELCOME
51 !insertmacro MUI_PAGE_LICENSE "@srcdir@\alphalicense.txt"
52 ;Page custom PageReinstall ; PageLeaveReinstall
53 !insertmacro MUI_PAGE_COMPONENTS
54 !insertmacro MUI_PAGE_DIRECTORY
55 !insertmacro MUI_PAGE_INSTFILES
56
57 !insertmacro MUI_UNPAGE_CONFIRM
58 !insertmacro MUI_UNPAGE_COMPONENTS
59 !insertmacro MUI_UNPAGE_INSTFILES
60
61 !insertmacro MUI_LANGUAGE "English"
62
63 ;--------------------------------
64
65 ; The stuff to install
66 Section ""
67
68   SectionIn RO
69   
70   ; Set output path to the installation directory.
71   SetOutPath $INSTDIR\bin
72
73   File "C:\mingw\bin\mingwm10.dll"
74   File "C:\GTK\bin\libfreetype-6.dll"
75   
76   ; Put file there
77 ;  File "sinfg_modules.conf"
78   
79   CreateDirectory "$INSTDIR\etc"
80   Delete $INSTDIR\etc\sinfg_modules.conf
81         
82   ; Write the installation path into the registry
83   ; WriteRegStr HKLM "Software\Voria_@PACKAGE_TARNAME@" "Install_Dir" "$INSTDIR"
84   
85   WriteRegStr HKLM "${SYNFIG_REG_KEY}" "Path" "$INSTDIR"
86   WriteRegStr HKLM "${SYNFIG_REG_KEY}" "Version" "@PRODUCT_VERSION@"
87   
88   ; Write the uninstall keys for Windows
89   WriteRegStr HKLM "${SYNFIG_UNINSTALL_KEY}" "DisplayName" "@PACKAGE_NAME@"
90   WriteRegStr HKLM "${SYNFIG_UNINSTALL_KEY}" "DisplayVersion" "@PACKAGE_VERSION@"
91   WriteRegStr HKLM "${SYNFIG_UNINSTALL_KEY}" "UninstallString" '"$INSTDIR\${SYNFIG_UNINSTALL_EXE}"'
92   WriteRegDWORD HKLM "${SYNFIG_UNINSTALL_KEY}" "NoModify" 1
93   WriteRegDWORD HKLM "${SYNFIG_UNINSTALL_KEY}" "NoRepair" 1
94   WriteUninstaller "${SYNFIG_UNINSTALL_EXE}"
95   
96 SectionEnd
97
98
99 ; Optional section (can be disabled by the user)
100 ;Section "Start Menu Shortcuts"
101
102 ;  CreateDirectory "$SMPROGRAMS\Example2"
103 ;  CreateShortCut "$SMPROGRAMS\Example2\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
104 ;  CreateShortCut "$SMPROGRAMS\Example2\Example2 (MakeNSISW).lnk" "$INSTDIR\makensisw.exe" "" "$INSTDIR\makensisw.exe" 0
105   
106 ;SectionEnd
107
108 ;--------------------------------
109
110 ; Uninstaller
111
112 Section "Uninstall"
113   
114   ; Remove registry keys
115   DeleteRegKey HKLM "${SYNFIG_REG_KEY}"
116   DeleteRegKey HKLM "${SYNFIG_UNINSTALL_KEY}"
117   ; DeleteRegKey HKLM "Software\Voria_@PACKAGE_TARNAME@"
118
119   ; Remove files and uninstaller
120   ;Delete $INSTDIR\sinfg.exe
121   Delete $INSTDIR\uninstall-@PACKAGE_TARNAME@.exe
122   Delete $INSTDIR\etc\sinfg_modules.conf
123   RMDir $INSTDIR\bin
124   RMDir $INSTDIR\etc
125
126   ; Remove shortcuts, if any
127
128   ; Remove directories used
129   ;RMDir "$SMPROGRAMS\Example2"
130   RMDir "$INSTDIR"
131
132 SectionEnd
133
134 !include @srcdir@\src\sinfg\sinfg.nsh
135 !include @srcdir@\src\tool\tool.nsh
136
137 Section "Examples"
138         SetOutPath $INSTDIR\examples
139         File "@srcdir@\examples\*.sif"
140         CreateDirectory "$SMPROGRAMS\Voria"
141         CreateShortCut "$SMPROGRAMS\Voria\Examples.lnk" "$INSTDIR\examples" "" "$INSTDIR\examples" 0
142 SectionEnd
143
144 Section "un.Examples"
145         Delete "$SMPROGRAMS\Voria\Examples.lnk"
146         Delete "$INSTDIR\examples\*.sif"
147         RMDir "$INSTDIR\examples"
148 SectionEnd
149
150 SubSection "PlugIns"
151 SubSection "Layers"
152 !include "@srcdir@\src\modules\lyr_std\lyr_std.nsh"
153 !include "@srcdir@\src\modules\mod_filter\mod_filter.nsh"
154 !include "@srcdir@\src\modules\mod_gradient\mod_gradient.nsh"
155 !include "@srcdir@\src\modules\mod_noise\mod_noise.nsh"
156 !include "@srcdir@\src\modules\mod_particle\mod_particle.nsh"
157 !include "@srcdir@\src\modules\mod_geometry\mod_geometry.nsh"
158 !include "@srcdir@\src\modules\lyr_freetype\lyr_freetype.nsh"
159 SubSectionEnd
160 SubSection "Render Targets"
161 !include "@srcdir@\src\modules\mod_bmp\mod_bmp.nsh"
162 ;!include "@srcdir@\src\modules\mod_dv\mod_dv.nsh"
163 ;!include "@srcdir@\src\modules\mod_ffmpeg\mod_ffmpeg.nsh"
164 ;!include "@srcdir@\src\modules\mod_gif\mod_gif.nsh"
165 ;!include "@srcdir@\src\modules\mod_imagemagick\mod_imagemagick.nsh"
166 !include "@srcdir@\src\modules\mod_jpeg\mod_jpeg.nsh"
167 !include "@srcdir@\src\modules\mod_png\mod_png.nsh"
168 !include "@srcdir@\src\modules\mod_ppm\mod_ppm.nsh"
169 !include "@srcdir@\src\modules\mod_yuv420p\mod_yuv420p.nsh"
170 SubSectionEnd
171 SubSectionEnd
172
173
174 SubSection "un.PlugIns"
175 SubSection "un.Layers"
176 !include "@srcdir@\src\modules\lyr_std\unlyr_std.nsh"
177 !include "@srcdir@\src\modules\lyr_freetype\unlyr_freetype.nsh"
178 !include "@srcdir@\src\modules\mod_filter\unmod_filter.nsh"
179 !include "@srcdir@\src\modules\mod_gradient\unmod_gradient.nsh"
180 !include "@srcdir@\src\modules\mod_noise\unmod_noise.nsh"
181 !include "@srcdir@\src\modules\mod_particle\unmod_particle.nsh"
182 !include "@srcdir@\src\modules\mod_geometry\unmod_geometry.nsh"
183 SubSectionEnd
184 SubSection "un.Render Targets"
185 !include "@srcdir@\src\modules\mod_bmp\unmod_bmp.nsh"
186 ;!include "@srcdir@\src\modules\mod_dv\unmod_dv.nsh"
187 ;!include "@srcdir@\src\modules\mod_ffmpeg\unmod_ffmpeg.nsh"
188 ;!include "@srcdir@\src\modules\mod_gif\unmod_gif.nsh"
189 ;!include "@srcdir@\src\modules\mod_imagemagick\unmod_imagemagick.nsh"
190 !include "@srcdir@\src\modules\mod_jpeg\unmod_jpeg.nsh"
191 !include "@srcdir@\src\modules\mod_png\unmod_png.nsh"
192 !include "@srcdir@\src\modules\mod_ppm\unmod_ppm.nsh"
193 !include "@srcdir@\src\modules\mod_yuv420p\unmod_yuv420p.nsh"
194 SubSectionEnd
195 SubSectionEnd
196
197 Function .onInit
198         ; Get installer location
199         ReadRegStr $R0 HKLM "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
200 ;       IfErrors 0 +2
201 ;       ReadRegStr $R0 HKCU "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
202         
203         StrCmp $R0 "" done
204
205         ; Get current installed version
206         ReadRegStr $R1 HKLM "${SYNFIG_UNINSTALL_KEY}" "DisplayVersion"
207 ;       IfErrors 0 +2
208 ;       ReadRegStr $R1 HKCU "${SYNFIG_UNINSTALL_KEY}" "DisplayVersion"
209
210 ;  StrCmp $R1 ${PRODUCT_VERSION} done
211
212         MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION "A previous version of @PACKAGE_NAME@ appears to be installed. Would you like to uninstall it first?" IDNO done IDCANCEL abortInstall
213
214         ; Run the uninstaller
215         
216         ClearErrors
217         ; CopyFiles "$R0" $TEMP
218         ExecWait '$R0 _?=$INSTDIR'
219         IfErrors no_remove_uninstaller
220         Delete $R0
221         RMDir $INSTDIR
222
223 no_remove_uninstaller:
224 ;    Delete "$TEMP\$R0"
225         
226     ; Check that the user completed the uninstallation by examining the registry
227     ReadRegStr $R0 HKLM "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
228         StrCmp $R0 "" done abortInstall
229         ReadRegStr $R0 HKCU "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
230         StrCmp $R0 "" done abortInstall
231
232 abortInstall:
233     MessageBox MB_OK|MB_ICONEXCLAMATION "Unable to uninstall previous version of @PACKAGE_NAME@"
234     Abort
235
236 done:
237     BringToFront
238
239 FunctionEnd