source: trunk/dports/_resources/port1.0/group/php5extension-1.0.tcl @ 101915

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

php-1.0.tcl, php5extension-1.0.tcl: add deprecation notices

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.7 KB
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: php5extension-1.0.tcl 101915 2013-01-22 00:56:26Z ryandesign@macports.org $
3#
4# Copyright (c) 2009 The MacPorts Project
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are
9# met:
10#
11# 1. Redistributions of source code must retain the above copyright
12#    notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright
14#    notice, this list of conditions and the following disclaimer in the
15#    documentation and/or other materials provided with the distribution.
16# 3. Neither the name of The MacPorts Project nor the names of its
17#    contributors may be used to endorse or promote products derived from
18#    this software without specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31#
32#
33# This PortGroup automatically sets up the standard environment for building
34# a PHP extension.
35#
36# Usage:
37#
38#   PortGroup               php5extension 1.0
39#   php5extension.setup     extension version source
40#
41# where extension is the name of the extension (e.g. APC), version is its
42# version, and if the extension is hosted at PECL, source is "pecl"; otherwise
43# don't use source.
44#
45# If this is a Zend extension, use
46#
47#   php5extension.type      zend
48#
49#
50# The php5extension 1.0 PortGroup is DEPRECATED. Please do not use for new
51# development. Please switch any existing ports using it to the php 1.1
52# PortGroup (which supports multiple PHP versions) at your earliest
53# convenience.
54#
55# Most official ports using the php5extension 1.0 PortGroup already have
56# corresponding ports using the php 1.1 PortGroup; the php5extension ports
57# will be marked as replaced_by their php 1.1 counterparts as soon as all
58# ports depending on them are updated to depend on the new ports instead.
59# Then, after a suitable morning period, the php5extension PortGroup will
60# be removed.
61
62
63default build.dir                   {[lindex ${php5extension.build_dirs} 0]}
64default configure.dir               {[lindex ${php5extension.build_dirs} 0]}
65default destroot.dir                {[lindex ${php5extension.build_dirs} 0]}
66options php5extension.build_dirs
67default php5extension.build_dirs    {[php5extension.build_dirs_proc]}
68options php5extension.extensions
69options php5extension.extension_dir
70default php5extension.extension_dir {[exec ${prefix}/bin/php-config --extension-dir 2>/dev/null]}
71options php5extension.ini
72default php5extension.ini           {[lindex ${php5extension.extensions} 0].ini}
73options php5extension.inidir
74default php5extension.inidir        {${prefix}/var/db/php5}
75options php5extension.php_ini
76default php5extension.php_ini       {${prefix}/etc/php5/php.ini}
77options php5extension.phpize
78default php5extension.phpize        {${prefix}/bin/phpize}
79options php5extension.type
80default php5extension.type      php
81options php5extension.source
82default php5extension.source        standalone
83
84proc php5extension.setup {extensions version {source ""}} {
85    global php5extension.build_dirs php5extension.extensions php5extension.ini php5extension.inidir php5extension.source
86    global destroot
87
88    # Use "set" to preserve the list structure.
89    set php5extension.extensions ${extensions}
90
91    php5extension.source        ${source}
92
93    name                        php5-[lindex ${php5extension.extensions} 0]
94    version                     ${version}
95    categories                  php
96    distname                    [lindex ${php5extension.extensions} 0]-${version}
97
98    depends_build               port:autoconf
99
100    depends_lib                 path:bin/php:php5
101
102    configure.universal_args-delete --disable-dependency-tracking
103
104    variant debug description {Enable debug support (useful to analyze a PHP-related core dump)} {}
105
106    pre-configure {
107        set php_debug_variant [regexp {/debug-[^/]+$} ${php5extension.extension_dir}]
108        if {${php_debug_variant} && ![variant_isset debug]} {
109            ui_error "${name} cannot be installed without the debug variant because PHP is installed with the debug variant."
110            return -code error "incompatible variant selection"
111        } elseif {[variant_isset debug] && !${php_debug_variant}} {
112            ui_error "${name} cannot be installed with the debug variant because PHP is installed without the debug variant."
113            return -code error "incompatible variant selection"
114        }
115        foreach dir ${php5extension.build_dirs} {
116            ui_debug "Generating configure script in [file tail ${dir}]"
117            system "cd ${dir} && ${php5extension.phpize}"
118        }
119    }
120
121    configure {
122        foreach configure.dir ${php5extension.build_dirs} {
123            ui_debug "Configuring in [file tail ${configure.dir}]"
124            portconfigure::configure_main
125        }
126    }
127
128    build {
129        foreach build.dir ${php5extension.build_dirs} {
130            ui_debug "Building in [file tail ${build.dir}]"
131            portbuild::build_main
132        }
133    }
134
135    destroot.destdir            INSTALL_ROOT=${destroot}
136
137    destroot {
138        foreach destroot.dir ${php5extension.build_dirs} {
139            ui_debug "Staging in [file tail ${destroot.dir}]"
140            portdestroot::destroot_main
141        }
142        xinstall -m 755 -d ${destroot}${php5extension.inidir}
143        if {"zend" == ${php5extension.type}} {
144            set extension_prefix "zend_extension=${php5extension.extension_dir}/"
145        } else {
146            set extension_prefix "extension="
147        }
148        set fp [open ${destroot}${php5extension.inidir}/${php5extension.ini} w]
149        puts $fp "; Do not edit this file; it is automatically generated by MacPorts."
150        puts $fp "; Any changes you make will be lost if you upgrade or uninstall ${name}."
151        puts $fp "; To configure PHP, edit ${php5extension.php_ini}."
152        foreach extension ${php5extension.extensions} {
153            puts $fp "${extension_prefix}${extension}.so"
154        }
155        close $fp
156    }
157
158    post-install {
159        if {[file exists ${php5extension.php_ini}]} {
160            set count 0
161            set fp [open ${php5extension.php_ini} r]
162            while {![eof $fp]} {
163                set line [gets $fp]
164                regexp {^extension_dir *= *"?([^\"]*)"?} $line -> phpiniextensiondir
165                if {[info exists phpiniextensiondir]} {
166                    ui_debug "Found extension_dir ${phpiniextensiondir} in ${php5extension.php_ini}"
167                    if {${phpiniextensiondir} != ${php5extension.extension_dir}} {
168                        if {0 == ${count}} {
169                            ui_msg "Your php.ini contains a line that will prevent ${name}"
170                            ui_msg "and other PHP extensions from working. To fix this,"
171                            ui_msg "edit ${php5extension.php_ini} and delete this line:"
172                            ui_msg ""
173                        }
174                        ui_msg ${line}
175                        incr count
176                    }
177                    unset phpiniextensiondir
178                }
179            }
180            close $fp
181        }
182    }
183
184    if {"pecl" == ${source}} {
185        global php5extension.homepage
186        set php5extension.homepage  http://pecl.php.net/package/[lindex ${php5extension.extensions} 0]/
187
188        homepage                    ${php5extension.homepage}
189        master_sites                http://pecl.php.net/get/
190        extract.suffix              .tgz
191
192        livecheck.type              regexm
193        livecheck.url               ${php5extension.homepage}
194        livecheck.regex             {>([0-9.]+)</a></th>\s*<[^>]+>stable<}
195    } elseif {"bundled" == ${source}} {
196        homepage                    http://www.php.net/[lindex ${php5extension.extensions} 0]
197        master_sites                php
198
199        dist_subdir                 php5
200        distname                    php-${version}
201        use_bzip2                   yes
202
203        pre-extract {
204            foreach extension ${php5extension.extensions} {
205                extract.post_args-append ${worksrcdir}/ext/${extension}
206            }
207        }
208
209        pre-configure {
210            set php_version [exec ${prefix}/bin/php-config --version 2>/dev/null]
211            if {${version} != ${php_version}} {
212                ui_error "${name} ${version} requires PHP ${version} but you have PHP ${php_version}."
213                return -code error "incompatible PHP installation"
214            }
215        }
216
217        destroot.target             install-modules install-headers
218
219        livecheck.type              none
220        livecheck.url               http://www.php.net/downloads.php
221        livecheck.regex             get/php-(5\\.\[0-9.\]+)\\.tar
222    }
223}
224
225proc php5extension.build_dirs_proc {} {
226    global php5extension.extensions php5extension.source worksrcpath
227    if {"bundled" == ${php5extension.source}} {
228        set dirs {}
229        foreach extension ${php5extension.extensions} {
230            lappend dirs ${worksrcpath}/ext/${extension}
231        }
232        return ${dirs}
233    }
234    return ${worksrcpath}
235}
Note: See TracBrowser for help on using the repository browser.