Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Sep 2008 18:44:18 -0700
From:      Chris H <chris#@1command.com>
To:        Dmitry Marakasov <amdmi3@amdmi3.ru>
Cc:        freebsd-ports@freebsd.org
Subject:   Re: a $PREFIX question...
Message-ID:  <20080914184418.wa74jqjy0wk0sowo@webmail.1command.com>
In-Reply-To: <20080914004920.GD37740@hades.panopticon>
References:  <20080912105907.hgkvg352gco0k8ow@webmail.1command.com> <20080912211222.GA37740@hades.panopticon> <20080912214349.xrprskkcg00gw080@webmail.1command.com> <20080913125407.GC37740@hades.panopticon> <20080913115506.y6dyjx8k8wcggk0g@webmail.1command.com> <20080914004920.GD37740@hades.panopticon>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello Dmitry, and thank you for your response.

Quoting Dmitry Marakasov <amdmi3/@\amdmi3.ru>:

> * Chris H (chris#/@\1command.com) wrote:
>
> JFYI, I'm not php user, but I have more than enough experience of
> ports hacking, so I may miss something php-specific, though I have
> some thoughts.

Understood. Thank you.

>
>>> For jail there's DESTDIR.
>> Ahh. That's good to know. I had thought to look to the BIND port as a
>> model for a jail. But, since I'm really just trying to get both PHP4 and
>> PHP5 to install in such a manner as to prevent symbol collisions, I
>> thought that simply keeping the configure/install the same as it is
>> now, but substituting php, for php5 would be the most efficient, and
>> tidy approach. It appears that all I'm dealing with is:
>>
>> /usr/local/lib/php
>> /usr/local/include/php
>> /usr/local/etc/php && php.conf
>> /usr/local/bin/php || pgp-cgi
> Ah, sorry. Actually I wasn't aware that php installs stuff into */php
> directories. In this case maybe changing /php to /php5 may really be
> more convenient.
>
>> Which - if I have a reasonable understanding of all this, translates to:
>> $PREFIX || $LOCALBASE/php no?
> No. Now I finally understand your question :)

Just for the record, I read Mk/bsd.port.mk and /intended/ to infer:
$LOCALBASE == /usr/local
$PREFIX if undefined == $LOCALBASE
else $PREFIX == $PREFIX

or

if $PREFIX != $PREFIX, $PREFIX == $LOCALBASE

Sorry for not being clearer. :)

>
> LOCALBASE (/usr/local by default) is a place where all software
> installed through ports will go. It is also where ports search for
> libraries, includes etc. installed by other ports.
>
> PREFIX (LOCALBASE by default, thus /usr/local as well) is where the
> currently installed port goes.
>
> No one should really redefine LOCALBASE, but you may change prefix to
> install a specific port to some nondefault location.
>
> Those have nothing to do with /php dirs. It seems to be php-specific
> feature to install it's files under /php subdirs everywhere. So, by
> default (prefix=/usr/local) e.g. php cli binary will be installed as
>
> /usr/local/bin/php/php

Actually the php binary, and php-cgi are installed in local/bin/
But local/include, local/lib, and local/etc have a php directory appended,
and php.conf is dumped into the local/etc/ directory.

