source: trunk/dports/lang/php52/Portfile @ 68370

Last change on this file since 68370 was 68370, checked in by ryandesign@…, 10 years ago

php52: fix build failure with gettext 0.18; see #24934

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 17.0 KB
Line 
1# $Id: Portfile 68370 2010-06-02 07:18:39Z ryandesign@macports.org $
2
3PortSystem              1.0
4
5name                    php52
6conflicts               php5 php5-devel php5-gd php5-iconv php5-mbstring php5-sqlite
7version                 5.2.13
8revision        1
9set major               [lindex [split ${version} .] 0]
10set my_name             php${major}
11dist_subdir             ${my_name}
12categories              lang php www
13maintainers             ryandesign jwa
14homepage                http://www.php.net/
15master_sites            php
16distname                php-${version}
17use_bzip2               yes
18platforms               darwin freebsd
19use_parallel_build      yes
20
21description \
22    PHP: Hypertext Preprocessor
23
24long_description \
25    PHP is a widely-used general-purpose scripting language \
26    that is especially suited for developing web sites, but can also \
27    be used for command-line scripting.
28
29checksums \
30    [suffix ${distname}] \
31    md5     eb4d0766dc4fb9667f05a68b6041e7d1 \
32    sha1    7127a21f1b493e3cd43f45cadecdb46b623eb1fb \
33    rmd160  9e21d32a7b757d25ed827834b26235ea1eebfcc8
34
35depends_build \
36    port:pkgconfig \
37    port:autoconf213
38
39depends_lib \
40    path:bin/gsed:gsed \
41    port:libtool \
42    port:libxml2 \
43    port:libxslt \
44    port:openssl \
45    port:zlib \
46    port:bzip2 \
47    port:libiconv \
48    port:expat \
49    port:gettext \
50    port:tiff \
51    port:mhash \
52    port:libmcrypt \
53    port:curl \
54    port:pcre \
55    port:jpeg \
56    port:libpng \
57    port:freetype
58
59# Use -p1 to accommodate the Suhosin patch
60patch.pre_args          -p1
61patchfiles \
62    patch-ext-standard-string.c.diff \
63    patch-scripts-php-config.in.diff \
64    patch-bind.diff
65
66use_autoconf            yes
67autoconf.cmd            ${prefix}/bin/autoconf213
68
69set phpinidir           ${prefix}/etc/${my_name}
70set extraphpinidir      ${prefix}/var/db/${my_name}
71
72destroot.keepdirs       ${destroot}${extraphpinidir}
73
74configure.args \
75    --mandir=${prefix}/share/man \
76    --infodir=${prefix}/share/info \
77    --with-config-file-path=${phpinidir} \
78    --with-config-file-scan-dir=${extraphpinidir} \
79    --enable-calendar \
80    --with-iconv=${prefix} \
81    --enable-exif \
82    --enable-ftp \
83    --enable-wddx\
84    --with-zlib=${prefix} \
85    --with-bz2=${prefix} \
86    --without-mysql \
87    --without-sqlite \
88    --without-pdo-sqlite \
89    --with-libxml-dir=${prefix} \
90    --with-gettext=${prefix} \
91    --with-libexpat-dir=${prefix} \
92    --with-xmlrpc \
93    --enable-soap \
94    --enable-bcmath \
95    --enable-mbstring \
96    --enable-dba \
97    --enable-zip \
98    --with-openssl=${prefix} \
99    --with-mhash=${prefix} \
100    --with-mcrypt=${prefix} \
101    --with-mime-magic \
102    --with-xsl=${prefix} \
103    --with-curl=${prefix} \
104    --with-pcre-regex=${prefix} \
105    --with-gd \
106    --with-jpeg-dir=${prefix} \
107    --with-png-dir=${prefix} \
108    --enable-gd-native-ttf \
109    --without-pear \
110    --with-freetype-dir=${prefix}
111
112configure.universal_args-delete --disable-dependency-tracking
113
114platform darwin 10 {
115    configure.env-append \
116        LIBS=-lresolv
117}
118
119platform macosx {
120    configure.args-append \
121        --with-ldap=/usr \
122        --with-kerberos=/usr \
123        --with-iodbc=/usr
124}
125
126variant no_web conflicts apache apache2 fastcgi description {Don't include any web server support} {}
127
128# Build an Apache 1 module. On Mac OS X, it uses Apple's provided Apache 1 server.
129# On other platforms, the MacPorts apache port is used. Keep the options here
130# in sync with those in the relevant part of the post-destroot phase.
131variant apache conflicts apache2 no_web description {Add Apache 1 web server module} {
132    if { ! [variant_isset macosx] && (![info exists os.subplatform] || ${os.subplatform} != "macosx") } {
133        depends_lib-append \
134            port:apache
135        configure.args-append \
136            --with-apxs=${prefix}/sbin/apxs
137    } else {
138        destroot.violate_mtree yes
139        configure.args-append \
140            --with-apxs=/usr/sbin/apxs
141    }
142}
143
144# Build an Apache 2.2 module. Keep the options here in sync with those in the
145# relevant part of the post-destroot phase.
146variant apache2 conflicts apache no_web description {Add Apache 2.2 web server module} {
147    pre-configure {
148        # Checking for mod_cgi.so is a convenient way to verify apache2 is using its
149        # +preforkmpm variant. (+eventmpm and +workermpm instead provide mod_cgid.so.)
150        if {![file exists ${prefix}/apache2/modules/mod_cgi.so]} {
151            ui_error "To use ${name} with the +apache2 variant, apache2 must be installed with the +preforkmpm variant."
152            return -code error "incompatible apache2 installation"
153        }
154    }
155    destroot.violate_mtree yes
156    depends_lib-append \
157        port:apache2
158    configure.args-append \
159        --with-apxs2=${prefix}/apache2/bin/apxs
160}
161
162# Build a FastCGI binary. Keep the options here in sync with those in the
163# relevant part of the post-destroot phase.
164variant fastcgi conflicts no_web description {Add FastCGI web server binary} {
165    if { ![variant_isset apache] && ![variant_isset apache2] } {
166        configure.args-append \
167            --enable-fastcgi \
168            --enable-force-cgi-redirect
169    }
170}
171
172variant gmp description {Add GNU MP multiprocessing functions} {
173    depends_lib-append \
174        port:gmp
175    configure.args-append \
176        --with-gmp=${prefix}
177}
178
179variant dbase description {Add dBase file format support} {
180    configure.args-append \
181        --enable-dbase
182}
183
184variant imap description {Add IMAP protocol support} {
185    depends_lib-append \
186        port:cclient
187    configure.args-append \
188        --with-imap=${prefix} \
189        --with-imap-ssl=${prefix}
190}
191
192variant pspell description {Add pspell spell-checking functions} {
193    depends_lib-append \
194        port:aspell
195    configure.args-append \
196        --with-pspell=${prefix}
197}
198
199variant tidy description {Add Tidy support} {
200    depends_lib-append \
201        port:tidy
202    configure.args-append \
203        --with-tidy=${prefix}
204}
205
206variant mssql description {Add MS-SQL server support} {
207    depends_lib-append \
208        port:freetds
209    configure.args-append \
210        --with-mssql=${prefix} \
211        --with-pdo-dblib=${prefix}
212   
213    # See http://bugs.php.net/bug.php?id=44991
214    post-patch {
215        reinplace "s|tds.h|sybdb.h|g"               ${worksrcpath}/ext/mssql/config.m4
216        reinplace "s|libtds.a|libsybdb.a|g"         ${worksrcpath}/ext/mssql/config.m4
217        reinplace "s|libtds.so|libsybdb.dylib|g"    ${worksrcpath}/ext/mssql/config.m4
218    }
219}
220
221variant snmp conflicts macports_snmp description {Add SNMP support using Apple SNMP} {
222    # This compiles PHP5 with SNMP linked against Apple's included NET-SNMP.
223    configure.args-append \
224        --with-snmp=/usr
225}
226
227variant macports_snmp conflicts snmp description {Add SNMP support using MacPorts SNMP} {
228    # This compiles PHP with SNMP linked against MacPorts' NET-SNMP.
229    depends_lib-append \
230        port:net-snmp
231    configure.args-append \
232        --with-snmp=${prefix}
233}
234
235variant mysql4 conflicts mysql5 description {Add MySQL 4 support} {
236    depends_lib-append \
237        port:mysql4
238    configure.args-delete \
239        --without-mysql
240    configure.args-append \
241        --with-mysql=${prefix} \
242        --with-pdo-mysql=${prefix}
243}
244
245variant mysql5 conflicts mysql4 description {Add MySQL 5 support} {
246    depends_lib-append \
247        path:bin/mysql_config5:mysql5
248    configure.args-delete \
249        --without-mysql
250    configure.args-append \
251        --with-mysql=${workpath}/mysql5 \
252        --with-pdo-mysql=${prefix}/bin/mysql_config5 \
253        --with-mysql-sock=${prefix}/var/run/mysql5/mysqld.sock \
254        --with-mysqli=${prefix}/bin/mysql_config5
255    post-extract {
256        file mkdir "${workpath}/mysql5"
257        file link -symbolic "${workpath}/mysql5/lib" "${prefix}/lib/mysql5"
258        file link -symbolic "${workpath}/mysql5/include" "${prefix}/include/mysql5"
259    }
260}
261
262variant oracle description {Add Oracle oci8 database functions with the Oracle Instant Client} {
263    patchfiles-append \
264        patch-ext-pdo_oci-config.m4.diff
265    depends_lib-append \
266        port:oracle-instantclient
267    configure.args-append \
268        --with-oci8=instantclient,${prefix}/lib/oracle \
269        --with-pdo-oci=instantclient,${prefix}/lib/oracle,10.1
270}
271
272variant postgresql82 conflicts postgresql83 postgresql84 description {Add PostgreSQL 8.2 support} {
273    depends_lib-append \
274        port:postgresql82
275    configure.args-append \
276        --with-pgsql=${prefix}/lib/postgresql82/bin \
277        --with-pdo-pgsql=${prefix}/lib/postgresql82/bin
278}
279
280variant postgresql83 conflicts postgresql82 postgresql84 description {Add PostgreSQL 8.3 support} {
281    depends_lib-append \
282        port:postgresql83
283    configure.args-append \
284        --with-pgsql=${prefix}/lib/postgresql83/bin \
285        --with-pdo-pgsql=${prefix}/lib/postgresql83/bin
286}
287
288variant postgresql84 conflicts postgresql82 postgresql83 description {Add PostgreSQL 8.4 support} {
289    depends_lib-append \
290        port:postgresql84
291    configure.args-append \
292        --with-pgsql=${prefix}/lib/postgresql84/bin \
293        --with-pdo-pgsql=${prefix}/lib/postgresql84/bin
294}
295
296# note that standard sqlite support uses the built-in sqlite2 libraries
297# while pdo sqlite support uses the sqlite3 libraries from the sqlite3 port
298variant sqlite description {Add SQLite support} {
299    depends_lib-append \
300        port:sqlite3
301    configure.args-delete \
302        --without-sqlite \
303        --without-pdo-sqlite
304    configure.args-append \
305        --with-sqlite \
306        --with-pdo-sqlite=${prefix} \
307        --enable-sqlite-utf8
308}
309
310variant ipc description {Add semaphore, shared memory and IPC functions} {
311    configure.args-append \
312        --enable-shmop \
313        --enable-sysvsem \
314        --enable-sysvshm \
315        --enable-sysvmsg
316}
317
318variant pcntl description {Add process control functions} {
319    configure.args-append \
320        --enable-pcntl
321}
322
323if {![variant_isset apache] && ![variant_isset apache2] && ![variant_isset fastcgi] && ![variant_isset no_web]} {
324    default_variants +apache2
325}
326
327variant pear description {Add PEAR} {
328    configure.args-delete \
329        --without-pear
330    configure.args-append \
331        --with-pear=${prefix}/lib/php
332    destroot.target-append \
333        install-pear
334    destroot.args-append \
335        PHP_PEAR_INSTALL_DIR=${prefix}/lib/php
336    post-destroot {
337        #nuke pear-stuff in ${destroot}
338        system "cd ${destroot} && rm -rf .channels .depdb .depdblock .filemap .lock"
339       
340        system "if \[ -f ${prefix}/lib/php/.depdblock \]; then rm -f ${destroot}${prefix}/lib/php/.depdblock; fi"
341        system "if \[ -f ${prefix}/lib/php/.depdb \]; then rm -f ${destroot}${prefix}/lib/php/.depdb; fi"
342        system "if \[ -f ${prefix}/lib/php/.filemap \]; then rm -f ${destroot}${prefix}/lib/php/.filemap; fi"
343        system "if \[ -f ${prefix}/lib/php/.lock \]; then rm -f ${destroot}${prefix}/lib/php/.lock; fi"
344        system "if \[ -d ${prefix}/lib/php/.channels \]; then rm -rf ${destroot}${prefix}/lib/php/.channels; fi"
345    }
346}
347
348variant readline description {Add GNU readline functions} {
349    depends_lib-append \
350        port:readline
351    configure.args-append \
352        --with-readline=${prefix}
353}
354
355variant sockets description {Add socket communication functions} {
356    configure.args-append \
357        --enable-sockets
358}
359
360variant t1lib description {Add PostScript Type 1 font support with t1lib} {
361    depends_lib-append \
362        port:t1lib
363    configure.args-append \
364        --with-t1lib=${prefix}
365}
366
367variant suhosin description {Add Suhosin patch} {
368    pre-fetch {
369        if {"darwin" == ${os.platform} && ${os.major} < 9} {
370            ui_error "The suhosin variant requires Mac OS X 10.5 or greater."
371            return -code error "incompatible Mac OS X version"
372        }
373    }
374    #set suhosin_patch_version   ${version}-0.9.7
375    set suhosin_patch_version   5.2.11-0.9.7
376    set suhosin_patch           suhosin-patch-${suhosin_patch_version}.patch.gz
377    patch_sites-append          http://download.suhosin.org/
378    patchfiles-append           ${suhosin_patch}
379    checksums-append \
380        ${suhosin_patch} \
381            md5     8f9de4d97fae6eba163cf3699509a260 \
382            sha1    248419332131efc53f3306c2a57a4b1a9dc92cc1 \
383            rmd160  0f6d442aace34c221f9fbff42a63e7f3b4489f15
384}
385
386destroot.args \
387    INSTALL_ROOT=${destroot}
388
389destroot.target \
390    install-cli install-build install-headers install-programs
391
392post-destroot {
393    # Copy the Apache 1 module.
394    if { [variant_isset apache] } {
395        xinstall -m 755 -d ${destroot}${prefix}/libexec/apache \
396            ${destroot}${prefix}/etc/apache/extra
397        xinstall -m 755 ${worksrcpath}/libs/libphp5.so ${destroot}${prefix}/libexec/apache/
398        xinstall -m 755 -c ${filespath}/mod_php.conf ${destroot}$prefix/etc/apache/extra
399    }
400   
401    # Copy the Apache 2.2 module.
402    if { [variant_isset apache2] } {
403        xinstall -m 755 -d ${destroot}${prefix}/apache2/modules \
404            ${destroot}${prefix}/apache2/conf/extra
405        xinstall -m 755 ${worksrcpath}/libs/libphp5.so ${destroot}${prefix}/apache2/modules/
406        xinstall -m 755 -c ${filespath}/mod_php.conf ${destroot}${prefix}/apache2/conf/extra
407    }
408   
409    if { [variant_isset fastcgi] } {
410        # If we've built an Apache module (any version) then the FastCGI binary
411        # will not have been built, so we need to run through the whole process
412        # again and build just the FastCGI binary. Keep the options here in sync
413        # with the options specified in the apache and apache2 variants.
414        if { [variant_isset apache] } {
415            if { ![variant_isset macosx] && (![info exists os.subplatform] || ${os.subplatform} != "macosx") } {
416                configure.args-delete \
417                    --with-apxs=${prefix}/sbin/apxs
418            } else {
419                configure.args-delete \
420                    --with-apxs=/usr/sbin/apxs
421            }
422        }
423        if { [variant_isset apache2] } {
424            configure.args-delete \
425                --with-apxs2=${prefix}/apache2/bin/apxs
426        }
427       
428        # Run the build again to get the FastCGI binary. Keep the options here
429        # in sync with those in the fastcgi variant.
430        if { [variant_isset apache] || [variant_isset apache2] } {
431            configure.args-append \
432                --enable-fastcgi \
433                --enable-force-cgi-redirect
434            ui_msg "$UI_PREFIX Configuring ${name} again for fastcgi"
435            command_exec configure
436            ui_msg "$UI_PREFIX Building ${name} again for fastcgi"
437            command_exec build
438            ui_msg "$UI_PREFIX Staging ${name} fastcgi into destroot"
439        }
440       
441        # Copy the FastCGI binary to the bin dir under a new name so it doesn't
442        # conflict with the cli version.
443        xinstall -m 755 ${worksrcpath}/sapi/cgi/php-cgi ${destroot}${prefix}/bin
444    }
445   
446    #file rename ${destroot}${prefix}/etc/pear.conf ${destroot}${prefix}/etc/pear.conf.sample
447   
448    # Copy the default php.ini files.
449    xinstall -m 755 -d ${destroot}${phpinidir}
450    xinstall -m 644 -W ${worksrcpath} \
451        php.ini-dist \
452        php.ini-recommended \
453        ${destroot}${phpinidir}
454}
455
456pre-activate {
457    set filepath ${extraphpinidir}/.turd_${name}
458    if {[file exists ${filepath}]} {
459        delete ${filepath}
460    }
461}
462
463post-activate {
464    if {[file exists ${prefix}/etc/php.ini] && ![file exists ${phpinidir}/php.ini]} {
465        move ${prefix}/etc/php.ini ${phpinidir}
466        ui_msg "Your ${prefix}/etc/php.ini has been moved to ${phpinidir}/php.ini"
467        ui_msg ""
468    }
469    if {![file exists ${phpinidir}/php.ini]} {
470        ui_msg "To customize php, copy"
471        ui_msg "${phpinidir}/php.ini-dist (if this is a development server) or"
472        ui_msg "${phpinidir}/php.ini-recommended (if this is a production server) to"
473        ui_msg "${phpinidir}/php.ini and then make changes."
474    } else {
475        ui_msg "You may need to update your php.ini for any changes that have been made"
476        ui_msg "in this version of php. Compare ${phpinidir}/php.ini with"
477        ui_msg "${phpinidir}/php.ini-dist (if this is a development server) or"
478        ui_msg "${phpinidir}/php.ini-recommended (if this is a production server)."
479    }
480   
481    if {![variant_isset no_web]} {
482        ui_msg ""
483        ui_msg "If this is your first install, you need to activate PHP in your web server."
484        if {![variant_isset fastcgi]} {
485            if {[variant_isset apache]} {
486                set moduledir ${prefix}/libexec/modules
487                set apxs ${prefix}/apache/bin/apxs
488            }
489            if {[variant_isset apache2]} {
490                set moduledir ${prefix}/apache2/modules
491                set apxs ${prefix}/apache2/bin/apxs
492            }
493            ui_msg ""
494            ui_msg "To enable PHP in Apache, run"
495            ui_msg "  cd ${moduledir}"
496            ui_msg "  ${apxs} -a -e -n \"${my_name}\" lib${my_name}.so"
497        }
498    }
499   
500    #ui_msg "* copy  ${prefix}/etc/pear.conf.sample to  ${prefix}/etc/pear.conf"
501}
502
503variant debug description {Enable debug support (useful to analyze a PHP-related core dump)} {
504    configure.args-append   --enable-debug
505}
506
507test.run                yes
508
509livecheck.type          regex
510livecheck.url           ${homepage}downloads.php
511livecheck.regex         get/php-(5\\.2\\.\[0-9.\]+)\\.tar
Note: See TracBrowser for help on using the repository browser.