1if exist qtwebkit-23 (
2	echo qtwebkit-23 directory already exists, skipping...
3	exit /b
4)
5
6set OLDPATH=%PATH%
7
8rem Download dependencies.
9
10if exist python-%PYTHONCOMMONPORTABLEVER%-bin-win32\python.exe goto pastpython
11	if not exist python-%PYTHONCOMMONPORTABLEVER%-bin-win32.7z (
12		%WGET% http://python-common-portable.googlecode.com/files/python-%PYTHONCOMMONPORTABLEVER%-bin-win32.7z
13		if errorlevel 1 exit /b 1
14	)
15
16	if exist python-%PYTHONCOMMONPORTABLEVER%-bin-win32 %RMDIR% python-%PYTHONCOMMONPORTABLEVER%-bin-win32
17	mkdir python-%PYTHONCOMMONPORTABLEVER%-bin-win32
18
19	%SEVENZ% x -opython-%PYTHONCOMMONPORTABLEVER%-bin-win32 python-%PYTHONCOMMONPORTABLEVER%-bin-win32.7z
20	if errorlevel 1 exit /b 1
21:pastpython
22
23set PATH=%CD%\python-%PYTHONCOMMONPORTABLEVER%-bin-win32;%PATH%
24
25if exist ruby-%RUBYVER%-i386-mingw32\bin\ruby.exe goto pastruby
26	if not exist ruby-%RUBYVER%-i386-mingw32.7z (
27		%WGET% http://rubyforge.org/frs/download.php/76807/ruby-%RUBYVER%-i386-mingw32.7z
28		if errorlevel 1 exit /b 1
29	)
30
31	if exist ruby-%RUBYVER%-i386-mingw32 %RMDIR% ruby-%RUBYVER%-i386-mingw32
32
33	%SEVENZ% x ruby-%RUBYVER%-i386-mingw32.7z
34	if errorlevel 1 exit /b 1
35:pastruby
36
37set PATH=%CD%\ruby-%RUBYVER%-i386-mingw32\bin;%PATH%
38
39if exist winflexbison\bison.exe goto pastwinflexbison
40	if not exist win_flex_bison-latest.zip (
41		%WGET% http://downloads.sourceforge.net/project/winflexbison/win_flex_bison-latest.zip
42		if errorlevel 1 exit /b 1
43	)
44
45	if exist winflexbison %RMDIR% winflexbison
46	mkdir winflexbison
47
48	%SEVENZ% x -owinflexbison win_flex_bison-latest.zip
49	if errorlevel 1 exit /b 1
50
51	rename winflexbison\win_bison.exe bison.exe
52	if errorlevel 1 exit /b 1
53:pastwinflexbison
54
55set PATH=%CD%\winflexbison;%PATH%
56
57if not exist gnuwin32 mkdir gnuwin32
58set PATH=%CD%\gnuwin32\bin;%PATH%
59
60if exist gnuwin32\bin\gperf.exe goto pastgperf
61	if not exist gperf-%GNUWIN32GPERFVER%-bin.zip (
62		%WGET% http://sourceforge.net/projects/gnuwin32/files/gperf/%GNUWIN32GPERFVER%/gperf-%GNUWIN32GPERFVER%-bin.zip/download
63		if errorlevel 1 exit /b 1
64	)
65
66	%SEVENZ% x -ognuwin32 gperf-%GNUWIN32GPERFVER%-bin.zip
67	if errorlevel 1 exit /b 1
68:pastgperf
69
70if exist gnuwin32\bin\grep.exe goto pastgrep
71	if not exist grep-%GNUWIN32GREPVER%-dep.zip (
72		%WGET% http://sourceforge.net/projects/gnuwin32/files/grep/%GNUWIN32GREPVER%/grep-%GNUWIN32GREPVER%-dep.zip/download
73		if errorlevel 1 exit /b 1
74	)
75
76	if not exist grep-%GNUWIN32GREPVER%-bin.zip (
77		%WGET% http://sourceforge.net/projects/gnuwin32/files/grep/%GNUWIN32GREPVER%/grep-%GNUWIN32GREPVER%-bin.zip/download
78		if errorlevel 1 exit /b 1
79	)
80
81	%SEVENZ% x -ognuwin32 grep-%GNUWIN32GREPVER%-dep.zip
82	if errorlevel 1 exit /b 1
83
84	%SEVENZ% x -ognuwin32 grep-%GNUWIN32GREPVER%-bin.zip
85	if errorlevel 1 exit /b 1
86:pastgrep
87
88rem Now QtWebKit itself.
89
90set TARBALL=qtwebkit-%QTWEBKIT23VER%.tar.gz
91rem FOR does not seem to work inside IF, so I use GOTO.
92if exist %TARBALL% goto pastdownload
93	rem Beware of HTTP 202 Accept: Gitorious will be preparing the tarball and
94	rem send small text instead of it meanwhile.
95
96:download
97	%WGET% -O %TARBALL% http://gitorious.org/webkit/qtwebkit-23/archive-tarball/qtwebkit-%QTWEBKIT23VER%
98	if errorlevel 1 exit /b 1
99
100	for /F "usebackq" %%A in ('%TARBALL%') do set SIZE=%%~zA
101	if %SIZE% LSS 1000000 (
102		%RM% %TARBALL%
103		if errorlevel 1 exit /b 1
104		goto download
105	)
106:pastdownload
107
108if exist pax_global_header %RM% pax_global_header
109if exist webkit-qtwebkit-23 %RMDIR% webkit-qtwebkit-23
110if exist qtwebkit-%QTWEBKIT23VER%.tar %RM% qtwebkit-%QTWEBKIT23VER%.tar
111%SEVENZ% x qtwebkit-%QTWEBKIT23VER%.tar.gz
112if errorlevel 1 exit /b 1
113%SEVENZ% x qtwebkit-%QTWEBKIT23VER%.tar
114if errorlevel 1 exit /b 1
115%RM% qtwebkit-%QTWEBKIT23VER%.tar
116%RM% pax_global_header
117
118rename webkit-qtwebkit-23 qtwebkit-23
119if errorlevel 1 exit /b 1
120
121pushd qtwebkit-23
122if errorlevel 1 exit /b 1
123
124rem This is needed to disable LTCG also on MSVC2012. Otherwise linking fails due to too big objects.
125%SED% -i -e "s/win32-msvc2005|win32-msvc2008|win32-msvc2010|wince/win32-msvc2005|win32-msvc2008|win32-msvc2010|win32-msvc2012|wince/" Source\WebCore\WebCore.pri
126if errorlevel 1 exit /b 1
127
128rem Don't build DumpRenderTree, linking fails.
129%SED% -i -e "/DumpRenderTree\//d" Tools\Tools.pro
130if errorlevel 1 exit /b 1
131
132set QTDIR=%INSTALLPREFIX%\qt
133set SQLITE3SRCDIR=%QTDIR%\src\3rdparty\sqlite
134set PATH=%QTDIR%\bin;%INSTALLPREFIX%\zlib-install\bin;%PATH%
135
136rem debug: --inspector --javascript-debugger?
137rem TODO all: --svg?
138%PERL% Tools\Scripts\build-webkit --qt --release --no-webkit2 --no-force-sse2 --minimal --netscape-plugin-api
139if errorlevel 1 exit /b 1
140
141pushd WebKitBuild\Release
142if errorlevel 1 exit /b 1
143
144nmake install
145if errorlevel 1 exit /b 1
146
147popd
148if errorlevel 1 exit /b 1
149
150popd
151if errorlevel 1 exit /b 1
152
153set PATH=%OLDPATH%
154
155%CP% "%QTDIR%"\lib\QtWebKit4.dll "%INSTALLBASE%"
156if errorlevel 1 exit /b 1
157