Slightly OT: Invoking a shell command from a Makeile

Alphons "Fonz" van Werven a.j.werven at student.utwente.nl
Sun Jan 27 15:08:02 PST 2008


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



More information about the freebsd-questions mailing list