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