]> git.street.me.uk Git - andy/viking.git/blob - win32/prepare.bat
[WINDOWS] Update to compile with GCC4.8.1
[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 set CURL_TAR=libcurl-7.14.0_nossl-1sid.tar\r
233 set CURL_BZ2=%CURL_TAR%.bz2\r
234 if not exist "%MINGW_BIN%\libcurl.dll" (\r
235         if not exist %CURL_BZ2% (\r
236                 wget http://downloads.sourceforge.net/devpaks/libcurl-7.14.0_nossl-1sid.DevPak?download\r
237                 move libcurl-7.14.0_nossl-1sid.DevPak %CURL_BZ2%\r
238         )\r
239         echo Extracting libcurl...\r
240         7z e %CURL_BZ2%\r
241         7z x %CURL_TAR% -o"libcurl"\r
242         if ERRORLEVEL 1 goto Error\r
243         @echo ON\r
244         move libcurl\include "%MinGW%\include\curl\r
245         copy /Y libcurl\bin\*.* "%MinGW_BIN%"\r
246         copy /Y libcurl\lib\*.* "%MinGW%\lib"\r
247         copy /Y libcurl\docs\*.* "%MinGW%\doc"\r
248         copy /Y COPYING.txt "%MinGW%\COPYING_curl.txt"\r
249         rmdir /S /Q libcurl\r
250         del %CURL_TAR%\r
251         @echo OFF\r
252 )\r
253 \r
254 echo =+=+=\r
255 echo Checking libexif...\r
256 echo =+=+=\r
257 set EXIF=libexif-0.6.21.1_winxp_mingw
258 set EXIF_7Z=%EXIF%.7z\r
259 if not exist "%MINGW_BIN%\libexif-12.dll" (\r
260         :: Space in URL so function call doesn't work ATM
261         ::call :Download %EXIF_7Z% "http://sourceforge.net/projects/maille/files/Extern libs/%EXIF_7Z%/download"
262         if not exist "%EXIF_7Z%" (
263                 wget "http://sourceforge.net/projects/maille/files/Extern libs/%EXIF_7Z%/download"\r
264                 if ERRORLEVEL 1 goto Error
265         )\r
266
267         echo Extracting libexif...\r
268         7z x %EXIF_7Z%\r
269         if ERRORLEVEL 1 goto Error\r
270 \r
271         echo Using xcopy to get all subdirs of libexif into place...
272         @echo ON\r
273         xcopy /Y /S %EXIF%\*.* "%MinGW%"\r
274         rmdir /S /Q %EXIF%\r
275         @echo OFF\r
276 )\r
277 \r
278 echo =+=+=\r
279 echo Checking libstdc++...\r
280 echo =+=+=\r
281 set STDCPP_TAR=gcc-c++-4.8.1-4-mingw32-dll.tar
282 set STDCPP_LZ=%STDCPP_TAR%.lzma\r
283 if not exist "%MINGW_BIN%\libstdc++-6.dll" (\r
284   call :Download "%STDCPP_LZ%" "http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/gcc-4.8.1-4/%STDCPP_LZ%/download"
285   call :InstallLZMA "%STDCPP_LZ%"
286 )\r
287 \r
288 echo =+=+=\r
289 echo Checking libbz2 header...\r
290 echo =+=+=\r
291 set BZ2_TAR=bzip2-1.0.6-4-mingw32-dev.tar\r
292 set BZ2_LZ=%BZ2_TAR%.lzma\r
293 if not exist "%MINGW%\include\bzlib.h" (\r
294         call :Download %BZ2_LZ% "http://sourceforge.net/projects/mingw/files/MinGW/Extension/bzip2/bzip2-1.0.6-4/%BZ2_LZ%"
295         call :InstallLZMA "%BZ2_LZ%"
296 )\r
297 \r
298 echo =+=+=\r
299 echo Checking libbz2...\r
300 echo =+=+=\r
301 set BZ2DLL_TAR=libbz2-1.0.6-4-mingw32-dll-2.tar\r
302 set BZ2DLL_LZ=%BZ2DLL_TAR%.lzma\r
303 if not exist "%MINGW_BIN%\libbz2-2.dll" (\r
304         call :Download %BZ2DLL_LZ% "http://sourceforge.net/projects/mingw/files/MinGW/Extension/bzip2/bzip2-1.0.6-4/%BZ2DLL_LZ%"
305         call :InstallLZMA "%BZ2DLL_LZ%"
306 )\r
307 \r
308 echo =+=+=\r
309 echo Checking magic dev...\r
310 echo =+=+=\r
311 set MAGIC_ZIP=file-5.03-lib.zip\r
312 if not exist "%MINGW%\include\magic.h" (\r
313         call :Download %MAGIC_ZIP% http://downloads.sourceforge.net/gnuwin32/%MAGIC_ZIP%
314         7z x %MAGIC_ZIP% -o"%MinGW%"\r
315         if ERRORLEVEL 1 goto Error\r
316 )\r
317 \r
318 echo =+=+=\r
319 echo Checking magic DLL...\r
320 echo =+=+=\r
321 set MAGICDLL_ZIP=file-5.03-bin.zip\r
322 if not exist "%MINGW_BIN%\magic1.dll" (\r
323         call :Download %MAGICDLL_ZIP% http://downloads.sourceforge.net/gnuwin32/%MAGICDLL_ZIP%
324         7z x %MAGICDLL_ZIP% -o"%MinGW%"\r
325         if ERRORLEVEL 1 goto Error\r
326 )\r
327 \r
328 echo =+=+=\r
329 echo Checking regex DLL (required by magic)...\r
330 echo =+=+=\r
331 set REGDLL_ZIP=regex-2.7-bin.zip\r
332 if not exist "%MINGW_BIN%\regex2.dll" (\r
333         call :Download %REGDLL_ZIP% http://downloads.sourceforge.net/gnuwin32/%REGDLL_ZIP%
334         7z x %REGDLL_ZIP% -o"%MinGW%"\r
335         if ERRORLEVEL 1 goto Error\r
336 )\r
337 \r
338 echo =+=+=\r
339 echo Checking SQLite dev...\r
340 echo =+=+=\r
341 set SQL_ZIP=sqlite-amalgamation-3080002.zip\r
342 if not exist "%MINGW%\include\sqlite3.h" (\r
343         call :Download %SQL_ZIP% http://www.sqlite.org/2013/%SQL_ZIP%
344         7z x %SQL_ZIP%\r
345         if ERRORLEVEL 1 goto Error\r
346         copy /Y sqlite-amalgamation-3080002\s* "%MinGW%\include"\r
347         rmdir /S /Q sqlite-amalgamation-3080002\r
348 )\r
349 \r
350 echo =+=+=\r
351 echo Checking SQL DLL...\r
352 echo =+=+=\r
353 set SQLDLL_ZIP=sqlite-dll-win32-x86-3080002.zip\r
354 if not exist "%MINGW_BIN%\sqlite3.dll" (\r
355         call :Download %SQLDLL_ZIP% http://www.sqlite.org/2013/%SQLDLL_ZIP%
356         7z x %SQLDLL_ZIP% -o"%MinGW_BIN%"\r
357         if ERRORLEVEL 1 goto Error\r
358         REM Annoyingly SQL doesn't come with a .lib file so have to generate it ourselves:\r
359         REM Possibly need to insert the line 'LIBRARY sqlite3.dll' at the beginning of the def file?\r
360         REM  but this may not be needed as the --dllname option may suffice\r
361         set PATH=%PATH%;%MinGW_BIN%
362         dlltool.exe -d %MinGW_BIN%\sqlite3.def --dllname %MinGW_BIN%\sqlite3.dll -l %MinGW%\lib\sqlite3.lib
363         if ERRORLEVEL 1 goto Error
364 )\r
365 \r
366 ::\r
367 :: Ideally building the code on Windows shouldn't need Doc Utils or the Help processor stuff\r
368 :: But ATM it's too hard to avoid.\r
369 ::\r
370 echo =+=+=\r
371 echo Checking Gnome Doc Utils...\r
372 echo =+=+=\r
373 set GNOME_DOC_ZIP=gnome-doc-utils-0.12.0.zip\r
374 if not exist "%MINGW_BIN%\gnome-doc-prepare" (\r
375         call :Download %GNOME_DOC_ZIP% http://ftp.gnome.org/pub/gnome/binaries/win32/gnome-doc-utils/0.12/%GNOME_DOC_ZIP%
376         echo Extracting Gnome Doc Utils...\r
377         7z x %GNOME_DOC_ZIP% -o"%MinGW%"\r
378         if ERRORLEVEL 1 goto Error\r
379 )\r
380 \r
381 echo =+=+=\r
382 echo Checking xsltproc...\r
383 echo =+=+=\r
384 set XLST=libxslt-1.1.26.win32\r
385 set XLST_ZIP=%XLST%.zip\r
386 if not exist "%MINGW_BIN%\xsltproc.exe" (\r
387         call :Download %XLST_ZIP% ftp://ftp.zlatkovic.com/libxml/%XLST_ZIP%
388         echo Extracting XLST...\r
389         7z x %XLST_ZIP%\r
390         xcopy /Y /S "%XLST%\bin\*" "%MinGW_BIN%"\r
391         if ERRORLEVEL 1 goto Error\r
392         rmdir /Q /S %XLST%\r
393 )\r
394 \r
395 echo =+=+=\r
396 echo Checking xmllint...\r
397 echo =+=+=\r
398 set XML2=libxml2-2.7.8.win32\r
399 set XML2_ZIP=%XML2%.zip\r
400 if not exist "%MINGW_BIN%\xmllint.exe" (\r
401         call :Download %XML2_ZIP% ftp://ftp.zlatkovic.com/libxml/%XML2_ZIP%
402         echo Extracting xmllint...\r
403         7z x %XML2_ZIP%\r
404         xcopy /Y /S "%XML2%\bin\*" "%MinGW_BIN%"\r
405         if ERRORLEVEL 1 goto Error\r
406         rmdir /Q /S %XML2%\r
407 )\r
408 \r
409 echo =+=+=\r
410 echo Checking iconv...\r
411 echo =+=+=\r
412 set ICONV=iconv-1.9.2.win32\r
413 set ICONV_ZIP=%ICONV%.zip\r
414 if not exist "%MINGW_BIN%\iconv.dll" (\r
415         call :Download %ICONV_ZIP% ftp://ftp.zlatkovic.com/libxml/%ICONV_ZIP%
416         echo Extracting iconv...\r
417         7z x %ICONV_ZIP%\r
418         xcopy /Y /S "%ICONV%\bin\*" "%MinGW_BIN%"\r
419         if ERRORLEVEL 1 goto Error\r
420         rmdir /Q /S %ICONV%\r
421 )\r
422 \r
423 :: Note GPSBabel can not be directly downloaded via wget\r
424 :: ATM get it manually from here:\r
425 ::   http://www.gpsbabel.org/download.html\r
426 set GPSBABEL_INST=GPSBabel-1.4.4-Setup.exe\r
427 if not exist "%ProgramFiles%\GPSBabel" (\r
428         echo Installing GPSBabel...\r
429         if exist %GPSBABEL_INST% (\r
430                 %GPSBABEL_INST% /silent\r
431                 if ERRORLEVEL 1 goto Error\r
432         ) else (
433                 echo Required %GPSBABEL_INST% not found. Exitting
434                 exit /b
435         )\r
436 )\r
437 \r
438 echo =+=+=\r
439 echo Checking Perl Installation...\r
440 echo =+=+=\r
441 set PERL_MSI=ActivePerl-5.18.2.1802-MSWin32-x86-64int-298023.msi
442 if not exist "%SystemDrive%\Perl" (\r
443         call :Download %PERL_MSI% http://downloads.activestate.com/ActivePerl/releases/5.18.2.1802/%PERL_MSI%
444         echo Installing Perl takes a little time...\r
445         msiexec /qb /i %PERL_MSI% PERL_PATH=Yes PERL_EXT=Yes\r
446         if ERRORLEVEL 1 goto Error\r
447 )\r
448 \r
449 echo =+=+=\r
450 echo Checking NSIS installed...\r
451 echo =+=+=\r
452 set NSIS_INST=nsis-2.46-setup.exe\r
453 if not exist "%ProgramFiles%\NSIS" (\r
454         call :Download %NSIS_INST% http://prdownloads.sourceforge.net/nsis/nsis-2.46-setup.exe?download
455         echo Installing NSIS...\r
456         %NSIS_INST% /S\r
457         if ERRORLEVEL 1 goto Error\r
458 )\r
459 \r
460 echo =+=+=\r
461 echo Checking NSIS Plugins installed...\r
462 echo =+=+=\r
463 set FPDLLZIP=FindProc.zip\r
464 if not exist "%ProgramFiles%\NSIS\Plugins\FindProcDLL.dll" (\r
465         call :Download %FPDLLZIP% http://nsis.sourceforge.net/mediawiki/images/3/3c/%FPDLLZIP%
466         echo Extracting NSIS Plugins...\r
467         7z e %FPDLLZIP% -o"%ProgramFiles%\NSIS\Plugins"\r
468         if ERRORLEVEL 1 goto Error\r
469 )\r
470 \r
471 popd\r
472 \r
473 echo Fixing Perl reference\r
474
475 set PATH=%PATH%;C:\msys\1.0\bin\r
476
477 call :FixPerlRef %MINGW_BIN%\glib-mkenums s:/bin/perl:perl:
478 call :FixPerlRef %MINGW_BIN%\intltool-extract s:/opt/perl/bin/perl:perl:
479 call :FixPerlRef %MINGW_BIN%\intltool-merge s:/opt/perl/bin/perl:perl:
480 call :FixPerlRef %MINGW_BIN%\intltool-prepare s:/opt/perl/bin/perl:perl:
481 call :FixPerlRef %MINGW_BIN%\intltool-update s:/opt/perl/bin/perl:perl:
482
483 goto End
484
485 :FixPerlRef
486 :: Param %1 = File
487 :: Param %2 = sed command
488 :: Sadly '-i' for in place changes doesn't seem available with Windows sed 3.02
489 sed -e '%2' %1 > %1.tmp
490 if ERRORLEVEL 1 goto Error\r
491 xcopy /Y %1.tmp %1
492 if ERRORLEVEL 1 goto Error\r
493 del %1.tmp
494 :: End function
495 exit /b
496 \r
497 :: Potentially Clean Up\r
498 :: If any parameters given on the command line then remove all downloaded items\r
499 :Clean\r
500 if not [%1]==[] (\r
501         echo Removing downloaded files\r
502         if exist cache rmdir /S /Q cache\r
503 )\r
504 \r
505 goto End\r
506 \r
507
508 ::Function to try to download something via wget
509 :: (obviously needs 7zip to be installed first and available on the path!)
510 :: Param %1 = File
511 :: Param %2 = URL (which should retrieve %1) [ URL can't contain a space or %20:( ]
512 :Download
513 if not exist "%1" (
514         wget "%2"
515         if ERRORLEVEL 1 goto Error
516 )
517 :: End function
518 exit /b
519
520 ::Function to install something via 7zip
521 :: (obviously needs 7zip to be installed first and available on the path!)
522 :: Param %1 = LZMA file
523 :: Param %2 = Internal file (normally the .tar file)
524 :InstallBy7Zip
525 echo Extracting "%1" from "%2"
526 7z e "%1"
527 if ERRORLEVEL 1 goto Error
528 7z x "%2" -o"%MinGW%"
529 if ERRORLEVEL 1 goto Error
530 del "%2"
531 if ERRORLEVEL 1 goto Error
532 :: End function
533 exit /b
534
535 ::Function to install LZMA file containing a tar file (via 7zip)
536 :: (obviously needs 7zip to be installed first and available on the path!)
537 :: Param %1 = LZMA file
538 :InstallLZMA
539 7z e "%1"
540 if ERRORLEVEL 1 goto Error
541 set param=%1
542 :: Remove the .lzma extension to get the tar file
543 set file=%param:.lzma=%
544 7z x "%file%" -o"%MinGW%" -y
545 if ERRORLEVEL 1 goto Error
546 del "%file%"
547 if ERRORLEVEL 1 goto Error
548 :: End function
549 exit /b
550
551 :Error\r
552 echo exitting due to error: %ERRORLEVEL%\r
553 exit /b
554 \r
555 :End\r
556 echo Finished\r