-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild-php-7.0.x-win32-sdk.bat
More file actions
340 lines (287 loc) · 12.2 KB
/
build-php-7.0.x-win32-sdk.bat
File metadata and controls
340 lines (287 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
@ECHO OFF
REM setting info box
@ECHO ############################################################################
@ECHO ## ##
@ECHO ## please install MS Visual Studio Express 2015 for Windows Desktop ##
@ECHO ## http://www.microsoft.com/en-us/download/... ##
@ECHO ## ##
@ECHO ############################################################################
@ECHO.
REM setting PHP version
SET PHPVERSION=7.0.17
SET PHPMAJOR=%PHPVERSION:~0,3%
REM setting full path of current directory to %DIR&
SET DIR=%~dp0
SET DIR=%Dir:~0,-1%
REM check for .\downloads directory
IF NOT EXIST "%DIR%\downloads" (
@ECHO.
@ECHO creating .\downloads directory
MD %DIR%\downloads
)
REM adding current directory and ./downloads to path
SET PATH=%PATH%;%DIR%;%DIR%\downloads;%DIR%\bin;
REM -----------------------------------------------------------
REM --- CHECK EXTENSIONS TO BUILD
REM -----------------------------------------------------------
@ECHO.
SET /P BUILDEXT_EXCEL=Do you want to build the excel extension? [y/n]
@ECHO.
SET /P BUILDEXT_LZ4=Do you want to build the lz4 extension? [y/n]
REM @ECHO.
REM SET /P BUILDEXT_TWIG=Do you want to build the twig extension? [y/n]
REM -----------------------------------------------------------
REM --- TOOLS CHECK
REM -----------------------------------------------------------
REM check for wget availability
wget >nul 2>&1
IF %ERRORLEVEL%==9009 (
REM since wget is not available look if PHP is available and try to download wget from web with PHP
php -v >nul 2>&1
IF NOT %ERRORLEVEL%==9009 (
REM download wget with php
@ECHO.
@ECHO loading wget...
php -r "file_put_contents('%DIR%\downloads\wget.exe',file_get_contents('https://eternallybored.org/misc/wget/current/wget.exe'));"
)
REM if wget download with PHP failed try to download with bitsadmin.exe
IF NOT EXIST "%DIR%\downloads\wget.exe" (
REM checking for bitsadmin.exe to download wget.exe from web source
IF NOT EXIST "%SYSTEMROOT%\System32\bitsadmin.exe" (
@ECHO.
@ECHO wget.exe not available
@ECHO failed to download wget.exe automatically
@ECHO please download wget from https://eternallybored.org/misc/wget/current/wget.exe
@ECHO manually and put the wget.exe file in .\downloads folder
@ECHO it is also available from the php-sdk-binary-tools zip archive
PAUSE
EXIT
)
REM bitsadmin.exe is available but wget.exe is not - so download it from web
@ECHO.
@ECHO loading wget for Windows from...
@ECHO https://eternallybored.org/misc/wget/current/wget.exe
bitsadmin.exe /transfer "WgetDownload" "https://eternallybored.org/misc/wget/current/wget.exe" "%DIR%\downloads\wget.exe"
)
REM if download of wget failed stop script
IF NOT EXIST "%DIR%\downloads\wget.exe" (
@ECHO.
@ECHO loading wget failed. Please re-run script or
@ECHO install .\downloads\wget.exe manually
PAUSE
EXIT
)
)
REM check for 7-zip cli tool
7za >nul 2>&1
IF %ERRORLEVEL%==9009 (
@ECHO.
@ECHO loading 7-zip cli tool from web...
wget http://downloads.sourceforge.net/sevenzip/7za920.zip -O %DIR%\downloads\7za920.zip -N
REM if wget download of 7za failed stop script
IF NOT EXIST "%DIR%\downloads\7za920.zip" (
@ECHO.
@ECHO failed to download 7za920.zip - please re-run this script
PAUSE
EXIT
)
REM if php is available try unpacking 7za with php
php -v >nul 2>&1
IF NOT %ERRORLEVEL%==9009 (
@ECHO.
@ECHO unpacking 7za.exe...
php -r "file_put_contents('%DIR%\downloads\7za.exe',file_get_contents('zip://%DIR%/downloads/7za920.zip#7za.exe'));"
)
REM if unpacking 7za with PHP failed try to unpacking with unzip
IF NOT EXIST "%DIR%\downloads\7za.exe" (
REM check if unzip.exe is available to unpack 7-zip
unzip >nul 2>&1
IF %ERRORLEVEL%==9009 (
REM check for unzip tool in Git\bin
IF EXIST "%PROGRAMFILES(X86)%\Git\bin\unzip.exe" (
@ECHO.
@ECHO copying unzip.exe from Git...
COPY "%PROGRAMFILES(X86)%\Git\bin\unzip.exe" "%DIR%\downloads\"
)
IF NOT EXIST "%DIR%\downloads\unzip.exe" (
@ECHO.
@ECHO please unpack .\downloads\7za920.zip manually and re-run this file
PAUSE
EXIT
)
)
REM unpacking 7za920.zip
@ECHO.
@ECHO unpacking 7-zip cli tool...
CD %DIR%\downloads
unzip -C 7za920.zip 7za.exe
CD %DIR%
)
)
7za >nul 2>&1
IF %ERRORLEVEL%==9009 (
@ECHO.
@ECHO 7za.exe not found - please re-run this script
PAUSE
EXIT
)
REM -----------------------------------------------------------
REM --- PHP SDK PREPARATION
REM -----------------------------------------------------------
IF NOT EXIST "%DIR%\downloads\php-sdk-binary-tools-20110915.zip" (
@ECHO.
@ECHO loading php-sdk-binary tools...
wget http://windows.php.net/downloads/php-sdk/php-sdk-binary-tools-20110915.zip -O %DIR%\downloads\php-sdk-binary-tools-20110915.zip -N
)
IF NOT EXIST "%DIR%\downloads\php-sdk-binary-tools-20110915.zip" (
@ECHO.
@ECHO php-sdk-binary tools zip file not found in .\downloads please re-run this script
PAUSE
EXIT
)
@ECHO.
@ECHO unpacking php-sdk-binary tools...
7za x %DIR%\downloads\php-sdk-binary-tools-20110915.zip -o%DIR% -y
@ECHO.
@ECHO building directory structure...
MD phpdev
CD phpdev
MD vc14
CD vc14
MD x86
CD x86
MD obj_7.0.17
IF NOT EXIST "%DIR%\downloads\deps-7.0-vc14-x86.7z" (
@ECHO.
@ECHO loading php dependencies...
wget http://windows.php.net/downloads/php-sdk/deps-7.0-vc14-x86.7z -O %DIR%\downloads\deps-7.0-vc14-x86.7z -N
)
IF NOT EXIST "%DIR%\downloads\deps-7.0-vc14-x86.7z" (
@ECHO.
@ECHO php dependencies not found in .\downloads please re-run this script
PAUSE
EXIT
)
@ECHO.
@ECHO unpacking php dependencies...
7za x %DIR%\downloads\deps-7.0-vc14-x86.7z -o%DIR%\phpdev\vc14\x86 -y
IF NOT EXIST "%SystemRoot%\System32\vcruntime140.dll" (
@ECHO.
@ECHO MS visual c redistributable dll not found in system path
@ECHO possible problem for compiling
@ECHO grab an up-2-date version of vcruntime140.dll from MS
@ECHO http://www.microsoft.com/en-us/download/details.aspx?id=30679
PAUSE
)
IF EXIST "%SystemRoot%\System32\vcruntime140.dll" (
@ECHO.
@ECHO copying ms visual c redistributable dll from system path...
COPY "%SystemRoot%\System32\vcruntime140.dll" "%DIR%\phpdev\vc14\x86\deps\bin\"
)
IF NOT EXIST "%SystemRoot%\System32\vcruntime140d.dll" (
@ECHO.
@ECHO MS visual c redistributable dll not found in system path
@ECHO possible problem for compiling
@ECHO grab an up-2-date version of vcruntime140d.dll from MS
@ECHO http://www.microsoft.com/en-us/download/details.aspx?id=30679
PAUSE
)
IF EXIST "%SystemRoot%\System32\vcruntime140d.dll" (
@ECHO.
@ECHO copying ms visual c redistributable dll from system path...
COPY "%SystemRoot%\System32\vcruntime140d.dll" "%DIR%\phpdev\vc14\x86\deps\bin\"
)
IF NOT EXIST "%DIR%\downloads\php-7.0.17.tar.bz2" (
@ECHO.
@ECHO loading php source code...
REM wget http://de1.php.net/get/php-7.0.17.tar.bz2/from/this/mirror -O %DIR%\downloads\php-7.0.17.tar.bz2 -N
REM wget https://downloads.php.net/~ab/php-7.0.17.tar.bz2 -O %DIR%\downloads\php-7.0.17.tar.bz2 -N --no-check-certificate
wget http://de1.php.net/get/php-7.0.17.tar.bz2/from/this/mirror -O %DIR%\downloads\php-7.0.17.tar.bz2 -N --no-check-certificate
)
IF NOT EXIST "%DIR%\downloads\php-7.0.17.tar.bz2" (
@ECHO.
@ECHO php source code not found in .\downloads please re-run this script
PAUSE
EXIT
)
IF NOT EXIST "%DIR%\downloads\php-7.0.17.tar" (
7za x %DIR%\downloads\php-7.0.17.tar.bz2 -o%DIR%\downloads -y
)
IF NOT EXIST "%DIR%\downloads\php-7.0.17.tar" (
@ECHO.
@ECHO php source code not found in .\downloads please re-run this script
PAUSE
EXIT
)
@ECHO.
@ECHO unpacking php source code...
7za x %DIR%\downloads\php-7.0.17.tar -o%DIR%\phpdev\vc14\x86 -y
@REM rename 7.0.17 to 7.0.17
@REM MOVE %DIR%\phpdev\vc14\x86\php-7.0.17 %DIR%\phpdev\vc14\x86\php-7.0.17
REM @ECHO cloning php-src repository from github...
REM CD %DIR%\phpdev\vc14\x86
REM git clone --branch=master --depth=1 https://github.com/php/php-src.git php-7.0.17
CD %DIR%
REM SET CFLAGS=--disable-all --enable-cli --enable-snapshot-build --enable-debug --enable-object-out-dir=../obj_7.0.17/ --disable-isapi --disable-nsapi
SET CFLAGS=--disable-all --enable-cli --enable-snapshot-build --enable-object-out-dir=../obj_7.0.17/
REM -----------------------------------------------------------
REM --- PHP_EXCEL / LIBXL EXTENSION
REM -----------------------------------------------------------
IF /I %BUILDEXT_EXCEL%==Y (
call %DIR%\ext\php_excel_7.0.x_x86.bat
REM SET CFLAGS=%CFLAGS% --with-excel=shared --with-xml --with-libxml --with-iconv
SET CFLAGS=%CFLAGS% --with-excel=shared
)
REM -----------------------------------------------------------
REM --- LZ4 EXTENSION
REM -----------------------------------------------------------
IF /I %BUILDEXT_LZ4%==Y (
call %DIR%\ext\php_lz4_7.0.x_x86.bat
SET CFLAGS=%CFLAGS% --enable-lz4=shared
)
REM -----------------------------------------------------------
REM --- TWIG EXTENSION
REM -----------------------------------------------------------
REM IF /I %BUILDEXT_TWIG%==Y (
REM call %DIR%\ext\php_twig_7.0.x_x86.bat
REM SET CFLAGS=%CFLAGS% --enable-twig=shared
REM )
REM -----------------------------------------------------------
REM --- BUILDING COMPILE.BAT files
REM -----------------------------------------------------------
CD %DIR%
@ECHO @ECHO OFF> compile-php-7.0.17-nts-x32.bat
@ECHO @ECHO ####################################################>> compile-php-7.0.17-nts-x32.bat
@ECHO @ECHO ## Attention ##>> compile-php-7.0.17-nts-x32.bat
@ECHO @ECHO ## please call this batch file with ##>> compile-php-7.0.17-nts-x32.bat
@ECHO @ECHO ## Visual Studio 2015 Native Tools Command Prompt ##>> compile-php-7.0.17-nts-x32.bat
@ECHO @ECHO ## the standard Windows CLI will not work ##>> compile-php-7.0.17-nts-x32.bat
@ECHO @ECHO ####################################################>> compile-php-7.0.17-nts-x32.bat
@ECHO.>>compile-php-7.0.17-nts-x32.bat
@ECHO PAUSE>> compile-php-7.0.17-nts-x32.bat
@ECHO call .\bin\phpsdk_setvars.bat>> compile-php-7.0.17-nts-x32.bat
@ECHO CD .\phpdev\vc14\x86\php-7.0.17>> compile-php-7.0.17-nts-x32.bat
@ECHO nmake clean>> compile-php-7.0.17-nts-x32.bat
@ECHO call buildconf.bat --force>> compile-php-7.0.17-nts-x32.bat
@ECHO call configure %CFLAGS% --disable-zts>> compile-php-7.0.17-nts-x32.bat
@ECHO nmake snap /I>> compile-php-7.0.17-nts-x32.bat
@ECHO CD .\..\..\..\..\>> compile-php-7.0.17-nts-x32.bat
@ECHO PAUSE>> compile-php-7.0.17-nts-x32.bat
@ECHO @ECHO OFF> compile-php-7.0.17-ts-x32.bat
@ECHO @ECHO ####################################################>> compile-php-7.0.17-ts-x32.bat
@ECHO @ECHO ## Attention ##>> compile-php-7.0.17-ts-x32.bat
@ECHO @ECHO ## please call this batch file with ##>> compile-php-7.0.17-ts-x32.bat
@ECHO @ECHO ## Visual Studio 2015 Native Tools Command Prompt ##>> compile-php-7.0.17-ts-x32.bat
@ECHO @ECHO ## the standard Windows CLI will not work ##>> compile-php-7.0.17-ts-x32.bat
@ECHO @ECHO ####################################################>> compile-php-7.0.17-ts-x32.bat
@ECHO.>>compile-php-7.0.17-ts-x32.bat
@ECHO PAUSE>> compile-php-7.0.17-ts-x32.bat
@ECHO call .\bin\phpsdk_setvars.bat>> compile-php-7.0.17-ts-x32.bat
@ECHO CD .\phpdev\vc14\x86\php-7.0.17>> compile-php-7.0.17-ts-x32.bat
@ECHO nmake clean>> compile-php-7.0.17-ts-x32.bat
@ECHO call buildconf.bat --force>> compile-php-7.0.17-ts-x32.bat
@ECHO call configure %CFLAGS%>> compile-php-7.0.17-ts-x32.bat
@ECHO nmake snap /I>> compile-php-7.0.17-ts-x32.bat
@ECHO CD .\..\..\..\..\>> compile-php-7.0.17-ts-x32.bat
@ECHO PAUSE>> compile-php-7.0.17-ts-x32.bat
PAUSE