blob: 16f2f4d52091925990bf864e91404a323b2df9b2 (
plain)
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
|
#
# Maintainer: Michael Rynn <michael.rynn@parracan.org>
# Contributor: wolftankk <wolftankk@gmail.com>
php_suffix="70" # This mutation
php_ext="phalcon"
pkgname="php${php_suffix}-${php_ext}"
pkgver=3.3.2
pkgrel=1
pkgdesc="PHP Extension package for a faster web site framework."
url="http://phalconphp.com"
arch=('x86_64' 'i686')
[[ $CARCH == 'i686' ]] && _arch=32bits || _arch=64bits
license=('PHP')
depends=("php${php_suffix}")
makedepends=('gcc')
source=(
"https://github.com/phalcon/cphalcon/archive/v$pkgver.zip"
)
sha256sums=(
'1f5bd8d0d43762e4177716342adcfeb71df2859f78a56bed9c66040bb293dbf3'
)
# find which accessible php-config[suffix], use in
# makepkg not meant to be interactive. Assume this PKGBUILD stays in AUR
# locate php-config[suffix], get options
# xdebug build uses phpize[suffix]
php_select()
{
declare -a php_configy # paths
# pass a folder to be searched for any php-config*
findconfig()
{
local _myglob="$1/php-config${php_suffix}*"
for f in $_myglob;
do
if [ "$f" != "$_myglob" ]; then
php_configy+=("$f")
fi
done
}
binpath="${PATH}"
re='([^:]+):(.*)'
while [[ $binpath =~ $re ]]
do
bindir="${BASH_REMATCH[1]}"
binpath="${BASH_REMATCH[2]}"
findconfig $bindir
done
if [[ -n $binpath ]]; then
findconfig $binpath
fi
# see how many we have
optct="${#php_configy[@]}"
# if only one, do automatic??
if [[ $optct -lt "1" ]]; then
echo "No php-config* found"
exit -1
elif [[ $optct -eq "1" ]]; then
php_config="${php_configy[0]}"
else
declare -a php_options # assemble user menu
optct=0
php_options+=("0) Get me out of here!")
for cfg in "${php_configy[@]}";
do
let optct='((optct+1))'
PHP_FULL_VERSION=`${cfg} --version`
php_options+=("${optct}) ${cfg} (php-${PHP_FULL_VERSION})")
done
echo
echo "More than one php-config found. Select:"
echo
for opt in "${php_options[@]}"; do
echo $opt
done
echo
read -p "Which php-config do you want? " choice
numbers='[0-9]+$'
if ! [[ "${choice}" =~ $numbers ]]; then
echo "bye"
exit
fi
if [[ ( "${choice}" -gt "$optct" ) || ( "${choice}" -lt "1" ) ]]; then
echo "OK"
exit
fi
let choice='((choice-1))'
php_config="${php_configy[$choice]}"
fi
#get some config options, assumable from php70
all_options=`${php_config} --configure-options`
declare -A config_options # AA for key lookup
attre='--([^=]+)=(.*)'
for option in $all_options; do
[[ $option =~ $attre ]] && vname="${BASH_REMATCH[1]}" && nvalue="${BASH_REMATCH[2]}"
config_options[$vname]=$nvalue
done
PHP_FULL_VERSION=`${php_config} --version`
PHP_VERSION="${PHP_FULL_VERSION%%.*}"
#get php version
PHP_MINOR_VERSION="${PHP_FULL_VERSION%.*}"
if [[ "${PHP_VERSION}" == "7" ]]; then
if [ $(echo " $PHP_MINOR_VERSION >= 7.1" | bc) -eq 1 ]; then
echo "Phalcon not yet supported for php > 7.0"
exit
fi
fi
PHALCON_BUILD="php${PHP_VERSION}"
# export so makepkg remembers. PHP-build dependent
export PHPCONFIG_SCANDIR="${config_options[with-config-file-scan-dir]#/*}"
export PHPIZE_CMD="phpize${config_options[program-suffix]}"
export PHPCONFIG_CMD="${php_config}"
export PHALCON_BUILD
}
prepare()
{
echo "PHALCON_BUILD is ${PHALCON_BUILD}"
echo "_arch is $_arch"
}
build() {
cd "$srcdir/cphalcon-$pkgver"
#Check best compilation flags for GCC
export CC="gcc"
export CFLAGS="-march=native -mtune=native -O2 -fomit-frame-pointer"
export CPPFLAGS="-DPHALCON_RELEASE"
echo 'int main() {}' > t.c
$CC $CFLAGS t.c -o t 2> t.t
if [ $? != 0 ]; then
chmod +x gcccpuopt
BFLAGS=`./gcccpuopt`
export CFLAGS="-O2 -fomit-frame-pointer $BFLAGS"
$CC $CFLAGS t.c -o t 2> t.t
if [ $? != 0 ]; then
export CFLAGS="-O2"
fi
fi
if [ $($CC -dumpversion | cut -f1 -d.) -ge 4 ]; then
$CC $CFLAGS -fvisibility=hidden t.c -o t 2> t.t && export CFLAGS="$CFLAGS -fvisibility=hidden"
fi
rm -f t.t t.c t
#cd dir
cd "$srcdir/cphalcon-$pkgver/build/$PHALCON_BUILD/$_arch"
#Clean current compilation
if [ -f Makefile ]; then
make clean
$PHPIZE_CMD --clean
fi
$PHPIZE_CMD
./configure --prefix=/usr --enable-phalcon
make
}
package() {
backup=("${PHPCONFIG_SCANDIR}/phalcon.ini")
cd "$srcdir/cphalcon-$pkgver/build/$PHALCON_BUILD/$_arch"
make INSTALL_ROOT="$pkgdir" install
echo 'extension=phalcon.so' > phalcon.ini
install -Dm644 phalcon.ini "$pkgdir/${PHPCONFIG_SCANDIR}/phalcon.ini"
}
if [[ -z $PHALCON_BUILD ]]; then
php_select
fi
|