Ticket #17976: Portfile

File Portfile, 15.3 KB (added by tinhkyaw@…, 16 years ago)

Portfile for php5 with a new variant db4

Line 
1# $Id: Portfile 44882 2009-01-04 12:17:18Z ryandesign@macports.org $
2
3PortSystem              1.0
4
5name                    php5
6epoch                   1
7version                 5.2.8
8revision                1
9categories              www lang php
10maintainers             ryandesign jwa
11homepage                http://www.php.net/
12distname                php-${version}
13use_bzip2               yes
14platforms               darwin freebsd
15use_parallel_build      yes
16
17description \
18    PHP: Hypertext Preprocessor
19
20long_description \
21    PHP is a widely-used general-purpose scripting language \
22    that is especially suited for developing web sites, but can also \
23    be used for command-line scripting.
24
25master_sites \
26    ${homepage}distributions/ \
27    http://it.php.net/distributions/ \
28    http://fi.php.net/distributions/ \
29    http://de.php.net/distributions/ \
30    http://gr.php.net/distributions/ \
31    http://fr.php.net/distributions/ \
32    http://es.php.net/distributions/ \
33    http://se.php.net/distributions/
34
35checksums \
36    md5     8760a833cf10433d3e72271ab0d0eccf \
37    sha1    d285636144e0a4aa61195793634807e763c63dc3 \
38    rmd160  d38fe5d918c335089a027600a93d950f417a7e98
39
40depends_build \
41    port:pkgconfig \
42    port:autoconf213
43
44depends_lib \
45    port:libtool \
46    port:libxml2 \
47    port:libxslt \
48    port:openssl \
49    port:zlib \
50    port:bzip2 \
51    port:libiconv \
52    port:expat \
53    port:gettext \
54    port:tiff \
55    port:mhash \
56    port:libmcrypt \
57    port:curl \
58    port:pcre \
59    port:jpeg \
60    port:libpng \
61    port:freetype
62
63patchfiles \
64    patch-bind.diff
65
66use_autoconf            yes
67autoconf.cmd            ${prefix}/bin/autoconf213
68
69configure.args \
70    --mandir=${prefix}/share/man \
71    --infodir=${prefix}/share/info \
72    --with-config-file-path=${prefix}/etc \
73    --enable-calendar \
74    --with-iconv=${prefix} \
75    --enable-exif \
76    --enable-ftp \
77    --enable-wddx\
78    --with-zlib=${prefix} \
79    --with-bz2=${prefix} \
80    --without-mysql \
81    --without-sqlite \
82    --without-pdo-sqlite \
83    --with-libxml-dir=${prefix} \
84    --with-gettext=${prefix} \
85    --with-xml \
86    --with-libexpat-dir=${prefix} \
87    --with-xmlrpc \
88    --enable-soap \
89    --enable-bcmath \
90    --enable-mbstring \
91    --enable-dba \
92    --enable-zip \
93    --with-openssl=${prefix} \
94    --with-mhash=${prefix} \
95    --with-mcrypt=${prefix} \
96    --with-mime-magic \
97    --with-xsl=${prefix} \
98    --with-curl=${prefix} \
99    --with-pcre-regex=${prefix} \
100    --with-gd \
101    --with-jpeg-dir=${prefix} \
102    --with-png-dir=${prefix} \
103    --enable-gd-native-ttf \
104    --without-pear \
105    --with-freetype-dir=${prefix}
106
107platform darwin 6 {
108    depends_lib-append \
109        lib:libdl:dlcompat
110    configure.env-append \
111        LIBS=-ldl
112    configure.cppflags-append \
113        "-no-cpp-precomp -DBIND_8_COMPAT"
114}
115
116platform darwin 7 {
117    configure.env-append \
118        LIBS=-ldl
119    configure.cppflags-append \
120        "-no-cpp-precomp"
121}
122
123platform macosx {
124    configure.args-append \
125        --with-ldap=/usr \
126        --with-kerberos=/usr
127    if {${os.major} > 7} {
128        configure.args-append \
129            --with-iodbc=/usr
130    }
131}
132
133variant no_web conflicts apache apache2 fastcgi description {Don't include any web server support} {}
134
135# Build an Apache 1 module. On Mac OS X, it uses Apple's provided Apache 1 server.
136# On other platforms, the MacPorts apache port is used. Keep the options here
137# in sync with those in the relevant part of the post-destroot phase.
138variant apache conflicts apache2 no_web description {Add Apache 1 web server module} {
139    if { ! [variant_isset macosx] } {
140        depends_lib-append \
141            path:sbin/apxs:apache
142        configure.args-append \
143            --with-apxs=${prefix}/sbin/apxs
144    } else {
145        destroot.violate_mtree yes
146        configure.args-append \
147            --with-apxs=/usr/sbin/apxs
148    }
149}
150
151# Build an Apache 2.2 module. Keep the options here in sync with those in the
152# relevant part of the post-destroot phase.
153variant apache2 conflicts apache no_web description {Add Apache 2.2 web server module (default)} {
154    pre-fetch {
155        if {[string match "*libmysqlclient_r.la*" [exec pkg-config --libs apr-util-1]]} {
156            return -code error "${name} +apache2 can't be built while apr-util is installed with the +mysql5 variant. Deactivate or uninstall apr-util, reinstall apr-util without the +mysql5 variant, then clean ${name} and try installing it again."
157        }
158    }
159    destroot.violate_mtree yes
160    depends_lib-append \
161        path:apache2/bin/apxs:apache2
162    configure.args-append \
163        --with-apxs2=${prefix}/apache2/bin/apxs
164}
165
166# Build a FastCGI binary. Keep the options here in sync with those in the
167# relevant part of the post-destroot phase.
168variant fastcgi conflicts no_web description {Add FastCGI web server binary} {
169    if { ![variant_isset apache] && ![variant_isset apache2] } {
170        configure.args-append \
171            --enable-fastcgi \
172            --enable-force-cgi-redirect
173    }
174}
175
176variant gmp description {Add GNU MP functions} {
177    depends_lib-append \
178        port:gmp
179    configure.args-append \
180        --with-gmp=${prefix}
181}
182
183variant db4 description {Add db4 handle support} {
184# This compiles PHP5 with db46 enabled
185    depends_lib-append \
186        port:db46
187    configure.args-append \
188        --with-db4=${prefix}
189}
190
191variant dbase description {Add dBase file format support} {
192    configure.args-append \
193        --enable-dbase
194}
195
196# Add IMAP support. See:
197# http://www.php.net/imap
198variant imap description {enable operation with IMAP protocol} {
199    depends_lib-append \
200        port:cclient
201    configure.args-append \
202        --with-imap=${prefix} \
203        --with-imap-ssl=${prefix}
204}
205
206variant pspell description {Add pspell spell-checking functions} {
207    depends_lib-append \
208        port:aspell
209    configure.args-append \
210        --with-pspell=${prefix}
211}
212
213# Add Tidy support. See:
214# http://www.php.net/tidy
215variant tidy description {add Tidy support} {
216    depends_lib-append \
217        port:tidy
218    configure.args-append \
219        --with-tidy=${prefix}
220}
221
222variant mssql description {add support for MS-SQL server} {
223    depends_lib-append \
224        port:freetds
225    configure.args-append \
226        --with-mssql=${prefix}
227   
228    # See http://bugs.php.net/bug.php?id=44991
229    post-patch {
230        reinplace "s|tds.h|sybdb.h|g"               ${worksrcpath}/ext/mssql/config.m4
231        reinplace "s|libtds.a|libsybdb.a|g"         ${worksrcpath}/ext/mssql/config.m4
232        reinplace "s|libtds.so|libsybdb.dylib|g"    ${worksrcpath}/ext/mssql/config.m4
233    }
234}
235
236variant snmp conflicts macports_snmp description {use Apple snmp} {
237    # This compiles PHP5 with SNMP linked against Apple's included NET-SNMP.
238    configure.args-append \
239        --with-snmp=/usr
240}
241
242variant macports_snmp conflicts snmp description {use MacPorts snmp} {
243    # This compiles PHP with SNMP linked against MacPorts' NET-SNMP.
244    depends_lib-append \
245        port:net-snmp
246    configure.args-append \
247        --with-snmp=${prefix}
248}
249
250variant mysql3 conflicts mysql4 mysql5 description {build MySQL 3 support} {
251    depends_lib-append \
252        port:mysql3
253    configure.args-delete \
254        --without-mysql
255    configure.args-append \
256        --with-mysql=${prefix} \
257        --with-pdo-mysql=${prefix}
258}
259
260variant mysql4 conflicts mysql3 mysql5 description {build MySQL 4 support} {
261    depends_lib-append \
262        port:mysql4
263    configure.args-delete \
264        --without-mysql
265    configure.args-append \
266        --with-mysql=${prefix} \
267        --with-pdo-mysql=${prefix}
268}
269
270variant mysql5 conflicts mysql3 mysql4 description {build MySQL 5 support} {
271    depends_lib-append \
272        path:bin/mysql_config5:mysql5
273    configure.args-delete \
274        --without-mysql
275    configure.args-append \
276        --with-mysql=${workpath}/mysql5 \
277        --with-pdo-mysql=${prefix}/bin/mysql_config5 \
278        --with-mysql-sock=${prefix}/var/run/mysql5/mysqld.sock \
279        --with-mysqli=${prefix}/bin/mysql_config5
280    post-extract {
281        file mkdir "${workpath}/mysql5"
282        file link -symbolic "${workpath}/mysql5/lib" "${prefix}/lib/mysql5"
283        file link -symbolic "${workpath}/mysql5/include" "${prefix}/include/mysql5"
284    }
285}
286
287variant oracle description {Add Oracle oci8 database functions with the Oracle Instant Client} {
288    depends_lib-append \
289        port:oracle-instantclient
290    configure.args-append \
291        --with-oci8=instantclient,${prefix}/lib/oracle
292}
293
294variant postgresql82 conflicts postgresql83 description {provide postgresql82 support} {
295    depends_lib-append \
296        port:postgresql82
297    configure.args-append \
298        --with-pgsql=${prefix}/lib/postgresql82/bin \
299        --with-pdo-pgsql=${prefix}/lib/postgresql82/bin
300}
301
302variant postgresql83 conflicts postgresql82 description {provide postgresql83 support} {
303    depends_lib-append \
304        port:postgresql83
305    configure.args-append \
306        --with-pgsql=${prefix}/lib/postgresql83/bin \
307        --with-pdo-pgsql=${prefix}/lib/postgresql83/bin
308}
309
310# add sqlite support
311# note that standard sqlite support uses the built-in sqlite2 libraries
312# while pdo sqlite support uses the sqlite3 libraries from the sqlite3 port
313variant sqlite description {build sqlite support} {
314    depends_lib-append \
315        port:sqlite3
316    configure.args-delete \
317        --without-sqlite \
318        --without-pdo-sqlite
319    configure.args-append \
320        --with-sqlite \
321        --with-pdo-sqlite=${prefix} \
322        --enable-sqlite-utf8
323}
324
325# add semaphore, shared memory and IPC functions; see http://www.php.net/sem
326variant ipc description {build IPC support} {
327    configure.args-append \
328        --enable-shmop \
329        --enable-sysvsem \
330        --enable-sysvshm \
331        --enable-sysvmsg
332}
333
334# add process control functions; see http://www.php.net/pcntl
335variant pcntl description {provide process control} {
336    configure.args-append \
337        --enable-pcntl
338}
339
340if {![variant_isset apache] && ![variant_isset apache2] && ![variant_isset fastcgi] && ![variant_isset no_web]} {
341    default_variants +apache2
342}
343
344variant pear description {add pear stuff} {
345    configure.args-delete \
346        --without-pear
347    configure.args-append \
348        --with-pear=${prefix}/lib/php
349    destroot.target-append \
350        install-pear
351    destroot.args-append \
352        PHP_PEAR_INSTALL_DIR=${prefix}/lib/php
353    post-destroot {
354        #nuke pear-stuff in ${destroot}
355        system "cd ${destroot} && rm -rf .channels .depdb .depdblock .filemap .lock"
356       
357        system "if \[ -f ${prefix}/lib/php/.depdblock \]; then rm -f ${destroot}${prefix}/lib/php/.depdblock; fi"
358        system "if \[ -f ${prefix}/lib/php/.depdb \]; then rm -f ${destroot}${prefix}/lib/php/.depdb; fi"
359        system "if \[ -f ${prefix}/lib/php/.filemap \]; then rm -f ${destroot}${prefix}/lib/php/.filemap; fi"
360        system "if \[ -f ${prefix}/lib/php/.lock \]; then rm -f ${destroot}${prefix}/lib/php/.lock; fi"
361        system "if \[ -d ${prefix}/lib/php/.channels \]; then rm -rf ${destroot}${prefix}/lib/php/.channels; fi"
362    }
363}
364
365variant readline description {Add GNU readline functions} {
366    depends_lib-append \
367        port:readline
368    configure.args-append \
369        --with-readline=${prefix}
370}
371
372variant sockets description {Add socket communication functions} {
373    # Note: This extension will be moved to the PECL repository and will no longer be bundled with PHP as of PHP 5.3.0.
374    # This variant should be removed when the port is upgraded to PHP 5.3.0.
375    configure.args-append \
376        --enable-sockets
377}
378
379variant t1lib description {Add PostScript Type 1 font support with t1lib} {
380    depends_lib-append \
381        port:t1lib
382    configure.args-append \
383        --with-t1lib=${prefix} \
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/extras-conf
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/extras-conf
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/extras-conf
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/extras-conf
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] } {
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}${prefix}/etc
450    xinstall -m 755 ${workpath}/${worksrcdir}/php.ini-dist ${destroot}${prefix}/etc/php.ini-dist
451    xinstall -m 755 ${workpath}/${worksrcdir}/php.ini-recommended ${destroot}${prefix}/etc/php.ini-recommended
452}
453
454post-install {
455    ui_msg "\nIf this is your first install, you might want"
456   
457    if { [variant_isset apache] } {
458        ui_msg " * enable php in apache :\n"
459       
460        ui_msg "cd ${prefix}/libexec/apache"
461        ui_msg "${prefix}/apache/bin/apxs -a -e -n \"php5\" libphp5.so\n"
462        ui_msg "* copy  ${prefix}/etc/php.ini-dist to  ${prefix}/etc/php.ini"
463    }
464   
465    if { [variant_isset apache2] } {
466        ui_msg "cd ${prefix}/apache2/modules"
467        ui_msg "${prefix}/apache2/bin/apxs -a -e -n \"php5\" libphp5.so\n"
468        ui_msg "* copy  ${prefix}/etc/php.ini-dist to  ${prefix}/etc/php.ini"
469    }
470   
471    #ui_msg "* copy  ${prefix}/etc/pear.conf.sample to  ${prefix}/etc/pear.conf"
472}
473
474test.run                yes
475
476livecheck.check         regex
477livecheck.url           ${homepage}downloads.php
478livecheck.regex         get/php-(5\\.\[0-9.\]+)\\.tar