Slightly OT: Invoking a shell command from a Makeile

Giorgos Keramidas keramida at ceid.upatras.gr
Sun Jan 27 19:38:12 PST 2008


On 2008-01-28 05:19, Ivan Rambius Ivanov <rambiusparkisanius at gmail.com> wrote:
> On Jan 28, 2008 2:59 AM, Giorgos Keramidas <keramida at ceid.upatras.gr> wrote:
> >         FPCVERSION!= make -f ${PORTSDIR}/lang/fpc/Makefile -V PORTVERSION
>
> Yes, I found this out after some searching in google.
>
> > I'm curious though.  Why do you have to find the value of the
> > {PORTVERSION} from a Ports makefile?
> >
> > Perhaps there is already a `standard' feature of the Ports which can do
> > something similar.  Have you asked around in freebsd-ports?
>
> The port I am developing builds and installs a software called nbc
> [1], [2]. It is written in Pascal and uses the freepascal compiler [3]
> coming from lang/fpc port and some other pascal libraries called units
> coming from devel/fpc-fcl-base. These units are installed into
> /usr/local/lib/fpc/<portversion_of_fpc>, where portversion of_fpc is
> the version of the freepascal compiler as defined in PORTVERSION
> variable in fpc's Makefile. Currently it is 2.2.0. I do not want to
> hardcode that number in nbc port's Makefile - I want to extract it on
> the fly from fpc port's Makefile, this is why I am doing this trick.

That's interesting, but the *installed* copy of devel/fpc-fcl-base may
be older than the available version in `/usr/ports'.  Many programs
install an `xxx-config' script too, which can be queried at runtime,
i.e.:

$ net-snmp-config --version
5.3.1

This runs from ${LOCALBASE} and it is *always* the same as the installed
version of the net-snmp port.

Maybe a similar script can be added to the devel/fpc-fcl-base port, if
one is not already part of it?

In a similar vein, the editors/emacs* ports support installing
extensions in multiple subdirs of ${LOCALBASE} by switching make
variables depending on the value of ${EMACS_PORT_NAME}.

It's probably more work to make devel/fpc-fcl-base tunable like this,
but it is going to be safer than assuming that the /usr/ports/lang/fpc
version is actually the same as the installed version.  This assumption
is only true until the next CVSup of the ports tree, or until portsnap
fetches a newer version of lang/fpc.

I'm *not* a ports hacker, so some of the above may be false and all of
it should be taken with a grain of salt, but I'm sure our freebsd-ports
guys can help :)  It's definitely worth asking them for the best way to
implement something like this.

- Giorgos



More information about the freebsd-questions mailing list