Ticket #37475: Portfile

File Portfile, 14.8 KB (added by rscorer@…, 11 years ago)

Portfile for PHP5

Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 71588 2010-09-17 05:21:24Z ryandesign@macports.org $
3
4PortSystem              1.0
5
6name                    php5
7conflicts               php5-devel php52
8# Keep version of php5 in sync with bundled php5 extension ports.
9# Increment revision of php5-eaccelerator when updating version of php5.
10epoch                   1
11version                 5.3.20
12revision                2
13set major               [lindex [split ${version} .] 0]
14set my_name             php${major}
15dist_subdir             ${my_name}
16categories              lang php www
17maintainers             ryandesign jwa
18platforms               darwin freebsd
19license                 PHP-3.01
20use_parallel_build      yes
21
22description             PHP: Hypertext Preprocessor
23
24long_description        PHP is a widely-used general-purpose scripting \
25                        language that is especially suited for developing \
26                        web sites, but can also be used for command-line \
27                        scripting.
28
29homepage                http://www.php.net/
30master_sites            php
31
32distname                php-${version}
33use_bzip2               yes
34
35checksums \
36    [suffix ${distname}] \
37    md5     00241b9e89e93adf3baac32c56211e4e \
38    sha1    64d505884bc43ae3bf1f50c1d4b1cc4a8b749962 \
39    rmd160  e50668e3376b8790cf47f3b6cd91e4a7004f5cd5
40
41depends_build           port:pkgconfig \
42                        port:autoconf213
43
44depends_lib             path:bin/gsed:gsed \
45                        port:libtool \
46                        port:libevent \
47                        port:libxml2 \
48                        port:bzip2 \
49                        port:mhash \
50                        port:pcre \
51                        port:readline \
52                        port:zlib
53
54# Use -p1 to accommodate the Suhosin patch
55patch.pre_args          -p1
56patchfiles              patch-configure.in.diff \
57                        patch-scripts-php-config.in.diff
58
59use_autoconf            yes
60autoconf.cmd            ${prefix}/bin/autoconf213
61
62set phpinidir           ${prefix}/etc/${my_name}
63set extraphpinidir      ${prefix}/var/db/${my_name}
64
65destroot.keepdirs       ${destroot}${extraphpinidir}
66
67if {${configure.compiler} == "clang"} {
68    configure.compiler llvm-gcc-4.2
69}
70
71configure.args          --mandir=${prefix}/share/man \
72                        --infodir=${prefix}/share/info \
73                        --with-config-file-path=${phpinidir} \
74                        --with-config-file-scan-dir=${extraphpinidir} \
75                        --disable-all \
76                        --enable-bcmath \
77                        --enable-ctype \
78                        --enable-dom \
79                        --enable-fileinfo \
80                        --enable-filter \
81                        --enable-hash \
82                        --enable-json \
83                        --enable-libxml \
84                        --enable-pdo \
85                        --enable-phar \
86                        --enable-session \
87                        --enable-simplexml \
88                        --enable-tokenizer \
89                        --enable-xml \
90                        --enable-xmlreader \
91                        --enable-xmlwriter \
92                        --with-bz2=${prefix} \
93                        --with-mhash=${prefix} \
94                        --with-pcre-regex=${prefix} \
95                        --with-readline=${prefix} \
96                        --with-libxml-dir=${prefix} \
97                        --with-zlib=${prefix} \
98                        --without-pear \
99                        --disable-cgi
100
101# php5-mysql +mysqlnd needs mysqlnd support compiled into php
102configure.env-append    PHP_MYSQLND_ENABLED=yes
103
104configure.universal_args-delete --disable-dependency-tracking
105
106platform darwin 10 {
107    configure.env-append LIBS=-lresolv
108}
109
110variant no_web conflicts apache apache2 fastcgi description {Don't include any web server support} {}
111
112# Build an Apache 1 module. On Mac OS X, it uses Apple's provided Apache 1 server.
113# On other platforms, the MacPorts apache port is used. Keep the options here
114# in sync with those in the relevant part of the post-destroot phase.
115variant apache conflicts apache2 no_web description {Add Apache 1 web server module} {
116    if { ! [variant_isset macosx] && (![info exists os.subplatform] || ${os.subplatform} != "macosx") } {
117        depends_lib-append \
118            port:apache
119        configure.args-append \
120            --with-apxs=${prefix}/sbin/apxs
121    } else {
122        destroot.violate_mtree yes
123        configure.args-append \
124            --with-apxs=/usr/sbin/apxs
125    }
126}
127
128# Build an Apache 2.2 module. Keep the options here in sync with those in the
129# relevant part of the post-destroot phase.
130variant apache2 conflicts apache no_web description {Add Apache 2.2 web server module} {
131    pre-configure {
132        # Checking for mod_cgi.so is a convenient way to verify apache2 is using its
133        # +preforkmpm variant. (+eventmpm and +workermpm instead provide mod_cgid.so.)
134        if {![file exists ${prefix}/apache2/modules/mod_cgi.so]} {
135            ui_error "To use ${name} with the +apache2 variant, apache2 must be installed with the +preforkmpm variant."
136            return -code error "incompatible apache2 installation"
137        }
138    }
139    destroot.violate_mtree yes
140    depends_lib-append \
141        port:apache2
142    configure.args-append \
143        --with-apxs2=${prefix}/apache2/bin/apxs
144}
145
146# Build a FastCGI binary. Keep the options here in sync with those in the
147# relevant part of the post-destroot phase.
148variant fastcgi conflicts no_web description {Add FastCGI web server binary} {
149    if { ![variant_isset apache] && ![variant_isset apache2] } {
150        configure.args-delete \
151            --disable-cgi
152        configure.args-append \
153            --enable-cgi \
154            --enable-fpm \
155            --with-fpm-user=_www \
156            --with-fpm-group=_www
157    }
158    startupitem.create      yes
159    startupitem.name        php-fpm
160    startupitem.executable  ${prefix}/bin/php-fpm
161    startupitem.pidfile     auto ${prefix}/var/run/php-fpm.pid
162}
163
164foreach {old_variant new_port} {
165    gmp             gmp
166    imap            imap
167    macports_snmp   snmp
168    mssql           mssql
169    mysql4          mysql
170    mysql5          mysql
171    mysqlnd         mysql
172    oracle          oracle
173    pcntl           pcntl
174    postgresql82    postgresql
175    postgresql83    postgresql
176    pspell          pspell
177    snmp            snmp
178    sockets         sockets
179    sqlite          sqlite
180    tidy            tidy
181} {
182    eval [subst {
183        variant ${old_variant} description "Obsolete; install ${my_name}-${new_port} port instead" {
184            pre-configure {
185                ui_msg "The +${old_variant} variant is obsolete. Please install the ${my_name}-${new_port} port instead."
186            }
187        }
188    }]
189}
190
191variant ipc description {Add semaphore, shared memory and IPC functions} {
192    configure.args-append \
193        --enable-shmop \
194        --enable-sysvsem \
195        --enable-sysvshm \
196        --enable-sysvmsg
197}
198
199if {![variant_isset apache] && ![variant_isset apache2] && ![variant_isset fastcgi] && ![variant_isset no_web]} {
200    default_variants +apache2
201}
202
203variant pear description {Add PEAR} {
204    configure.args-delete \
205        --without-pear
206    configure.args-append \
207        --with-pear=${prefix}/lib/php
208    destroot.target-append \
209        install-pear
210    destroot.args-append \
211        PHP_PEAR_INSTALL_DIR=${prefix}/lib/php
212    post-destroot {
213        #nuke pear-stuff in ${destroot}
214        system -W ${destroot} "rm -rf .channels .depdb .depdblock .filemap .lock"
215
216        system "if \[ -f ${prefix}/lib/php/.depdblock \]; then rm -f ${destroot}${prefix}/lib/php/.depdblock; fi"
217        system "if \[ -f ${prefix}/lib/php/.depdb \]; then rm -f ${destroot}${prefix}/lib/php/.depdb; fi"
218        system "if \[ -f ${prefix}/lib/php/.filemap \]; then rm -f ${destroot}${prefix}/lib/php/.filemap; fi"
219        system "if \[ -f ${prefix}/lib/php/.lock \]; then rm -f ${destroot}${prefix}/lib/php/.lock; fi"
220        system "if \[ -d ${prefix}/lib/php/.channels \]; then rm -rf ${destroot}${prefix}/lib/php/.channels; fi"
221    }
222}
223
224variant suhosin description {Add Suhosin patch} {
225    pre-fetch {
226        if {"darwin" == ${os.platform} && ${os.major} < 9} {
227            ui_error "The suhosin variant requires Mac OS X 10.5 or greater."
228            return -code error "incompatible Mac OS X version"
229        }
230        set suhosin_available 1
231        if {!${suhosin_available}} {
232            ui_error "There is no suhosin patch for PHP ${version} yet. Please check back later."
233        }
234        if {![file exists ${prefix}/var/db/php5/suhosin.ini]} {
235            ui_msg "You may also be interested in the suhosin extension, a related but different piece of software. See the php5-suhosin port."
236        }
237        if {!${suhosin_available}} {
238            return -code error "unavailable variant"
239        }
240    }
241    set suhosin_patch_version   ${version}-0.9.10
242    set suhosin_patch           suhosin-patch-${suhosin_patch_version}.patch.gz
243    patch_sites-append          http://download.suhosin.org/
244    patchfiles-append           patch-suhosin-before.diff
245    patchfiles-append           ${suhosin_patch}
246    patchfiles-append           patch-suhosin-after.diff
247    checksums-append            ${suhosin_patch} \
248                                rmd160  ce43921fd9b183b154713ecda98294f6c68d5f22 \
249                                sha256  4438caeab0a10c6c94aee9f7eaa703f5799f97d4e0579f43a947bb7314e38317
250}
251
252destroot.args           INSTALL_ROOT=${destroot}
253
254destroot.target         install-cli install-build install-headers install-programs
255
256post-destroot {
257    # Copy the Apache 1 module.
258    if { [variant_isset apache] } {
259        xinstall -m 755 -d ${destroot}${prefix}/libexec/apache \
260            ${destroot}${prefix}/etc/apache/extra
261        xinstall -m 755 ${worksrcpath}/libs/libphp5.so ${destroot}${prefix}/libexec/apache/
262        xinstall -m 755 -c ${filespath}/mod_php.conf ${destroot}$prefix/etc/apache/extra
263    }
264
265    # Copy the Apache 2.2 module.
266    if { [variant_isset apache2] } {
267        xinstall -m 755 -d ${destroot}${prefix}/apache2/modules \
268            ${destroot}${prefix}/apache2/conf/extra
269        xinstall -m 755 ${worksrcpath}/libs/libphp5.so ${destroot}${prefix}/apache2/modules/
270        xinstall -m 755 -c ${filespath}/mod_php.conf ${destroot}${prefix}/apache2/conf/extra
271    }
272
273    if { [variant_isset fastcgi] } {
274        # If we've built an Apache module (any version) then the FastCGI binary
275        # will not have been built, so we need to run through the whole process
276        # again and build just the FastCGI binary. Keep the options here in sync
277        # with the options specified in the apache and apache2 variants.
278        if { [variant_isset apache] } {
279            if { ![variant_isset macosx] && (![info exists os.subplatform] || ${os.subplatform} != "macosx") } {
280                configure.args-delete \
281                    --with-apxs=${prefix}/sbin/apxs
282            } else {
283                configure.args-delete \
284                    --with-apxs=/usr/sbin/apxs
285            }
286        }
287        if { [variant_isset apache2] } {
288            configure.args-delete \
289                --with-apxs2=${prefix}/apache2/bin/apxs
290        }
291
292        # Run the build again to get the FastCGI binary. Keep the options here
293        # in sync with those in the fastcgi variant.
294        if { [variant_isset apache] || [variant_isset apache2] } {
295            configure.args-delete \
296                --disable-cgi
297            configure.args-append \
298              --enable-cgi \
299              --enable-fpm \
300              --with-fpm-user=_www \
301              --with-fpm-group=_www
302            ui_msg "$UI_PREFIX Configuring ${name} again for fastcgi"
303            command_exec configure
304            ui_msg "$UI_PREFIX Building ${name} again for fastcgi"
305            command_exec build
306            ui_msg "$UI_PREFIX Staging ${name} fastcgi into destroot"
307        }
308
309        # Move the FPM binary to the bin dir
310        xinstall -m 755 ${worksrcpath}/sapi/fpm/php-fpm ${prefix}/bin
311    }
312
313    #file rename ${destroot}${prefix}/etc/pear.conf ${destroot}${prefix}/etc/pear.conf.sample
314
315    # Copy the default php.ini files.
316    xinstall -m 755 -d ${destroot}${phpinidir}
317    xinstall -m 644 -W ${worksrcpath} \
318        php.ini-development \
319        php.ini-production \
320        ${destroot}${phpinidir}
321
322    # Copy mysqlnd headers.
323    xinstall -d ${destroot}${prefix}/include/php/ext/mysqlnd
324    eval xinstall -m 644 [glob ${worksrcpath}/ext/mysqlnd/*.h] ${destroot}${prefix}/include/php/ext/mysqlnd
325}
326
327pre-activate {
328    set filepath ${extraphpinidir}/.turd_${name}
329    if {[file exists ${filepath}]} {
330        delete ${filepath}
331    }
332}
333
334post-activate {
335    if {[file exists ${prefix}/etc/php.ini] && ![file exists ${phpinidir}/php.ini]} {
336        move ${prefix}/etc/php.ini ${phpinidir}
337        ui_msg "Your ${prefix}/etc/php.ini has been moved to ${phpinidir}/php.ini"
338        ui_msg ""
339    }
340    if {![file exists ${phpinidir}/php.ini]} {
341        ui_msg "To customize php, copy"
342        ui_msg "${phpinidir}/php.ini-development (if this is a development server) or"
343        ui_msg "${phpinidir}/php.ini-production (if this is a production server) to"
344        ui_msg "${phpinidir}/php.ini and then make changes."
345    } else {
346        ui_msg "You may need to update your php.ini for any changes that have been made"
347        ui_msg "in this version of php. Compare ${phpinidir}/php.ini with"
348        ui_msg "${phpinidir}/php.ini-development (if this is a development server) or"
349        ui_msg "${phpinidir}/php.ini-production (if this is a production server)."
350    }
351
352    if {[variant_isset fastcgi]} {
353      ui_msg "* copy  ${prefix}/etc/php-fpm.conf.sample to  ${prefix}/etc/php-fpm.conf"
354    }
355
356    if {![variant_isset no_web]} {
357        ui_msg ""
358        ui_msg "If this is your first install, you need to activate PHP in your web server."
359        if {![variant_isset fastcgi]} {
360            if {[variant_isset apache]} {
361                set moduledir ${prefix}/libexec/modules
362                set apxs ${prefix}/apache/bin/apxs
363            }
364            if {[variant_isset apache2]} {
365                set moduledir ${prefix}/apache2/modules
366                set apxs ${prefix}/apache2/bin/apxs
367            }
368            ui_msg ""
369            ui_msg "To enable PHP in Apache, run"
370            ui_msg "  cd ${moduledir}"
371            ui_msg "  ${apxs} -a -e -n \"${my_name}\" lib${my_name}.so"
372        }
373    }
374
375    #ui_msg "* copy  ${prefix}/etc/pear.conf.sample to  ${prefix}/etc/pear.conf"
376}
377
378variant debug description {Enable debug support (useful to analyze a PHP-related core dump)} {
379    configure.args-append   --enable-debug
380}
381
382test.run                yes
383
384livecheck.type          regex
385livecheck.url           ${homepage}downloads.php
386livecheck.regex         get/php-(5\\.\[0-9.\]+)\\.tar