Re: Slightly OT: Invoking a shell command from a Makeile

2008-01-27 Thread Alphons Fonz van Werven

Ivan Rambius Ivanov wrote:


I am developing a FreeBSD port and I would like to invoke a shell
command from it and assign its output to a variable.


If you're using GNU make (called gmake on BSD systems), you can do
VAR := $(shell command)
or, as a concrete example,
CFILES := $(shell ls *.c)

Not that I recommend using that example, it just goes to illustrate.

If you're using BSD make, I wouldn't know though. I'm just not familiar
with that. And if you wish to do it in a portable way such that it works
with BSD make, GNU make or whatever, then all I can say is good luck...

Hth,

Alphons

--
VISTA - Viruses Intruders Spyware Trojans Adware

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Slightly OT: Invoking a shell command from a Makeile

2008-01-27 Thread Ivan Rambius Ivanov
Hello Alphons,

On Jan 28, 2008 1:07 AM, Alphons Fonz van Werven
[EMAIL PROTECTED] wrote:
 Ivan Rambius Ivanov wrote:

  I am developing a FreeBSD port and I would like to invoke a shell
  command from it and assign its output to a variable.

 If you're using GNU make (called gmake on BSD systems), you can do
 VAR := $(shell command)
 or, as a concrete example,
 CFILES := $(shell ls *.c)
 Not that I recommend using that example, it just goes to illustrate.

 If you're using BSD make, I wouldn't know though. I'm just not familiar
 with that. And if you wish to do it in a portable way such that it works
 with BSD make, GNU make or whatever, then all I can say is good luck...
I do use BSD make and not GNU make, but your examples gave me a hint
what I should search on google and I found the exact syntax:

FPCVERSION!=make -f ${PORTSDIR}/lang/fpc/Makefile -V PORTVERSION

The assignment is done by the bang equals sign != and I found it
explained here http://www.khmere.com/freebsd_book/html/ch01.html

Thank you for your quick response.

Regards
Rambius

-- 
Tangra Mega Rock: http://www.radiotangra.com
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Slightly OT: Invoking a shell command from a Makeile

2008-01-27 Thread Alphons Fonz van Werven

Ivan Rambius Ivanov wrote:


I do use BSD make and not GNU make, but your examples gave me a hint
what I should search on google and I found the exact syntax:


Glad I could help, be it in a roundabout way.

Alphons

--
VISTA - Viruses Intruders Spyware Trojans Adware

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Slightly OT: Invoking a shell command from a Makeile

2008-01-27 Thread Giorgos Keramidas
On 2008-01-28 00:48, Ivan Rambius Ivanov [EMAIL PROTECTED] wrote:
 Hello,
 
 I am developing a FreeBSD port and I would like to invoke a shell
 command from it and assign its output to a variable. The command in
 question is
 
 # make -f /usr/ports/lang/fpc/Makefile -V PORTVERSION
 
 and I have verified that it works on the command line.
 
 I try to use it in my port's Makefile in the following way:
 
 FPCVERSION= `make -f /usr/ports/lang/fpc/Makefile -V PORTVERSION`
 
 but it fails with the following error
 
 Syntax error: EOF in backquote substitution

Try the BSD-specific syntax which uses bang-equal assignment to grab the
output of a shell command and assign it to a make variable:

FPCVERSION!= shell cmd here

i.e. something like:

FPCVERSION!= make -f ${PORTSDIR}/lang/fpc/Makefile -V PORTVERSION

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?

- Giorgos

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Slightly OT: Invoking a shell command from a Makeile

2008-01-27 Thread Ivan Rambius Ivanov
Hello Georgious,

On Jan 28, 2008 2:59 AM, Giorgos Keramidas [EMAIL PROTECTED] wrote:
 On 2008-01-28 00:48, Ivan Rambius Ivanov [EMAIL PROTECTED] wrote:
  Hello,
 
  I am developing a FreeBSD port and I would like to invoke a shell
  command from it and assign its output to a variable. The command in
  question is
 
  # make -f /usr/ports/lang/fpc/Makefile -V PORTVERSION
 
  and I have verified that it works on the command line.
 
  I try to use it in my port's Makefile in the following way:
 
  FPCVERSION= `make -f /usr/ports/lang/fpc/Makefile -V 
  PORTVERSION`
 
  but it fails with the following error
 
  Syntax error: EOF in backquote substitution

 Try the BSD-specific syntax which uses bang-equal assignment to grab the
 output of a shell command and assign it to a make variable:

 FPCVERSION!= shell cmd here

 i.e. something like:

 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.

Regards
Rambius

[1] http://bricxcc.sourceforge.net/nbc/
[2] http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/116274
[3] http://www.freepascal.org/

-- 
Tangra Mega Rock: http://www.radiotangra.com
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Slightly OT: Invoking a shell command from a Makeile

2008-01-27 Thread Giorgos Keramidas
On 2008-01-28 05:19, Ivan Rambius Ivanov [EMAIL PROTECTED] wrote:
 On Jan 28, 2008 2:59 AM, Giorgos Keramidas [EMAIL PROTECTED] 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

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]