PDA

View Full Version : Quick Makefile question



ranthal
March 13th, 2009, 12:00 AM
Hey all,

In a makefile I want to grab the output of a shell command and assign it to a macro, how do I do this?

The specifics are that I want to find the openssl binary (i.e. command line would run "which openssl") and assign it to the macro OPENSSL.

I feel like this is a really straightforward thing, my brain is just running on empty right now ](*,). Thanks!

monkeyking
March 13th, 2009, 12:50 AM
backtick the argument something like




ubuntu=pre

all : test

test : Makefile
echo ${ubuntu}


use it like


make
echo pre
pre

and then



make ubuntu=`which openssl`
echo /usr/bin/openssl
/usr/bin/openssl


This is a general trick in shells not just Makefiles

hope it helps

ranthal
March 13th, 2009, 01:41 AM
Sure did, thanks a bunch.