Atrus' Windows patches: [ 1695479 ] win32-synfig-remove-unused-libs
[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://www.synfig.com/"
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@\COPYING"
52 #!insertmacro MUI_PAGE_LICENSE "@srcdir@\alphalicense.txt"
53 ;Page custom PageReinstall ; PageLeaveReinstall
54 !insertmacro MUI_PAGE_COMPONENTS
55 !insertmacro MUI_PAGE_DIRECTORY
56 !insertmacro MUI_PAGE_INSTFILES
57
58 !insertmacro MUI_UNPAGE_CONFIRM
59 !insertmacro MUI_UNPAGE_COMPONENTS
60 !insertmacro MUI_UNPAGE_INSTFILES
61
62 !insertmacro MUI_LANGUAGE "English"
63
64 ;--------------------------------
65
66 ; The stuff to install
67 Section ""
68
69   SectionIn RO
70   
71   ; Set output path to the installation directory.
72   SetOutPath $INSTDIR\bin
73
74   ; Put file there
75   
76   CreateDirectory "$INSTDIR\etc"
77   Delete $INSTDIR\etc\synfig_modules.cfg
78         
79   ; Write the installation path into the registry
80   ; WriteRegStr HKLM "Software\Voria_@PACKAGE_TARNAME@" "Install_Dir" "$INSTDIR"
81   
82   WriteRegStr HKLM "${SYNFIG_REG_KEY}" "Path" "$INSTDIR"
83   WriteRegStr HKLM "${SYNFIG_REG_KEY}" "Version" "@PACKAGE_VERSION@"
84   
85   ; Write the uninstall keys for Windows
86   WriteRegStr HKLM "${SYNFIG_UNINSTALL_KEY}" "DisplayName" "@PACKAGE_NAME@"
87   WriteRegStr HKLM "${SYNFIG_UNINSTALL_KEY}" "DisplayVersion" "@PACKAGE_VERSION@"
88   WriteRegStr HKLM "${SYNFIG_UNINSTALL_KEY}" "UninstallString" '"$INSTDIR\${SYNFIG_UNINSTALL_EXE}"'
89   WriteRegDWORD HKLM "${SYNFIG_UNINSTALL_KEY}" "NoModify" 1
90   WriteRegDWORD HKLM "${SYNFIG_UNINSTALL_KEY}" "NoRepair" 1
91   WriteUninstaller "${SYNFIG_UNINSTALL_EXE}"
92   
93 SectionEnd
94
95
96 ; Optional section (can be disabled by the user)
97 ;Section "Start Menu Shortcuts"
98
99 ;  CreateDirectory "$SMPROGRAMS\Example2"
100 ;  CreateShortCut "$SMPROGRAMS\Example2\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
101 ;  CreateShortCut "$SMPROGRAMS\Example2\Example2 (MakeNSISW).lnk" "$INSTDIR\makensisw.exe" "" "$INSTDIR\makensisw.exe" 0
102   
103 ;SectionEnd
104
105 ; Optional section (can be disabled by the user)
106 Section "Start Menu Shortcuts"
107
108   CreateDirectory "$SMPROGRAMS\Voria"
109   CreateShortCut "$SMPROGRAMS\Voria\Uninstall Synfig Core.lnk" "$INSTDIR\uninstall-@PACKAGE_TARNAME@.exe" "" "$INSTDIR\uninstall-@PACKAGE_TARNAME@.exe" 0
110   
111 SectionEnd
112
113
114 ;--------------------------------
115
116 ; Uninstaller
117
118 Section "Uninstall"
119   
120   ; Remove registry keys
121   DeleteRegKey HKLM "${SYNFIG_REG_KEY}"
122   DeleteRegKey HKLM "${SYNFIG_UNINSTALL_KEY}"
123   ; DeleteRegKey HKLM "Software\Voria_@PACKAGE_TARNAME@"
124
125   ; Remove files and uninstaller
126   ;Delete $INSTDIR\synfig.exe
127   Delete $INSTDIR\uninstall-@PACKAGE_TARNAME@.exe
128   Delete $INSTDIR\etc\synfig_modules.cfg
129   RMDir $INSTDIR\bin
130   RMDir $INSTDIR\etc
131
132   ; Remove shortcuts, if any
133
134   Delete "$SMPROGRAMS\Voria\Uninstall Synfig Core.lnk"
135   ; Remove directories used
136   ;RMDir "$SMPROGRAMS\Example2"
137   RMDir "$INSTDIR"
138
139 SectionEnd
140
141 !include @srcdir@\src\synfig\synfig.nsh
142 !include @srcdir@\src\tool\tool.nsh
143
144 Section "Examples"
145         SetOutPath $INSTDIR\examples
146         File "@srcdir@\examples\*.sif"
147         CreateDirectory "$SMPROGRAMS\Voria"
148         CreateShortCut "$SMPROGRAMS\Voria\Examples.lnk" "$INSTDIR\examples" "" "$INSTDIR\examples" 0
149 SectionEnd
150
151 Section "un.Examples"
152         Delete "$SMPROGRAMS\Voria\Examples.lnk"
153         Delete "$INSTDIR\examples\*.sif"
154         RMDir "$INSTDIR\examples"
155 SectionEnd
156
157 SubSection "PlugIns"
158 SubSection "Layers"
159 !include "@srcdir@\src\modules\lyr_std\lyr_std.nsh"
160 !include "@srcdir@\src\modules\mod_filter\mod_filter.nsh"
161 !include "@srcdir@\src\modules\mod_gradient\mod_gradient.nsh"
162 !include "@srcdir@\src\modules\mod_noise\mod_noise.nsh"
163 !include "@srcdir@\src\modules\mod_particle\mod_particle.nsh"
164 !include "@srcdir@\src\modules\mod_geometry\mod_geometry.nsh"
165 !include "@srcdir@\src\modules\lyr_freetype\lyr_freetype.nsh"
166 SubSectionEnd
167 SubSection "Render Targets"
168 !include "@srcdir@\src\modules\mod_bmp\mod_bmp.nsh"
169 !include "@srcdir@\src\modules\mod_dv\mod_dv.nsh"
170 !include "@srcdir@\src\modules\mod_ffmpeg\mod_ffmpeg.nsh"
171 !include "@srcdir@\src\modules\mod_gif\mod_gif.nsh"
172 !include "@srcdir@\src\modules\mod_imagemagick\mod_imagemagick.nsh"
173 !include "@srcdir@\src\modules\mod_jpeg\mod_jpeg.nsh"
174 !include "@srcdir@\src\modules\mod_png\mod_png.nsh"
175 !include "@srcdir@\src\modules\mod_ppm\mod_ppm.nsh"
176 !include "@srcdir@\src\modules\mod_yuv420p\mod_yuv420p.nsh"
177 SubSectionEnd
178 SubSectionEnd
179
180
181 SubSection "un.PlugIns"
182 SubSection "un.Layers"
183 !include "@srcdir@\src\modules\lyr_std\unlyr_std.nsh"
184 !include "@srcdir@\src\modules\lyr_freetype\unlyr_freetype.nsh"
185 !include "@srcdir@\src\modules\mod_filter\unmod_filter.nsh"
186 !include "@srcdir@\src\modules\mod_gradient\unmod_gradient.nsh"
187 !include "@srcdir@\src\modules\mod_noise\unmod_noise.nsh"
188 !include "@srcdir@\src\modules\mod_particle\unmod_particle.nsh"
189 !include "@srcdir@\src\modules\mod_geometry\unmod_geometry.nsh"
190 SubSectionEnd
191 SubSection "un.Render Targets"
192 !include "@srcdir@\src\modules\mod_bmp\unmod_bmp.nsh"
193 !include "@srcdir@\src\modules\mod_dv\unmod_dv.nsh"
194 !include "@srcdir@\src\modules\mod_ffmpeg\unmod_ffmpeg.nsh"
195 !include "@srcdir@\src\modules\mod_gif\unmod_gif.nsh"
196 !include "@srcdir@\src\modules\mod_imagemagick\unmod_imagemagick.nsh"
197 !include "@srcdir@\src\modules\mod_jpeg\unmod_jpeg.nsh"
198 !include "@srcdir@\src\modules\mod_png\unmod_png.nsh"
199 !include "@srcdir@\src\modules\mod_ppm\unmod_ppm.nsh"
200 !include "@srcdir@\src\modules\mod_yuv420p\unmod_yuv420p.nsh"
201 SubSectionEnd
202 SubSectionEnd
203
204 Function .onInit
205         ; Get installer location
206         ReadRegStr $R0 HKLM "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
207 ;       IfErrors 0 +2
208 ;       ReadRegStr $R0 HKCU "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
209         
210         StrCmp $R0 "" done
211
212         ; Get current installed version
213         ReadRegStr $R1 HKLM "${SYNFIG_UNINSTALL_KEY}" "DisplayVersion"
214 ;       IfErrors 0 +2
215 ;       ReadRegStr $R1 HKCU "${SYNFIG_UNINSTALL_KEY}" "DisplayVersion"
216
217 ;  StrCmp $R1 ${PRODUCT_VERSION} done
218
219         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
220
221         ; Run the uninstaller
222         
223         ClearErrors
224         ; CopyFiles "$R0" $TEMP
225         ExecWait '$R0 _?=$INSTDIR'
226         IfErrors no_remove_uninstaller
227         Delete $R0
228         RMDir $INSTDIR
229
230 no_remove_uninstaller:
231 ;    Delete "$TEMP\$R0"
232         
233     ; Check that the user completed the uninstallation by examining the registry
234     ReadRegStr $R0 HKLM "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
235         StrCmp $R0 "" done abortInstall
236         ReadRegStr $R0 HKCU "${SYNFIG_UNINSTALL_KEY}" "UninstallString"
237         StrCmp $R0 "" done abortInstall
238
239 abortInstall:
240     MessageBox MB_OK|MB_ICONEXCLAMATION "Unable to uninstall previous version of @PACKAGE_NAME@"
241     Abort
242
243 done:
244     BringToFront
245
246 FunctionEnd