Menu

[df5474]: / src / compile.sh  Maximize  Restore  History

Download this file

235 lines (213 with data), 6.6 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
#!/bin/bash
#
# phpfarm
#
# Installs multiple versions of PHP beside each other.
# Both CLI and CGI versions are compiled.
# Sources are fetched from museum.php.net if no
# corresponding file bzips/php-$version.tar.bz2 exists.
#
# Usage:
# ./compile.sh 5.3.1
#
# You should add ../inst/bin to your $PATH to have easy access
# to all php binaries. The executables are called
# php-$version and php-cgi-$version
#
# In case the options in options.sh do not suit you or you just need
# different options for different php versions, you may create
# custom-options-$version.sh scripts that define a $configoptions
# variable. See options.sh for more details.
#
# Put pyrus.phar into bzips/ to automatically get version-specific
# pyrus/pear2 commands.
#
# Author: Christian Weiske <cweiske@php.net>
#
version=$1
vmajor=`echo ${version%%.*}`
vminor=`echo ${version%.*}`
vminor=`echo ${vminor#*.}`
vpatch=`echo ${version##*.}`
vcomp=`printf "%02d%02d%02d\n" $vmajor $vminor $vpatch`
#directory of this file. all php srces are extrated in it
basedir="`dirname "$0"`"
cd "$basedir"
basedir=`pwd`
#directory of php sources of specific version
srcdir="php-$version"
#directory with source archives
bzipsdir='bzips'
#directory phps get installed into
instbasedir="`readlink -f "$basedir/../inst"`"
#directory this specific version gets installed into
instdir="$instbasedir/php-$version"
#directory where all bins are symlinked
shbindir="$instbasedir/bin"
#we need a php version
if [ "x$version" = 'x' ]; then
echo 'Please specify php version'
exit 1
fi
#already extracted?
if [ ! -d "$srcdir" ]; then
echo 'Source directory does not exist; trying to extract'
srcfile="$bzipsdir/php-$version.tar.bz2"
if [ ! -f "$srcfile" ]; then
echo 'Source file not found:'
echo "$srcfile"
url="http://museum.php.net/php$vmajor/php-$version.tar.bz2"
wget -P "$bzipsdir" "$url"
if [ ! -f "$srcfile" ]; then
echo "Fetching sources from museum failed"
echo $url
#museum failed, now we try real download
url="http://www.php.net/get/php-$version.tar.bz2/from/this/mirror"
wget -P "$bzipsdir" -O "$srcfile" "$url"
fi
if [ ! -s "$srcfile" -a -f "$srcfile" ]; then
rm "$srcfile"
fi
if [ ! -f "$srcfile" ]; then
echo "Fetching sources from official download site failed"
echo $url
#use ilia's RC (5.3.x)
url="https://downloads.php.net/ilia/php-$version.tar.bz2"
wget -P "$bzipsdir" -O "$srcfile" "$url"
fi
if [ ! -s "$srcfile" -a -f "$srcfile" ]; then
rm "$srcfile"
fi
if [ ! -f "$srcfile" ]; then
echo "Fetching sources from ilia's site failed"
echo $url
#use stas's RC (5.4.x)
url="https://downloads.php.net/stas/php-$version.tar.bz2"
wget -P "$bzipsdir" -O "$srcfile" "$url"
fi
if [ ! -s "$srcfile" -a -f "$srcfile" ]; then
rm "$srcfile"
fi
if [ ! -f "$srcfile" ]; then
echo "Fetching sources from ilia's site failed"
echo $url
#use dsp's RC (5.5.x)
url="https://downloads.php.net/dsp/php-$version.tar.bz2"
wget -P "$bzipsdir" -O "$srcfile" "$url"
fi
if [ ! -s "$srcfile" -a -f "$srcfile" ]; then
rm "$srcfile"
fi
if [ ! -f "$srcfile" ]; then
echo "Fetching sources failed:"
echo $url
exit 2
fi
fi
#extract
tar xjvf "$srcfile"
fi
source 'options.sh' "$version" "$vmajor" "$vminor" "$vpatch"
cd "$srcdir"
#configuring
#TODO: do not configure when config.nice exists
if [ ! -f configure ]; then
./buildconf
fi
./configure \
--prefix="$instdir" \
--exec-prefix="$instdir" \
--enable-debug \
--disable-short-tags \
--without-pear \
$configoptions
if [ $? -gt 0 ]; then
echo configure.sh failed.
exit 3
fi
#compile sources
#make clean
make
if [ "$?" -gt 0 ]; then
echo make failed.
exit 4
fi
make install
if [ "$?" -gt 0 ]; then
echo make install failed.
exit 5
fi
#copy php.ini
#you can define your own ini target directory by setting $initarget
if [ "x$initarget" = x ]; then
initarget="$instdir/lib/php.ini"
fi
if [ -f "php.ini-development" ]; then
#php 5.3
cp "php.ini-development" "$initarget"
elif [ -f "php.ini-recommended" ]; then
#php 5.1, 5.2
cp "php.ini-recommended" "$initarget"
else
echo "No php.ini file found."
echo "Please copy it manually to $instdir/lib/php.ini"
fi
#set default ini values
cd "$basedir"
if [ -f "$initarget" ]; then
#fixme: make the options unique or so
custom="custom-php.ini"
[ ! -f $custom ] && cp "default-custom-php.ini" "$custom"
versionreplace="s/\$version/$version/"
[ -f $custom ] && cat "$custom" | sed $versionreplace >> "$initarget"
custom="custom-php-$vmajor.ini"
[ -f $custom ] && cat "$custom" | sed $versionreplace >> "$initarget"
custom="custom-php-$vmajor.$vminor.ini"
[ -f $custom ] && cat "$custom" | sed $versionreplace >> "$initarget"
custom="custom-php-$vmajor.$vminor.$vpatch.ini"
[ -f $custom ] && cat "$custom" | sed $versionreplace >> "$initarget"
fi
#create bin
[ ! -d "$shbindir" ] && mkdir "$shbindir"
if [ ! -d "$shbindir" ]; then
echo "Cannot create shared bin dir"
exit 6
fi
#symlink all files
#php may be called php.gcno or php.dSYM (Mac OS X)
bphp="$instdir/bin/php"
bphpgcno="$instdir/bin/php.gcno"
bphpdsym="$instdir/bin/php.dSYM"
#we want to keep the "nice" name for pyrus and for switch-phpfarm
if [ -f "$bphpgcno" ]; then
mv "$bphpgcno" "$bphp"
elif [ -f "$bphpdsym" ]; then
mv "$bphpdsym" "$bphp"
fi
if [ -f "$bphp" ]; then
ln -fs "$bphp" "$shbindir/php-$version"
else
echo "no php binary found"
exit 7
fi
#php-cgi may be called php-cgi.gcno or php-cgi.dSYM (Mac OS X)
bphpcgi="$instdir/bin/php-cgi"
bphpcgigcno="$instdir/bin/php-cgi.gcno"
bphpcgidsym="$instdir/bin/php-cgi.dSYM"
if [ -f "$bphpcgigcno" ]; then
mv "$bphpcgigcno" "$bphpcgi"
elif [ -f "$bphpcgidsym" ]; then
mv "$bphpcgidsym" "$bphpcgi"
fi
if [ -f "$bphpcgi" ]; then
ln -fs "$bphpcgi" "$shbindir/php-cgi-$version"
else
echo "no php-cgi binary found"
exit 8
fi
ln -fs "$instdir/bin/php-config" "$shbindir/php-config-$version"
ln -fs "$instdir/bin/phpize" "$shbindir/phpize-$version"
if [ $vmajor -gt 5 ] || [ $vmajor -eq 5 -a $vminor -gt 2 ]; then
cd "$basedir"
./pyrus.sh "$version" "$instdir"
fi
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.