> /usr/local/etc/php.conf
> /usr/local/include/php/Zend/zend.h
> ...
>
> and if you change PREFIX to /usr/local/php5 that'll be
>
> /usr/local/php5/bin/php/php
> /usr/local/php5/etc/php.conf
> /usr/local/php5/include/php/Zend/zend.h
> ...
>
> If you change PREFIX to /newphp, that'll be
>
> /newphp/bin/php/php
> /newphp/etc/php.conf
> /newphp/include/php/Zend/zend.h
> ...
>
> As you can see, changing PREFIX allows php4&5 to coexist, but some extra
> directory hierarchy is introduced.
>
>> So I figured that ultimately both php versions & the destination system
> ...
>> is /greatly/ appreciated here :)) Maybe the ultimate solution would be
>> to simply go the
>> $PREFIX/php && $PREFIX/php5 route. Thereby dropping (isolating) both
>> versions into their own trees. But if I understand any of this correctly,
>> I'll need to modify the system' environment to include these directories:
>> ($PREFIX/php/bin $PREFIX/php/lib $PREFIX/php/include &&
>> $PREFIX/php5/bin $PREFIX/php5/lib $PREFIX/php5/include)
>> Does this make any sense?
>
> Just a quick flashback to possible solutions:
>
> Solution 1: change PREFIX
> Solution 2: hack port to use */php5 dirs instead of */php
> Other than changing all paths in the port's Makefile and pkg-plist,
> you'll need to hack configure to use different directories.
> What you need is to look into php's configure.in, all paths you'll
> need should be there. Since the port has USE_AUTOTOOLS=autoconf:262,
> configure will be generated from configure.in when you build the
> port automatically. There may be many caveats and other places to change
> paths, or there may not be.

Huge insight, thank you!

OK. Looks like this will be the path I'll need to pursue to accomplish
my ultimate goal - eg;

# for PHP4
/usr/local/bin/
/usr/local/include/php/
/usr/local/lib/php/
/usr/local/etc/php/
/usr/local/etc/php.conf
# for PHP5
/usr/local/bin/
/usr/local/include/php/
/usr/local/lib/php5/
/usr/local/etc/php5/
/usr/local/etc/php5/php.conf
or
/usr/local/etc/php5.conf (probably better)

My understanding thus far for the php.conf file seems to indicate that
changing bsd's:
--with-config-file-scan-dir=${PREFIX}/etc/php
in the Makefile to:
--with-config-file-scan-dir=${PREFIX}/etc/php5
will create and use /usr/local/etc/php5/php.conf
which may be fine, but I'm going to look closer at the source(s) to
see if using /usr/local/etc/php5.conf will be a better choice or not.

>
> Yes, you'll need to `modify the system environment' to include paths to
> both php versions.

Understood. :)

> This is where the problems start.

Also understood. But my initial findings don't seem to indicate this
will pose a big problem - with possible/probable exception(s) being
adding ports depending on different php versions. But I figure if I
use/install php4 as the "base version" and install any modules/extensions
/before/ installing the php5 cgi and any additional php5 modules/extensions,
it should go pretty smoothly (fingers crossed) ;)

>
> Both php4 and php5 install equally named files, so if you need an app to
> use php5, you'll have to change PATH to include /usr/local/bin/php5/ or
> NEW_PHP_PREFIX/bin/php (depending on which way you chose); if an app
> needs php's includes, you'll also need to add /usr/loca/include/php5/ or
> NEW_PHP_PREFIX/include/php; same for lib/ and likely etc/. I believe
> that'd be hell. Even more problems if you intend to install something
> from ports which depend on php.

Also understood (see just above).

>
> Thus, if you really need both versions, I'd just install the version you
> need for more apps as default, and another version with changed PREFIX,
> period. No port hacking, just change path to php in some marginal apps.

Also understood.

Maybe when I've managed all of this successfully and also reverse this
in the same way (php5 as base and php4 as additional), I can introduce
a PHPSWITCH knob that will bring up a configure dialog that allows for
a choice for the chosen base, and additional php version choices. :)
I've whipped up a box especially for all this hackery with a 7.0-RELEASE
install. So I'm pretty committed to a /working/ version of all this. :)

Dmitry, I can't thank you enough for all the time you continue to
extend me on all of this! Thank you, thank you, thank you. :)

Best wishes.

--Chris

>
> --
> Dmitry Marakasov   .   55B5 0596 FF1E 8D84 5F56  9510 D35A 80DD F9D2 F77D
> amdmi3@amdmi3.ru  ..:  jabber: amdmi3@jabber.ru    http://www.amdmi3.ru
>






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080914184418.wa74jqjy0wk0sowo>