a $PREFIX question...

Dmitry Marakasov amdmi3 at amdmi3.ru
Sun Sep 14 00:49:35 UTC 2008


* 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.

>> 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 :)

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
/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.

Yes, you'll need to `modify the system environment' to include paths to
both php versions. This is where the problems start.

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.

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.

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


More information about the freebsd-ports mailing list