forked from rlerdorf/php7dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeext
executable file
·71 lines (63 loc) · 1.92 KB
/
makeext
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
#!/usr/local/php70/bin/php
<?php
if($argc<2) usage();
$zts = $world = false;
$build = [];
$conf = [];
$version = preg_replace('/[\.\-]+/', '', $argv[1]);
function usage() {
$cmd = basename(__FILE__);
echo "Usage: $cmd 71|70|56|55|54|53|all|world [zts]\n";
echo "To rebuild ext for PHP 7.0 and 7.0-debug: $cmd 70\n";
echo "To rebuild ext for PHP 7.0 and 7.0-debug threadsafe: $cmd 70 zts\n";
echo "To rebuild ext for PHP 5.*: $cmd 5\n";
exit;
}
if(!empty($argv[2]) && $argv[2]=='zts') $zts = true;
switch($argv[1]) {
case '71': $build[71]=true; break;
case '7':
case '70': $build[7]=true; break;
case '56': $build[56]=true; break;
case '55': $build[55]=true; break;
case '54': $build[54]=true; break;
case '5': $build = [56=>true,55=>true,54=>true]; break;
case 'all': $build = [7=>true, 56=>true,55=>true,54=>true]; break;
case 'world': $build = [71=>true, 7=>true, 56=>true,55=>true,54=>true]; $world=true; break;
}
function build_it() {
$cmds = [
"=configuring...",
"sudo make distclean 2>&1 1>> /dev/null",
"phpize",
"./configure 2>&1 1>> /tmp/build.log",
"=\ncompiling...",
"make -j2 2>&1 1>> /tmp/build.log",
"=\ninstalling...",
"sudo make install 2>&1 1>> /tmp/build.log",
"=\ndone\n"
];
foreach($cmds as $cmd) {
if($cmd[0]=='=') echo substr($cmd,1);
else shell_exec($cmd);
}
}
$dir = getcwd();
shell_exec("truncate --size 0 /tmp/build.log");
echo "Build log in /tmp/build.log\n";
foreach($build as $v=>$b) {
if(!$zts || $world) {
echo "Building extension for PHP $v\n";
shell_exec("newphp $v");
build_it();
echo "Building PHP $v-debug\n";
shell_exec("newphp $v debug");
build_it();
}
if($zts || $world) {
echo "Building PHP $v-zts\n";
build_it();
echo "Building PHP $v-debug-zts\n";
build_it();
}
}