Ticket #8599: php5-Portfile-fastcgi-anytime.diff

File php5-Portfile-fastcgi-anytime.diff, 4.8 KB (added by ryandesign (Ryan Carsten Schmidt), 18 years ago)

Allow +fastcgi and +apache(2) at the same time

  • Portfile

     
    33PortSystem      1.0
    44name            php5
    55version         5.2.1
    6 revision        3
     6revision        4
    77categories      lang php www
    88maintainers     ryandesign@macports.org jwa@macports.org
    99platforms       darwin freebsd
     
    135135                --with-iodbc=/usr
    136136}
    137137
    138 variant apache conflicts apache2 fastcgi {
     138# Build an Apache 1 module. On Mac OS X, it uses Apple's provided Apache 1 server.
     139# On other platforms, the MacPorts apache port is used. Keep the options here
     140# in sync with those in the relevant part of the post-destroot phase.
     141variant apache conflicts apache2 {
    139142        if { ! [variant_isset macosx] } {
    140143                depends_lib-append \
    141144                        path:${prefix}/sbin/apxs:apache
     
    147150        }
    148151}
    149152
    150 variant apache2 conflicts apache fastcgi {
     153# Build an Apache 2 module. Keep the options here in sync with those in the
     154# relevant part of the post-destroot phase.
     155variant apache2 conflicts apache {
    151156        depends_lib-append \
    152157                path:${prefix}/apache2/bin/apxs:apache2
    153158        configure.args-append \
    154159                --with-apxs2=${prefix}/apache2/bin/apxs
    155160}
    156161
    157 variant fastcgi conflicts apache apache2 {
    158         configure.args-append \
    159                 --enable-fastcgi \
    160                 --enable-force-cgi-redirect \
    161                 --enable-memory-limit
     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 {
     165        if { ![variant_isset apache] && ![variant_isset apache2] } {
     166                configure.args-append \
     167                        --enable-fastcgi \
     168                        --enable-force-cgi-redirect \
     169                        --enable-memory-limit
     170        }
    162171}
    163172
    164173variant snmp conflicts macports_snmp {
     
    291300        install-cli install-build install-headers install-programs
    292301
    293302post-destroot   {
    294         # copy fastcgi php binary to the bin dir under a new name so it doesn't overwrite cli version
    295         if { [variant_isset fastcgi] } {
    296                 xinstall -m 755 ${worksrcpath}/sapi/cgi/php ${destroot}${prefix}/bin/php-fcgi
    297         }
    298        
    299         #copy module
     303        # Copy the Apache 1 module.
    300304        if { [variant_isset apache] } {
    301        
    302305                xinstall -m 755 -d ${destroot}${prefix}/libexec/apache \
    303306                        ${destroot}${prefix}/etc/apache/extras-conf
    304307                xinstall -m 755 ${worksrcpath}/libs/libphp5.so ${destroot}${prefix}/libexec/apache/
    305308                xinstall -m 755 -c ${filespath}/mod_php.conf ${destroot}$prefix/etc/apache/extras-conf
    306309        }
    307310       
     311        # Copy the Apache 2 module.
    308312        if { [variant_isset apache2] } {
    309313                xinstall -m 755 -d ${destroot}${prefix}/apache2/modules \
    310314                        ${destroot}${prefix}/apache2/conf/extras-conf
     
    312316                xinstall -m 755 -c ${filespath}/mod_php.conf ${destroot}${prefix}/apache2/conf/extras-conf
    313317        }
    314318       
     319        if { [variant_isset fastcgi] } {
     320                # If we've built an Apache module (any version) then the FastCGI binary
     321                # will not have been built, so we need to run through the whole process
     322                # again and build just the FastCGI binary. Keep the options here in sync
     323                # with the options specified in the apache and apache2 variants.
     324                if { [variant_isset apache] } {
     325                        if { ![variant_isset macosx] } {
     326                                configure.args-delete \
     327                                        --with-apxs=${prefix}/sbin/apxs
     328                        } else {
     329                                configure.args-delete \
     330                                        --with-apxs=/usr/sbin/apxs
     331                        }
     332                }
     333                if { [variant_isset apache2] } {
     334                        configure.args-delete \
     335                                --with-apxs2=${prefix}/apache2/bin/apxs
     336                }
     337               
     338                # Run the build again to get the FastCGI binary. Keep the options here
     339                # in sync with those in the fastcgi variant.
     340                if { [variant_isset apache] || [variant_isset apache2] } {
     341                        configure.args-append \
     342                                --enable-fastcgi \
     343                                --enable-force-cgi-redirect \
     344                                --enable-memory-limit
     345                        ui_msg "$UI_PREFIX Configuring ${name} fastcgi"
     346                        # Note: Use command_exec as soon as a released MacPorts supports it!
     347                        #command_exec configure
     348                        my_command_exec configure
     349                        ui_msg "$UI_PREFIX Building ${name} fastcgi"
     350                        #command_exec build
     351                        my_command_exec build
     352                        ui_msg "$UI_PREFIX Staging ${name} fastcgi into destroot"
     353                }
     354               
     355                # Copy the FastCGI binary to the bin dir under a new name so it doesn't
     356                # conflict with the cli version.
     357                xinstall -m 755 ${worksrcpath}/sapi/cgi/php ${destroot}${prefix}/bin/php-fcgi
     358        }
     359       
    315360#       file rename ${destroot}${prefix}/etc/pear.conf ${destroot}${prefix}/etc/pear.conf.sample
    316361       
    317         #copy php.ini
     362        # Copy the default php.ini files.
    318363        xinstall -m 755 -d ${destroot}${prefix}/etc
    319364        xinstall -m 755 ${workpath}/${worksrcdir}/php.ini-dist ${destroot}${prefix}/etc/php.ini-dist
    320365        xinstall -m 755 ${workpath}/${worksrcdir}/php.ini-recommended ${destroot}${prefix}/etc/php.ini-recommended
     
    340385#       ui_msg "* copy  ${prefix}/etc/pear.conf.sample to  ${prefix}/etc/pear.conf"
    341386}
    342387
     388proc my_command_exec {cmd} {
     389        if {[catch {system "[command $cmd]"} result]} {
     390                return -code error "[format [msgcat::mc "%s failure: %s"] $cmd $result]"
     391        }
     392}