]> git.street.me.uk Git - andy/viking.git/blob - win32/prepare.bat
Enable using an optional file cache for Mapnik Renderings.
[andy/viking.git] / win32 / prepare.bat
1 @echo OFF\r
2 :: License: CC0\r
3 ::\r
4 :: Setup wget first - this has to be done manually\r
5 :: http://gnuwin32.sourceforge.net/packages/wget.htm\r
6 :: http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-setup.exe\r
7 ::\r
8 :: Simple script to check required built environment in default locations\r
9 ::  Versions downloaded are specified absolutely as otherwise it's tricky to try and work out the latest/stable version\r
10 :: In principal the idea is to try and automate the process as much as possible\r
11 ::\r
12 set PATH=%PATH%;%ProgramFiles%\GnuWin32\bin\r
13 \r
14 set MINGW=%SystemDrive%\MinGW\r
15 set MINGW_BIN=%MinGW%\bin\r
16 \r
17 set ERRORLEVEL=0\r
18 \r
19 if not exist cache mkdir cache\r
20 pushd cache\r
21 \r
22 :: We need a program to be able to extract not only zips, but bz2 and *lzma*
23 set PATH=%PATH%;%ProgramFiles%\7-Zip
24 echo =+=+=
25 echo Checking 7Zip is Available...
26 echo =+=+=
27 set ZIP_INST=7z920.exe
28 if not exist "%ProgramFiles%\7-Zip\7z.exe" (
29         call :Download %ZIP_INST% http://downloads.sourceforge.net/sevenzip/%ZIP_INST%
30         %ZIP_INST% /S
31         if ERRORLEVEL 1 goto Error
32 )
33
34 echo =+=+=\r
35 echo Checking mingw...\r
36 echo =+=+=\r
37 set MINGW_BASE_URL=http://sourceforge.net/projects/mingw/files/MinGW/Base
38 set BIN_UTILS_LZ=binutils-2.23.2-1-mingw32-bin.tar.lzma
39 set BIN_UTILS_URL=%MINGW_BASE_URL%/binutils/binutils-2.23.2-1/%BIN_UTILS_LZ%/download
40 ::GCC dependencies::
41 set MPC_DEV_LZ=mpc-1.0.1-2-mingw32-dev.tar.lzma
42 set MPC_DEV_URL=%MINGW_BASE_URL%/mpc/mpc-1.0.1-2/%MPC_DEV_LZ%/download
43 set MPC_DLL_LZ=mpc-1.0.1-2-mingw32-dll.tar.lzma
44 set MPC_DLL_URL=%MINGW_BASE_URL%/mpc/mpc-1.0.1-2/%MPC_DLL_LZ%/download
45 set MPFR_DEV_LZ=mpfr-3.1.2-2-mingw32-dev.tar.lzma
46 set MPFR_DEV_URL=%MINGW_BASE_URL%/mpfr/mpfr-3.1.2-2/%MPFR_DEV_LZ%/download
47 set MPFR_DLL_LZ=mpfr-3.1.2-2-mingw32-dll.tar.lzma
48 set MPFR_DLL_URL=%MINGW_BASE_URL%/mpfr/mpfr-3.1.2-2/%MPFR_DLL_LZ%/download
49 set GMP_DEV_LZ=gmp-5.1.2-1-mingw32-dev.tar.lzma
50 set GMP_DEV_URL=%MINGW_BASE_URL%/gmp/gmp-5.1.2/%GMP_DEV_LZ%/download
51 set GMP_DLL_LZ=gmp-5.1.2-1-mingw32-dll.tar.lzma
52 set GMP_DLL_URL=%MINGW_BASE_URL%/gmp/gmp-5.1.2/%GMP_DLL_LZ%/download
53 set PTHREADS_DEV_LZ=pthreads-w32-2.9.1-1-mingw32-dev.tar.lzma
54 set PTHREADS_DEV_URL=%MINGW_BASE_URL%/pthreads-w32/pthreads-w32-2.9.1/%PTHREADS_DEV_LZ%/download
55 set PTHREADS_DLL_LZ=pthreads-w32-2.9.1-1-mingw32-dll.tar.lzma
56 set PTHREADS_DLL_URL=%MINGW_BASE_URL%/pthreads-w32/pthreads-w32-2.9.1/%PTHREADS_DLL_LZ%/download
57 set ICONV_DEV_LZ=libiconv-1.14-3-mingw32-dev.tar.lzma
58 set ICONV_DEV_URL=%MINGW_BASE_URL%/libiconv/libiconv-1.14-3/%ICONV_DEV_LZ%/download
59 set ICONV_DLL_LZ=libiconv-1.14-3-mingw32-dll.tar.lzma
60 set ICONV_DLL_URL=%MINGW_BASE_URL%/libiconv/libiconv-1.14-3/%ICONV_DLL_LZ%/download
61 set GCC_CORE_BIN_LZ=gcc-core-4.8.1-4-mingw32-bin.tar.lzma
62 set GCC_CORE_BIN_URL=%MINGW_BASE_URL%/gcc/Version4/gcc-4.8.1-4/%GCC_CORE_BIN_LZ%/download
63 set GCC_CORE_DEV_LZ=gcc-core-4.8.1-4-mingw32-dev.tar.lzma
64 set GCC_CORE_DEV_URL=%MINGW_BASE_URL%/gcc/Version4/gcc-4.8.1-4/%GCC_CORE_DEV_LZ%/download
65 set GCC_CORE_DLL_LZ=gcc-core-4.8.1-4-mingw32-dll.tar.lzma
66 set GCC_CORE_DLL_URL=%MINGW_BASE_URL%/gcc/Version4/gcc-4.8.1-4/%GCC_CORE_DLL_LZ%/download
67 set MINGWRTDLL_LZ=mingwrt-4.0.3-1-mingw32-dll.tar.lzma
68 set MINGWRTDLL_URL=%MINGW_BASE_URL%/mingw-rt/mingwrt-4.0.3/%MINGWRTDLL_LZ%/download
69 set MINGWRTDEV_LZ=mingwrt-4.0.3-1-mingw32-dev.tar.lzma
70 set MINGWRTDEV_URL=%MINGW_BASE_URL%/mingw-rt/mingwrt-4.0.3/%MINGWRTDEV_LZ%/download
71 set W32API_LZ=w32api-4.0.3-1-mingw32-dev.tar.lzma
72 set W32API_URL=%MINGW_BASE_URL%/w32api/w32api-4.0.3/%W32API_LZ%/download
73 set ZLIB_LZ=zlib-1.2.8-1-mingw32-dll.tar.lzma
74 set ZLIB_URL=%MINGW_BASE_URL%/zlib/zlib-1.2.8/%ZLIB_LZ%/download
75 set GETTEXT_LZ=gettext-0.18.3.1-1-mingw32-dll.tar.lzma
76 set GETTEXT_URL=%MINGW_BASE_URL%/gettext/gettext-0.18.3.1-1/%GETTEXT_LZ%/download
77 \r
78 if not exist "%MINGW_BIN%" (\r
79         :: Here we download all default components manually in an attempt to get autoinstall to work...\r
80         call :Download "%BIN_UTILS_LZ%" "%BIN_UTILS_URL%"
81         call :InstallLZMA "%BIN_UTILS_LZ%"
82
83         call :Download "%MPC_DLL_LZ%" "%MPC_DLL_URL%"
84         call :InstallLZMA "%MPC_DLL_LZ%"
85
86         call :Download "%MPC_DEV_LZ%" "%MPC_DEV_URL%"
87         call :InstallLZMA "%MPC_DEV_LZ%"
88
89         call :Download "%MPFR_DLL_LZ%" "%MPFR_DLL_URL%"
90         call :InstallLZMA "%MPFR_DLL_LZ%"
91
92         call :Download "%MPFR_DEV_LZ%" "%MPFR_DEV_URL%"
93         call :InstallLZMA "%MPFR_DEV_LZ%"
94
95         call :Download "%GMP_DEV_LZ%" "%GMP_DEV_URL%"
96         call :InstallLZMA "%GMP_DEV_LZ%"
97
98         call :Download "%GMP_DLL_LZ%" "%GMP_DLL_URL%"
99         call :InstallLZMA "%GMP_DLL_LZ%"
100
101         call :Download "%PTHREADS_DLL_LZ%" "%PTHREADS_DLL_URL%"
102         call :InstallLZMA "%PTHREADS_DLL_LZ%"
103
104         call :Download "%PTHREADS_DEV_LZ%" "%PTHREADS_DEV_URL%"
105         call :InstallLZMA "%PTHREADS_DEV_LZ%"
106
107         call :Download "%ICONV_DEV_LZ%" "%ICONV_DEV_URL%"
108         call :InstallLZMA "%ICONV_DEV_LZ%"
109
110         call :Download "%ICONV_DLL_LZ%" "%ICONV_DLL_URL%"
111         call :InstallLZMA "%ICONV_DLL_LZ%"
112
113         call :Download "%GCC_CORE_DEV_LZ%" "%GCC_CORE_DEV_URL%"
114         call :InstallLZMA "%GCC_CORE_DEV_LZ%"
115
116         call :Download "%GCC_CORE_DLL_LZ%" "%GCC_CORE_DLL_URL%"
117         call :InstallLZMA "%GCC_CORE_DLL_LZ%"
118
119         call :Download "%GCC_CORE_BIN_LZ%" "%GCC_CORE_BIN_URL%"
120         call :InstallLZMA "%GCC_CORE_BIN_LZ%"
121
122         call :Download "%MINGWRTDEV_LZ%" "%MINGWRTDEV_URL%"
123         call :InstallLZMA "%MINGWRTDEV_LZ%"
124
125         call :Download "%MINGWRTDLL_LZ%" "%MINGWRTDLL_URL%"
126         call :InstallLZMA "%MINGWRTDLL_LZ%"
127
128         call :Download "%W32API_LZ%" "%W32API_URL%"
129         call :InstallLZMA "%W32API_LZ%"
130
131         call :Download "%ZLIB_LZ%" "%ZLIB_URL%"
132         call :InstallLZMA "%ZLIB_LZ%"
133
134         call :Download "%GETTEXT_LZ%" "%GETTEXT_URL%"
135         call :InstallLZMA "%GETTEXT_LZ%"
136 )\r
137 \r
138 echo =+=+=\r
139 echo Checking MSYS...\r
140 echo =+=+=\r
141 set MSYS_EXE=MSYS-1.0.11.exe\r
142 if not exist "%SystemDrive%\msys" (\r
143         if not exist %MSYS_EXE% (\r
144                 wget http://downloads.sourceforge.net/mingw/%MSYS_EXE%\r
145         )\r
146         if not [%WINELOADERNOEXEC%]==[] (
147                 echo Running under WINE - Requires MSYS install fixes: run msys-pi-wine.sh when msys install halts..."\r
148                 echo Ctrl-C to stop and then rerun the installation if necessary\r
149         )\r
150         %MSYS_EXE% /sp- /silent\r
151         if ERRORLEVEL 1 goto Error\r
152 )\r
153 \r
154 ::\r
155 echo =+=+=\r
156 echo Checking gtk+-bundle...\r
157 echo =+=+=\r
158 set GTK_ZIP=gtk+-bundle_2.24.10-20120208_win32.zip\r
159 if not exist "%MINGW_BIN%\gtk-update-icon-cache.exe" (\r
160         call :Download %GTK_ZIP% http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/%GTK_ZIP%
161         7z x %GTK_ZIP% -o"%MinGW%" -y
162         if ERRORLEVEL 1 goto Error\r
163 )\r
164 \r
165 set EXPAT_ZIP=expat-dev_2.0.1-1_win32.zip\r
166 echo =+=+=\r
167 echo Checking expat-dev...\r
168 echo =+=+=\r
169 if not exist "%MINGW%\include\expat.h" (\r
170         call :Download  %EXPAT_ZIP% http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/%EXPAT_ZIP%
171         7z x %EXPAT_ZIP% -o"%MinGW%"\r
172         if ERRORLEVEL 1 goto Error\r
173 )\r
174 \r
175 ::set GTT_ZIP=gettext-tools-dev_0.18.1.1-2_win32.zip
176 ::echo =+=+=
177 ::echo Checking gettext-tools-dev...
178 ::echo =+=+=
179 ::if not exist "%MINGW_BIN%\libgettextlib-0-18-1.dll" (
180 ::      if not exist %GTT_ZIP% (
181 ::              wget http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/%GTT_ZIP%
182 ::      )
183 ::      7z x -y %GTT_ZIP% -o"%MinGW%"
184 ::      if ERRORLEVEL 1 goto Error
185 ::)
186 \r
187 echo =+=+=\r
188 echo Checking intltool...\r
189 echo =+=+=\r
190 set INTLTOOL_ZIP=intltool_0.40.4-1_win32.zip\r
191 if not exist "%MINGW_BIN%\intltoolize" (\r
192         call :Download %INTLTOOL_ZIP% http://ftp.acc.umu.se/pub/GNOME/binaries/win32/intltool/0.40/%INTLTOOL_ZIP%
193         7z x %INTLTOOL_ZIP% -o"%MinGW%"\r
194         if ERRORLEVEL 1 goto Error\r
195 )\r
196 \r
197 echo =+=+=\r
198 echo Checking iconv...\r
199 echo =+=+=\r
200 set ICONV_ZIP=libiconv-1.9.2-1-bin.zip\r
201 if not exist "%MINGW_BIN%\iconv.exe" (\r
202         call :Download %ICONV_ZIP% http://sourceforge.net/projects/gnuwin32/files/libiconv/1.9.2-1/%ICONV_ZIP%
203         7z x -y %ICONV_ZIP% -o"%MinGW%"\r
204         if ERRORLEVEL 1 goto Error\r
205 )\r
206 \r
207 echo =+=+=\r
208 echo Checking libintl...\r
209 echo =+=+=\r
210 :: Needed by iconv\r
211 set LIBINTL_ZIP=libintl-0.14.4-bin.zip\r
212 if not exist "%MINGW_BIN%\libintl3.dll" (\r
213         call :Download %LIBINTL_ZIP% http://sourceforge.net/projects/gnuwin32/files/libintl/0.14.4/%LIBINTL_ZIP%
214         7z x -y %LIBINTL_ZIP% -o"%MinGW%"\r
215         if ERRORLEVEL 1 goto Error\r
216 )\r
217 \r
218 echo =+=+=\r
219 echo Checking gettext tools...
220 echo =+=+=
221 :: Needed by intltool
222 set GETTEXT_BIN_LZ=gettext-0.18.3.1-1-mingw32-bin.tar.lzma
223 set GETTEXT_BIN_URL=%MINGW_BASE_URL%/gettext/gettext-0.18.3.1-1/%GETTEXT_BIN_LZ%/download
224 if not exist "%MINGW_BIN%\xgettext.exe" (
225         call :Download %GETTEXT_BIN_LZ% %GETTEXT_BIN_URL%
226         call :InstallLZMA "%GETTEXT_BIN_LZ%"
227 )
228
229 echo =+=+=
230 echo Checking libcurl...\r
231 echo =+=+=\r
232 REM Win32 - Generic - http://curl.haxx.se/download.html
233 set CURL=curl-7.34.0-devel-mingw32
234 set CURL_ZIP=%CURL%.zip
235 if not exist "%MINGW_BIN%\libcurl.dll" (\r
236         call :Download %CURL_ZIP% http://curl.haxx.se/gknw.net/7.34.0/dist-w32/%CURL_ZIP%
237         echo Extracting libcurl...\r
238         7z x -y %CURL_ZIP% -o"libcurl"
239         if ERRORLEVEL 1 goto Error\r
240         @echo ON\r
241         xcopy /S /Y libcurl\%CURL%\include\*.* "%MinGW%\include"
242         xcopy /S /Y libcurl\%CURL%\bin\*.* "%MinGW_BIN%"
243         xcopy /S /Y libcurl\%CURL%\lib\*.a "%MinGW%\lib"
244         copy /Y libcurl\%CURL%\COPYING "%MinGW%\COPYING_curl.txt"
245         rmdir /S /Q libcurl\r
246         @echo OFF\r
247 )\r
248 \r
249 echo =+=+=\r
250 echo Checking libexif...\r
251 echo =+=+=\r
252 set EXIF=libexif-0.6.21.1_winxp_mingw
253 set EXIF_7Z=%EXIF%.7z\r
254 if not exist "%MINGW_BIN%\libexif-12.dll" (\r
255         :: Space in URL so function call doesn't work ATM
256         ::call :Download %EXIF_7Z% "http://sourceforge.net/projects/maille/files/Extern libs/%EXIF_7Z%/download"
257         if not exist "%EXIF_7Z%" (
258                 wget "http://sourceforge.net/projects/maille/files/Extern libs/%EXIF_7Z%/download"\r
259                 if ERRORLEVEL 1 goto Error
260         )\r
261
262         echo Extracting libexif...\r
263         7z x %EXIF_7Z%\r
264         if ERRORLEVEL 1 goto Error\r
265 \r
266         echo Using xcopy to get all subdirs of libexif into place...
267         @echo ON\r
268         xcopy /Y /S %EXIF%\*.* "%MinGW%"\r
269         rmdir /S /Q %EXIF%\r
270         @echo OFF\r
271 )\r
272 \r
273 echo =+=+=\r
274 echo Checking libstdc++...\r
275 echo =+=+=\r
276 set STDCPP_TAR=gcc-c++-4.8.1-4-mingw32-dll.tar
277 set STDCPP_LZ=%STDCPP_TAR%.lzma\r
278 if not exist "%MINGW_BIN%\libstdc++-6.dll" (\r
279   call :Download "%STDCPP_LZ%" "http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/gcc-4.8.1-4/%STDCPP_LZ%/download"
280   call :InstallLZMA "%STDCPP_LZ%"
281 )\r
282 \r
283 echo =+=+=\r
284 echo Checking libbz2 header...\r
285 echo =+=+=\r
286 set BZ2_TAR=bzip2-1.0.6-4-mingw32-dev.tar\r
287 set BZ2_LZ=%BZ2_TAR%.lzma\r
288 if not exist "%MINGW%\include\bzlib.h" (\r
289         call :Download %BZ2_LZ% "http://sourceforge.net/projects/mingw/files/MinGW/Extension/bzip2/bzip2-1.0.6-4/%BZ2_LZ%"
290         call :InstallLZMA "%BZ2_LZ%"
291 )\r
292 \r
293 echo =+=+=\r
294 echo Checking libbz2...\r
295 echo =+=+=\r
296 set BZ2DLL_TAR=libbz2-1.0.6-4-mingw32-dll-2.tar\r
297 set BZ2DLL_LZ=%BZ2DLL_TAR%.lzma\r
298 if not exist "%MINGW_BIN%\libbz2-2.dll" (\r
299         call :Download %BZ2DLL_LZ% "http://sourceforge.net/projects/mingw/files/MinGW/Extension/bzip2/bzip2-1.0.6-4/%BZ2DLL_LZ%"
300         call :InstallLZMA "%BZ2DLL_LZ%"
301 )\r
302 \r
303 echo =+=+=\r
304 echo Checking magic dev...\r
305 echo =+=+=\r
306 set MAGIC_ZIP=file-5.03-lib.zip\r
307 if not exist "%MINGW%\include\magic.h" (\r
308         call :Download %MAGIC_ZIP% http://downloads.sourceforge.net/gnuwin32/%MAGIC_ZIP%
309         7z x %MAGIC_ZIP% -o"%MinGW%"\r
310         if ERRORLEVEL 1 goto Error\r
311 )\r
312 \r
313 echo =+=+=\r
314 echo Checking magic DLL...\r
315 echo =+=+=\r
316 set MAGICDLL_ZIP=file-5.03-bin.zip\r
317 if not exist "%MINGW_BIN%\magic1.dll" (\r
318         call :Download %MAGICDLL_ZIP% http://downloads.sourceforge.net/gnuwin32/%MAGICDLL_ZIP%
319         7z x %MAGICDLL_ZIP% -o"%MinGW%"\r
320         if ERRORLEVEL 1 goto Error\r
321 )\r
322 \r
323 echo =+=+=\r
324 echo Checking regex DLL (required by magic)...\r
325 echo =+=+=\r
326 set REGDLL_ZIP=regex-2.7-bin.zip\r
327 if not exist "%MINGW_BIN%\regex2.dll" (\r
328         call :Download %REGDLL_ZIP% http://downloads.sourceforge.net/gnuwin32/%REGDLL_ZIP%
329         7z x %REGDLL_ZIP% -o"%MinGW%"\r
330         if ERRORLEVEL 1 goto Error\r
331 )\r
332 \r
333 echo =+=+=\r
334 echo Checking SQLite dev...\r
335 echo =+=+=\r
336 set SQL_ZIP=sqlite-amalgamation-3080002.zip\r
337 if not exist "%MINGW%\include\sqlite3.h" (\r
338         call :Download %SQL_ZIP% http://www.sqlite.org/2013/%SQL_ZIP%
339         7z x %SQL_ZIP%\r
340         if ERRORLEVEL 1 goto Error\r
341         copy /Y sqlite-amalgamation-3080002\s* "%MinGW%\include"\r
342         rmdir /S /Q sqlite-amalgamation-3080002\r
343 )\r
344 \r
345 echo =+=+=\r
346 echo Checking SQL DLL...\r
347 echo =+=+=\r
348 set SQLDLL_ZIP=sqlite-dll-win32-x86-3080002.zip\r
349 if not exist "%MINGW_BIN%\sqlite3.dll" (\r
350         call :Download %SQLDLL_ZIP% http://www.sqlite.org/2013/%SQLDLL_ZIP%
351         7z x %SQLDLL_ZIP% -o"%MinGW_BIN%"\r
352         if ERRORLEVEL 1 goto Error\r
353         REM Annoyingly SQL doesn't come with a .lib file so have to generate it ourselves:\r
354         REM Possibly need to insert the line 'LIBRARY sqlite3.dll' at the beginning of the def file?\r
355         REM  but this may not be needed as the --dllname option may suffice\r
356         set PATH=%PATH%;%MinGW_BIN%
357         dlltool.exe -d %MinGW_BIN%\sqlite3.def --dllname %MinGW_BIN%\sqlite3.dll -l %MinGW%\lib\sqlite3.lib
358         if ERRORLEVEL 1 goto Error
359 )\r
360 \r
361 ::\r
362 :: Ideally building the code on Windows shouldn't need Doc Utils or the Help processor stuff\r
363 :: But ATM it's too hard to avoid.\r
364 ::\r
365 echo =+=+=\r
366 echo Checking Gnome Doc Utils...\r
367 echo =+=+=\r
368 set GNOME_DOC_ZIP=gnome-doc-utils-0.12.0.zip\r
369 if not exist "%MINGW_BIN%\gnome-doc-prepare" (\r
370         call :Download %GNOME_DOC_ZIP% http://ftp.gnome.org/pub/gnome/binaries/win32/gnome-doc-utils/0.12/%GNOME_DOC_ZIP%
371         echo Extracting Gnome Doc Utils...\r
372         7z x %GNOME_DOC_ZIP% -o"%MinGW%"\r
373         if ERRORLEVEL 1 goto Error\r
374 )\r
375 \r
376 echo =+=+=\r
377 echo Checking xsltproc...\r
378 echo =+=+=\r
379 set XLST=libxslt-1.1.26.win32\r
380 set XLST_ZIP=%XLST%.zip\r
381 if not exist "%MINGW_BIN%\xsltproc.exe" (\r
382         call :Download %XLST_ZIP% ftp://ftp.zlatkovic.com/libxml/%XLST_ZIP%
383         echo Extracting XLST...\r
384         7z x %XLST_ZIP%\r
385         xcopy /Y /S "%XLST%\bin\*" "%MinGW_BIN%"\r
386         if ERRORLEVEL 1 goto Error\r
387         rmdir /Q /S %XLST%\r
388 )\r
389 \r
390 echo =+=+=\r
391 echo Checking xmllint...\r
392 echo =+=+=\r
393 set XML2=libxml2-2.7.8.win32\r
394 set XML2_ZIP=%XML2%.zip\r
395 if not exist "%MINGW_BIN%\xmllint.exe" (\r
396         call :Download %XML2_ZIP% ftp://ftp.zlatkovic.com/libxml/%XML2_ZIP%
397         echo Extracting xmllint...\r
398         7z x %XML2_ZIP%\r
399         xcopy /Y /S "%XML2%\bin\*" "%MinGW_BIN%"\r
400         if ERRORLEVEL 1 goto Error\r
401         rmdir /Q /S %XML2%\r
402 )\r
403 \r
404 echo =+=+=\r
405 echo Checking iconv...\r
406 echo =+=+=\r
407 set ICONV=iconv-1.9.2.win32\r
408 set ICONV_ZIP=%ICONV%.zip\r
409 if not exist "%MINGW_BIN%\iconv.dll" (\r
410         call :Download %ICONV_ZIP% ftp://ftp.zlatkovic.com/libxml/%ICONV_ZIP%
411         echo Extracting iconv...\r
412         7z x %ICONV_ZIP%\r
413         xcopy /Y /S "%ICONV%\bin\*" "%MinGW_BIN%"\r
414         if ERRORLEVEL 1 goto Error\r
415         rmdir /Q /S %ICONV%\r
416 )\r
417 \r
418 :: Note GPSBabel can not be directly downloaded via wget\r
419 :: ATM get it manually from here:\r
420 ::   http://www.gpsbabel.org/download.html\r
421 set GPSBABEL_INST=GPSBabel-1.5.1-Setup.exe
422 if not exist %GPSBABEL_INST% (
423         echo Required %GPSBABEL_INST% not found. Exitting
424         exit /b
425 )\r
426 \r
427 echo =+=+=\r
428 echo Checking Perl Installation...\r
429 echo =+=+=\r
430 set PERL_MSI=ActivePerl-5.18.2.1802-MSWin32-x86-64int-298023.msi
431 if not exist "%SystemDrive%\Perl" (\r
432         call :Download %PERL_MSI% http://downloads.activestate.com/ActivePerl/releases/5.18.2.1802/%PERL_MSI%
433         echo Installing Perl takes a little time...\r
434         msiexec /qb /i %PERL_MSI% PERL_PATH=Yes PERL_EXT=Yes\r
435         if ERRORLEVEL 1 goto Error\r
436 )\r
437 \r
438 echo =+=+=\r
439 echo Checking NSIS installed...\r
440 echo =+=+=\r
441 set NSIS_INST=nsis-2.46-setup.exe\r
442 if not exist "%ProgramFiles%\NSIS" (\r
443         call :Download %NSIS_INST% http://prdownloads.sourceforge.net/nsis/nsis-2.46-setup.exe?download
444         echo Installing NSIS...\r
445         %NSIS_INST% /S\r
446         if ERRORLEVEL 1 goto Error\r
447 )\r
448 \r
449 echo =+=+=\r
450 echo Checking NSIS Plugins installed...\r
451 echo =+=+=\r
452 set FPDLLZIP=FindProc.zip\r
453 if not exist "%ProgramFiles%\NSIS\Plugins\FindProcDLL.dll" (\r
454         call :Download %FPDLLZIP% http://nsis.sourceforge.net/mediawiki/images/3/3c/%FPDLLZIP%
455         echo Extracting NSIS Plugins...\r
456         7z e %FPDLLZIP% -o"%ProgramFiles%\NSIS\Plugins"\r
457         if ERRORLEVEL 1 goto Error\r
458 )\r
459 \r
460 popd\r
461 \r
462 echo Fixing Perl reference\r
463
464 set PATH=%PATH%;C:\msys\1.0\bin\r
465
466 call :FixPerlRef %MINGW_BIN%\glib-mkenums s:/bin/perl:perl:
467 call :FixPerlRef %MINGW_BIN%\intltool-extract s:/opt/perl/bin/perl:perl:
468 call :FixPerlRef %MINGW_BIN%\intltool-merge s:/opt/perl/bin/perl:perl:
469 call :FixPerlRef %MINGW_BIN%\intltool-prepare s:/opt/perl/bin/perl:perl:
470 call :FixPerlRef %MINGW_BIN%\intltool-update s:/opt/perl/bin/perl:perl:
471
472 goto End
473
474 :FixPerlRef
475 :: Param %1 = File
476 :: Param %2 = sed command
477 :: Sadly '-i' for in place changes doesn't seem available with Windows sed 3.02
478 sed -e '%2' %1 > %1.tmp
479 if ERRORLEVEL 1 goto Error\r
480 xcopy /Y %1.tmp %1
481 if ERRORLEVEL 1 goto Error\r
482 del %1.tmp
483 :: End function
484 exit /b
485 \r
486 :: Potentially Clean Up\r
487 :: If any parameters given on the command line then remove all downloaded items\r
488 :Clean\r
489 if not [%1]==[] (\r
490         echo Removing downloaded files\r
491         if exist cache rmdir /S /Q cache\r
492 )\r
493 \r
494 goto End\r
495 \r
496
497 ::Function to try to download something via wget
498 :: (obviously needs 7zip to be installed first and available on the path!)
499 :: Param %1 = File
500 :: Param %2 = URL (which should retrieve %1) [ URL can't contain a space or %20:( ]
501 :Download
502 if not exist "%1" (
503         wget "%2"
504         if ERRORLEVEL 1 goto Error
505 )
506 :: End function
507 exit /b
508
509 ::Function to install something via 7zip
510 :: (obviously needs 7zip to be installed first and available on the path!)
511 :: Param %1 = LZMA file
512 :: Param %2 = Internal file (normally the .tar file)
513 :InstallBy7Zip
514 echo Extracting "%1" from "%2"
515 7z e "%1"
516 if ERRORLEVEL 1 goto Error
517 7z x "%2" -o"%MinGW%"
518 if ERRORLEVEL 1 goto Error
519 del "%2"
520 if ERRORLEVEL 1 goto Error
521 :: End function
522 exit /b
523
524 ::Function to install LZMA file containing a tar file (via 7zip)
525 :: (obviously needs 7zip to be installed first and available on the path!)
526 :: Param %1 = LZMA file
527 :InstallLZMA
528 7z e "%1"
529 if ERRORLEVEL 1 goto Error
530 set param=%1
531 :: Remove the .lzma extension to get the tar file
532 set file=%param:.lzma=%
533 7z x "%file%" -o"%MinGW%" -y
534 if ERRORLEVEL 1 goto Error
535 del "%file%"
536 if ERRORLEVEL 1 goto Error
537 :: End function
538 exit /b
539
540 :Error\r
541 echo exitting due to error: %ERRORLEVEL%\r
542 exit /b
543 \r
544 :End\r
545 echo Finished\r