-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathya-phpenv-install-mac.sh
105 lines (91 loc) · 2.38 KB
/
ya-phpenv-install-mac.sh
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
#!/bin/sh
set -e
if [ -z "${PHPENV_GLOBAL_PACKAGES+defined}" ]; then
PHPENV_GLOBAL_PACKAGES='
laravel/installer
'
fi
if [ -z "${PHPENV_PECLS+defined}" ]; then
PHPENV_PECLS='
xdebug
'
fi
export PHPENV_VERSION="${1:-$PHPENV_VERSION}"
if [ -z "$PHPENV_VERSION" ]; then
echo "usage: $0 version"
exit
fi
if ! echo "$PHPENV_VERSION" | grep -q -E '^\d+\.\d+\.\d+$'; then
echo "not php version: $1"
exit
fi
if ! type phpenv >/dev/null 2>&1; then
echo 'missing phpenv'
exit
fi
if [ -z "$FORCE" -a -d "`phpenv root`/versions/$PHPENV_VERSION" ]; then
echo "already installed: $PHPENV_VERSION"
exit
fi
rpv=`echo "$PHPENV_VERSION" | sed -e 's/\./_0/g; s/_0*\([0-9][0-9]\)/\1/g'`
if [ $rpv -lt 70205 ]; then
echo "unsupported version: $PHPENV_VERSION"
[ -z "$FORCE" ] && exit
echo "installing may fail..."
fi
if ! type brew >/dev/null 2>&1; then
echo 'missing: Homebrew'
exit
fi
libs='bzip2 libiconv [email protected] tidy-html5 libzip zlib'
if [ $rpv -lt 70400 ]; then
libs="$libs [email protected] libedit re2c"
fi
if [ $rpv -lt 60000 ]; then
libs="$libs curl libmcrypt"
fi
missing=''
for lib in $libs; do
prefix=`brew --prefix "$lib" 2>/dev/null` ||:
if [ -z "$prefix" -o ! -d "$prefix" ]; then
missing="$missing $lib"
fi
done
if [ -n "$missing" ]; then
echo "missing lib:$missing"
exit
fi
export PKG_CONFIG_PATH="$(brew --prefix [email protected])/lib/pkgconfig"
export PHP_BUILD_EXTRA_MAKE_ARGUMENTS="-j`sysctl -n hw.logicalcpu`"
export PHP_BUILD_CONFIGURE_OPTS="\
--with-pear \
--with-zlib \
--with-bz2=$(brew --prefix bzip2) \
--with-iconv=$(brew --prefix libiconv) \
--with-tidy=$(brew --prefix tidy-html5) \
--with-zlib-dir=$(brew --prefix zlib) \
"
if [ $rpv -lt 70400 ]; then
export PATH="$(brew --prefix [email protected])/bin:$PATH"
export CPPFLAGS="$CPPFLAGS \
-DU_DEFINE_FALSE_AND_TRUE=1 \
-Wno-implicit-function-declaration \
"
fi
if [ $rpv -lt 60000 ]; then
export PHP_BUILD_CONFIGURE_OPTS="$PHP_BUILD_CONFIGURE_OPTS \
--with-curl=$(brew --prefix curl) \
"
fi
phpenv install -f "$PHPENV_VERSION"
if [ -n "$PHPENV_PECLS" ]; then
for pecl in $PHPENV_PECLS; do
pecl install "$pecl"
done
fi
if [ -n "$PHPENV_GLOBAL_PACKAGES" ]; then
for package in $PHPENV_GLOBAL_PACKAGES; do
composer global require "$package"
done
fi
phpenv rehash