]> git.street.me.uk Git - andy/viking.git/blob - win32/prepare.bat
Create and use a function to return the duration of a track.
[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 echo =+=+=\r
23 echo Checking mingw...\r
24 echo =+=+=\r
25 set MINGW_EXE=MinGW-5.1.6.exe\r
26 set BIN_UTILS=binutils-2.19.1-mingw32-bin.tar.gz\r
27 set GCC_CORE=gcc-core-3.4.5-20060117-3.tar.gz\r
28 set GCC_GPP=gcc-g++-3.4.5-20060117-3.tar.gz\r
29 set MINGWRTDLL=mingwrt-3.15.2-mingw32-dll.tar.gz\r
30 set MINGWRTDEV=mingwrt-3.15.2-mingw32-dev.tar.gz\r
31 set W32API=w32api-3.13-mingw32-dev.tar.gz\r
32 \r
33 if not exist "%MINGW_BIN%" (\r
34         :: Here we download all default components manually in an attempt to get autoinstall to work...\r
35         if not exist %MINGW_EXE% (\r
36                 wget "http://sourceforge.net/projects/mingw/files/OldFiles/MinGW 5.1.6/%MINGW_EXE%"\r
37         )\r
38         if not exist %BIN_UTILS% (\r
39                 wget "http://sourceforge.net/projects/mingw/files/MinGW/Base/binutils/binutils-2.19.1/%BIN_UTILS%/download"\r
40         )\r
41         if not exist %GCC_CORE% (\r
42                 wget "http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version3/Current Release_ gcc-3.4.5-20060117-3/%GCC_CORE%/download"\r
43         )\r
44         if not exist %GCC_GPP% (\r
45                 wget "http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version3/Current Release_ gcc-3.4.5-20060117-3/%GCC_GPP%/download"\r
46         )\r
47         if not exist %MINGWRTDEV% (\r
48                 wget http://sourceforge.net/projects/mingw/files/MinGW/Base/mingw-rt/mingwrt-3.15.2/%MINGWRTDEV%/download\r
49         )\r
50         if not exist %MINGWRTDLL% (\r
51                 wget http://sourceforge.net/projects/mingw/files/MinGW/Base/mingw-rt/mingwrt-3.15.2/%MINGWRTDLL%/download\r
52         )\r
53         if not exist %W32API% (\r
54                 wget http://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/w32api-3.13/%W32API%/download\r
55         )\r
56         :: Can't get it to silent install. As a NSIS installer it supports /S, but it doesn't seem to work - it just hangs\r
57         :: Have to click through manually\r
58         %MINGW_EXE%\r
59         if ERRORLEVEL 1 goto Error\r
60 )\r
61 \r
62 echo =+=+=\r
63 echo Checking MSYS...\r
64 echo =+=+=\r
65 set MSYS_EXE=MSYS-1.0.11.exe\r
66 if not exist "%SystemDrive%\msys" (\r
67         if not exist %MSYS_EXE% (\r
68                 wget http://downloads.sourceforge.net/mingw/%MSYS_EXE%\r
69         )\r
70         if not [%WINELOADER%]==[] (\r
71                 echo Running under WINE - Requires MSYS install fixes: run msys-pi-wine.sh when msys install halts..."\r
72                 echo Ctrl-C to stop and then rerun the installation if necessary\r
73         )\r
74         %MSYS_EXE% /sp- /silent\r
75         if ERRORLEVEL 1 goto Error\r
76 )\r
77 \r
78 :: We need a program to be able to extract not only zips, but bz2 and *lzma*\r
79 set PATH=%PATH%;%ProgramFiles%\7-Zip\r
80 echo =+=+=\r
81 echo Checking 7Zip is Available...\r
82 echo =+=+=\r
83 set ZIP_INST=7z920.exe\r
84 if not exist "%ProgramFiles%\7-Zip\7z.exe" (\r
85         if not exist %ZIP_INST% (\r
86                 wget http://downloads.sourceforge.net/sevenzip/%ZIP_INST%\r
87         )\r
88         %ZIP_INST% /S\r
89         if ERRORLEVEL 1 goto Error\r
90 )\r
91 \r
92 ::\r
93 echo =+=+=\r
94 echo Checking gtk+-bundle...\r
95 echo =+=+=\r
96 set GTK_ZIP=gtk+-bundle_2.24.10-20120208_win32.zip\r
97 if not exist "%MINGW_BIN%\gtk-update-icon-cache.exe" (\r
98         if not exist %GTK_ZIP% (\r
99                 wget http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.24/%GTK_ZIP%\r
100         )\r
101         7z x %GTK_ZIP% -o"%MinGW%"\r
102         if ERRORLEVEL 1 goto Error\r
103 )\r
104 \r
105 set EXPAT_ZIP=expat-dev_2.0.1-1_win32.zip\r
106 echo =+=+=\r
107 echo Checking expat-dev...\r
108 echo =+=+=\r
109 if not exist "%MINGW%\include\expat.h" (\r
110         if not exist %EXPAT_ZIP% (\r
111                 wget http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/%EXPAT_ZIP%\r
112         )\r
113         7z x %EXPAT_ZIP% -o"%MinGW%"\r
114         if ERRORLEVEL 1 goto Error\r
115 )\r
116 \r
117 set GTT_ZIP=gettext-tools-dev_0.18.1.1-2_win32.zip\r
118 echo =+=+=\r
119 echo Checking gettext-tools-dev...\r
120 echo =+=+=\r
121 if not exist "%MINGW_BIN%\libgettextlib-0-18-1.dll" (\r
122         if not exist %GTT_ZIP% (\r
123                 wget http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/%GTT_ZIP%\r
124         )\r
125         7z x -y %GTT_ZIP% -o"%MinGW%"\r
126         if ERRORLEVEL 1 goto Error\r
127 )\r
128 \r
129 echo =+=+=\r
130 echo Checking intltool...\r
131 echo =+=+=\r
132 set INTLTOOL_ZIP=intltool_0.40.4-1_win32.zip\r
133 if not exist "%MINGW_BIN%\intltoolize" (\r
134         if not exist %INTLTOOL_ZIP% (\r
135                 wget http://ftp.acc.umu.se/pub/GNOME/binaries/win32/intltool/0.40/%INTLTOOL_ZIP%\r
136         )\r
137         7z x %INTLTOOL_ZIP% -o"%MinGW%"\r
138         if ERRORLEVEL 1 goto Error\r
139 )\r
140 \r
141 echo =+=+=\r
142 echo Checking iconv...\r
143 echo =+=+=\r
144 set ICONV_ZIP=libiconv-1.9.2-1-bin.zip\r
145 if not exist "%MINGW_BIN%\iconv.exe" (\r
146         if not exist %ICONV_ZIP% (\r
147                 wget http://sourceforge.net/projects/gnuwin32/files/libiconv/1.9.2-1/%ICONV_ZIP%\r
148         )\r
149         7z x -y %ICONV_ZIP% -o"%MinGW%"\r
150         if ERRORLEVEL 1 goto Error\r
151 )\r
152 \r
153 echo =+=+=\r
154 echo Checking libintl...\r
155 echo =+=+=\r
156 :: Needed by iconv\r
157 set LIBINTL_ZIP=libintl-0.14.4-bin.zip\r
158 if not exist "%MINGW_BIN%\libintl3.dll" (\r
159         if not exist %LIBINTL_ZIP% (\r
160                 wget http://sourceforge.net/projects/gnuwin32/files/libintl/0.14.4/%LIBINTL_ZIP%\r
161         )\r
162         7z x -y %LIBINTL_ZIP% -o"%MinGW%"\r
163         if ERRORLEVEL 1 goto Error\r
164 )\r
165 \r
166 echo =+=+=\r
167 echo Checking libcurl...\r
168 echo =+=+=\r
169 set CURL_TAR=libcurl-7.14.0_nossl-1sid.tar\r
170 set CURL_BZ2=%CURL_TAR%.bz2\r
171 if not exist "%MINGW_BIN%\libcurl.dll" (\r
172         if not exist %CURL_BZ2% (\r
173                 wget http://downloads.sourceforge.net/devpaks/libcurl-7.14.0_nossl-1sid.DevPak?download\r
174                 move libcurl-7.14.0_nossl-1sid.DevPak %CURL_BZ2%\r
175         )\r
176         echo Extracting libcurl...\r
177         7z e %CURL_BZ2%\r
178         7z x %CURL_TAR% -o"libcurl"\r
179         if ERRORLEVEL 1 goto Error\r
180         @echo ON\r
181         move libcurl\include "%MinGW%\include\curl\r
182         copy /Y libcurl\bin\*.* "%MinGW_BIN%"\r
183         copy /Y libcurl\lib\*.* "%MinGW%\lib"\r
184         copy /Y libcurl\docs\*.* "%MinGW%\doc"\r
185         copy /Y COPYING.txt "%MinGW%\COPYING_curl.txt"\r
186         rmdir /S /Q libcurl\r
187         del %CURL_TAR%\r
188         @echo OFF\r
189 )\r
190 \r
191 echo =+=+=\r
192 echo Checking libexif...\r
193 echo =+=+=\r
194 set EXIF=libexif-0.6.20_winxp_mingw\r
195 set EXIF_7Z=%EXIF%.7z\r
196 if not exist "%MINGW_BIN%\libexif-12.dll" (\r
197         if not exist %EXIF_7Z% (\r
198                 wget "http://sourceforge.net/projects/maille/files/Extern libs/%EXIF_7Z%/download"\r
199         )\r
200         echo Extracting libexif...\r
201         7z x %EXIF_7Z%\r
202         if ERRORLEVEL 1 goto Error\r
203 \r
204         echo Using *xcopy* (to get all subdirs) libexif into place...\r
205         @echo ON\r
206         xcopy /Y /S %EXIF%\*.* "%MinGW%"\r
207         rmdir /S /Q %EXIF%\r
208         @echo OFF\r
209 )\r
210 \r
211 echo =+=+=\r
212 echo Checking libstdc++...\r
213 echo =+=+=\r
214 set STDCPP_TAR=libstdc++-4.6.2-1-mingw32-dll-6.tar\r
215 set STDCPP_LZ=%STDCPP_TAR%.lzma\r
216 if not exist "%MINGW_BIN%\libstdc++-6.dll" (\r
217         if not exist %STDCPP_LZ% (\r
218                 wget http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/gcc-4.6.2-1/%STDCPP_LZ%\r
219         )\r
220         echo Extracting lidstdc++...\r
221         7z e %STDCPP_LZ%\r
222         7z x %STDCPP_TAR% -o"%MinGW%"\r
223         if ERRORLEVEL 1 goto Error\r
224         del %STDCPP_TAR%\r
225 )\r
226 \r
227 echo =+=+=\r
228 echo Checking libbz2 header...\r
229 echo =+=+=\r
230 set BZ2_TAR=bzip2-1.0.6-4-mingw32-dev.tar\r
231 set BZ2_LZ=%BZ2_TAR%.lzma\r
232 if not exist "%MINGW%\include\bzlib.h" (\r
233         if not exist %BZ2_LZ% (\r
234                 wget "http://sourceforge.net/projects/mingw/files/MinGW/Extension/bzip2/bzip2-1.0.6-4/%BZ2_LZ%"\r
235         )\r
236         echo Extracting libbz2 header...\r
237         7z e %BZ2_LZ%\r
238         7z x %BZ2_TAR% -o"%MinGW%"\r
239         if ERRORLEVEL 1 goto Error\r
240         del %BZ2_TAR%\r
241 )\r
242 \r
243 echo =+=+=\r
244 echo Checking libbz2...\r
245 echo =+=+=\r
246 set BZ2DLL_TAR=libbz2-1.0.6-4-mingw32-dll-2.tar\r
247 set BZ2DLL_LZ=%BZ2DLL_TAR%.lzma\r
248 if not exist "%MINGW_BIN%\libbz2-2.dll" (\r
249         if not exist %BZ2DLL_LZ% (\r
250                 wget "http://sourceforge.net/projects/mingw/files/MinGW/Extension/bzip2/bzip2-1.0.6-4/%BZ2DLL_LZ%"\r
251         )\r
252         echo Extracting libbz2...\r
253         7z e %BZ2DLL_LZ%\r
254         7z x %BZ2DLL_TAR% -o"%MinGW%"\r
255         if ERRORLEVEL 1 goto Error\r
256         del %BZ2DLL_TAR%\r
257 )\r
258 \r
259 echo =+=+=\r
260 echo Checking magic dev...\r
261 echo =+=+=\r
262 set MAGIC_ZIP=file-5.03-lib.zip\r
263 if not exist "%MINGW%\include\magic.h" (\r
264         if not exist %MAGIC_ZIP% (\r
265                 wget http://downloads.sourceforge.net/gnuwin32/%MAGIC_ZIP%\r
266         )\r
267         7z x %MAGIC_ZIP% -o"%MinGW%"\r
268         if ERRORLEVEL 1 goto Error\r
269 )\r
270 \r
271 echo =+=+=\r
272 echo Checking magic DLL...\r
273 echo =+=+=\r
274 set MAGICDLL_ZIP=file-5.03-bin.zip\r
275 if not exist "%MINGW_BIN%\magic1.dll" (\r
276         if not exist %MAGICDLL_ZIP% (\r
277                 wget http://downloads.sourceforge.net/gnuwin32/%MAGICDLL_ZIP%\r
278         )\r
279         7z x %MAGICDLL_ZIP% -o"%MinGW%"\r
280         if ERRORLEVEL 1 goto Error\r
281 )\r
282 \r
283 echo =+=+=\r
284 echo Checking regex DLL (required by magic)...\r
285 echo =+=+=\r
286 set REGDLL_ZIP=regex-2.7-bin.zip\r
287 if not exist "%MINGW_BIN%\regex2.dll" (\r
288         if not exist %REGDLL_ZIP% (\r
289                 wget http://downloads.sourceforge.net/gnuwin32/%REGDLL_ZIP%\r
290         )\r
291         7z x %REGDLL_ZIP% -o"%MinGW%"\r
292         if ERRORLEVEL 1 goto Error\r
293 )\r
294 \r
295 echo =+=+=\r
296 echo Checking SQLite dev...\r
297 echo =+=+=\r
298 set SQL_ZIP=sqlite-amalgamation-3080002.zip\r
299 if not exist "%MINGW%\include\sqlite3.h" (\r
300         if not exist %SQL_ZIP% (\r
301                 wget http://www.sqlite.org/2013/%SQL_ZIP%\r
302         )\r
303         7z x %SQL_ZIP%\r
304         if ERRORLEVEL 1 goto Error\r
305         copy /Y sqlite-amalgamation-3080002\s* "%MinGW%\include"\r
306         rmdir /S /Q sqlite-amalgamation-3080002\r
307 )\r
308 \r
309 echo =+=+=\r
310 echo Checking SQL DLL...\r
311 echo =+=+=\r
312 set SQLDLL_ZIP=sqlite-dll-win32-x86-3080002.zip\r
313 if not exist "%MINGW_BIN%\sqlite3.dll" (\r
314         if not exist %SQLDLL_ZIP% (\r
315                 wget http://www.sqlite.org/2013/%SQLDLL_ZIP%\r
316         )\r
317         7z x %SQLDLL_ZIP% -o"%MinGW_BIN%"\r
318         if ERRORLEVEL 1 goto Error\r
319         REM Annoyingly SQL doesn't come with a .lib file so have to generate it ourselves:\r
320         REM Possibly need to insert the line 'LIBRARY sqlite3.dll' at the beginning of the def file?\r
321         REM  but this may not be needed as the --dllname option may suffice\r
322         popd %MinGW_BIN%\r
323         dlltool -d sqlite3.def --dllname sqlite3.dll -l ..\lib\sqlite3.lib\r
324         pushd\r
325 )\r
326 \r
327 ::\r
328 :: Ideally building the code on Windows shouldn't need Doc Utils or the Help processor stuff\r
329 :: But ATM it's too hard to avoid.\r
330 ::\r
331 echo =+=+=\r
332 echo Checking Gnome Doc Utils...\r
333 echo =+=+=\r
334 set GNOME_DOC_ZIP=gnome-doc-utils-0.12.0.zip\r
335 if not exist "%MINGW_BIN%\gnome-doc-prepare" (\r
336         if not exist %GNOME_DOC_ZIP% (\r
337                 wget http://ftp.gnome.org/pub/gnome/binaries/win32/gnome-doc-utils/0.12/%GNOME_DOC_ZIP%\r
338         )\r
339         echo Extracting Gnome Doc Utils...\r
340         7z x %GNOME_DOC_ZIP% -o"%MinGW%"\r
341         if ERRORLEVEL 1 goto Error\r
342 )\r
343 \r
344 echo =+=+=\r
345 echo Checking xsltproc...\r
346 echo =+=+=\r
347 set XLST=libxslt-1.1.26.win32\r
348 set XLST_ZIP=%XLST%.zip\r
349 if not exist "%MINGW_BIN%\xsltproc.exe" (\r
350         if not exist %XLST_ZIP% (\r
351                 wget ftp://ftp.zlatkovic.com/libxml/%XLST_ZIP%\r
352         )\r
353         echo Extracting XLST...\r
354         7z x %XLST_ZIP%\r
355         xcopy /Y /S "%XLST%\bin\*" "%MinGW_BIN%"\r
356         if ERRORLEVEL 1 goto Error\r
357         rmdir /Q /S %XLST%\r
358 )\r
359 \r
360 echo =+=+=\r
361 echo Checking xmllint...\r
362 echo =+=+=\r
363 set XML2=libxml2-2.7.8.win32\r
364 set XML2_ZIP=%XML2%.zip\r
365 if not exist "%MINGW_BIN%\xmllint.exe" (\r
366         if not exist %XML2_ZIP% (\r
367                 wget ftp://ftp.zlatkovic.com/libxml/%XML2_ZIP%\r
368         )\r
369         echo Extracting xmllint...\r
370         7z x %XML2_ZIP%\r
371         xcopy /Y /S "%XML2%\bin\*" "%MinGW_BIN%"\r
372         if ERRORLEVEL 1 goto Error\r
373         rmdir /Q /S %XML2%\r
374 )\r
375 \r
376 echo =+=+=\r
377 echo Checking iconv...\r
378 echo =+=+=\r
379 set ICONV=iconv-1.9.2.win32\r
380 set ICONV_ZIP=%ICONV%.zip\r
381 if not exist "%MINGW_BIN%\iconv.dll" (\r
382         if not exist %ICONV_ZIP% (\r
383                 wget ftp://ftp.zlatkovic.com/libxml/%ICONV_ZIP%\r
384         )\r
385         echo Extracting iconv...\r
386         7z x %ICONV_ZIP%\r
387         xcopy /Y /S "%ICONV%\bin\*" "%MinGW_BIN%"\r
388         if ERRORLEVEL 1 goto Error\r
389         rmdir /Q /S %ICONV%\r
390 )\r
391 \r
392 :: Note GPSBabel can not be directly downloaded via wget\r
393 :: ATM get it manually from here:\r
394 ::   http://www.gpsbabel.org/download.html\r
395 set GPSBABEL_INST=GPSBabel-1.4.4-Setup.exe\r
396 if not exist "%ProgramFiles%\GPSBabel" (\r
397         echo Installing GPSBabel...\r
398         if exist %GPSBABEL_INST% (\r
399                 %GPSBABEL_INST% /silent\r
400                 if ERRORLEVEL 1 goto Error\r
401         )\r
402 )\r
403 \r
404 echo =+=+=\r
405 echo Checking Perl Installation...\r
406 echo =+=+=\r
407 set PERL_MSI=ActivePerl-5.14.3.1404-MSWin32-x86-296513.msi\r
408 if not exist "%SystemDrive%\Perl" (\r
409         if not exist %PERL_MSI% (\r
410                 wget http://downloads.activestate.com/ActivePerl/releases/5.14.3.1404/%PERL_MSI%\r
411         )\r
412         echo Installing Perl takes a little time...\r
413         msiexec /qb /i %PERL_MSI% PERL_PATH=Yes PERL_EXT=Yes\r
414         if ERRORLEVEL 1 goto Error\r
415 )\r
416 \r
417 echo =+=+=\r
418 echo Checking NSIS installed...\r
419 echo =+=+=\r
420 set NSIS_INST=nsis-2.46-setup.exe\r
421 if not exist "%ProgramFiles%\NSIS" (\r
422         if not exist %NSIS_INST% (\r
423                 wget http://prdownloads.sourceforge.net/nsis/nsis-2.46-setup.exe?download\r
424         )\r
425         echo Installing NSIS...\r
426         %NSIS_INST% /S\r
427         if ERRORLEVEL 1 goto Error\r
428 )\r
429 \r
430 echo =+=+=\r
431 echo Checking NSIS Plugins installed...\r
432 echo =+=+=\r
433 set FPDLLZIP=FindProc.zip\r
434 if not exist "%ProgramFiles%\NSIS\Plugins\FindProcDLL.dll" (\r
435         if not exist %FPDLLZIP% (\r
436                 wget http://nsis.sourceforge.net/mediawiki/images/3/3c/%FPDLLZIP%\r
437         )\r
438         echo Extracting NSIS Plugins...\r
439         7z e %FPDLLZIP% -o"%ProgramFiles%\NSIS\Plugins"\r
440         if ERRORLEVEL 1 goto Error\r
441 )\r
442 \r
443 popd\r
444 \r
445 echo Fixing Perl reference\r
446 REM Sadly '-i' for in place changes doesn't seem available with Windows sed 3.02\r
447 set PATH=%PATH%;C:\msys\1.0\bin\r
448 sed -e 's:#! /bin/perl:#! /opt/perl/bin/perl:' %MINGW_BIN%\glib-mkenums > tmp.enums\r
449 if ERRORLEVEL 1 goto Error\r
450 xcopy /Y tmp.enums %MINGW_BIN%\glib-mkenums\r
451 if ERRORLEVEL 1 goto Error\r
452 del tmp.enums\r
453 \r
454 :: Potentially Clean Up\r
455 :: If any parameters given on the command line then remove all downloaded items\r
456 :Clean\r
457 if not [%1]==[] (\r
458         echo Removing downloaded files\r
459         if exist cache rmdir /S /Q cache\r
460 )\r
461 \r
462 goto End\r
463 \r
464 :Error\r
465 echo exitting due to error: %ERRORLEVEL%\r
466 exit\r
467 \r
468 :End\r
469 echo Finished\r