Ask a Question related to UNIX Programming, Design and Development.
-
Heiner Steven #1
Makefile: set macro once (Solaris make, GNU make)
Hello,
I have a question on a problem that is disturbing me for some
time now.
I want to set a variable in a Makefile by calling a shell
command. This usually is done like this:
SRC = `pwd`
But in this case, `pwd` will be evaluated for each usage
of the macro SRC. I only want the shell command to be evaluated
*once*.
With GNU "make" I can use the following syntax:
SRC := $(shell pwd | sed 's:\(.*/src\)/.*:\1:')
In a directory "/home/heiner/src/misc" this will set
SRC to "/home/heiner/src".
Solaris "make" has the following syntax for the same purpose:
SRC:sh = pwd | sed 's:\(.*/src\)/.*:\1:'
Does anybody know of a way to write a makefile in a way
both "make"s will accept it? Is there some common syntax
both will accept? Or an if-then-else construct I could use?
Heiner
--
___ _
/ __| |_ _____ _____ _ _ Heiner STEVEN <heiner.steven@nexgo.de>
\__ \ _/ -_) V / -_) ' \ Shell Script Programmers: visit
|___/\__\___|\_/\___|_||_| [url]http://www.shelldorado.com/[/url]
Heiner Steven Guest
-
Crypt:DES make problem on Solaris 9
Hi, I'm trying to install Crypt::DES module on a Solaris9 box and have the following problem when running make: gcc -c ... -
"make Makefile.PL" returns "...up to date"; make returns "no target to make"
I'm attempting to install a perl module (AppConfig-1.56) on a FreeBSD 4.9 system. It has both perl 5.5.3 and 5.8.3 and several modules are already... -
Math::Pari - Solaris 2.8 sparcv9 - make test error
Although I am able to make pari-2.1.5 with no problems, and Math-Pari-2.010500 seems to build just fine, make test fails. The general error is: ... -
To many intersect scripts make Macro a sad panda
Hello there, I'm trying to create a 2d game. To prevent my 'player' from walking through objects I am using intersect scripts like the following... -
I am trying to make the swith but sun and their OS is not making it easy. (I cant even connect to the internet with solaris)
william.quiter@sylvania.com (Hank) wrote in message news:<7e15f9e1.0306012204.2fc5dbfc@posting.google.com>... See ... -
Paul D. Smith #2
Re: Makefile: set macro once (Solaris make, GNU make)
%% Heiner Steven <heiner.steven@nexgo.de> writes:
hs> I want to set a variable in a Makefile by calling a shell
hs> command. This usually is done like this:
hs> SRC = `pwd`
hs> But in this case, `pwd` will be evaluated for each usage
hs> of the macro SRC. I only want the shell command to be evaluated
hs> *once*.
hs> Does anybody know of a way to write a makefile in a way both
hs> "make"s will accept it? Is there some common syntax both will
hs> accept? Or an if-then-else construct I could use?
If your question is what you _implied_, which is there any way to get
the `pwd` evaluated only once in a way that's portable between different
variants of make, then the answer to all your questions above is "no".
Personally I recommend that you write your makefiles in GNU make. That
way you can use powerful features and still know your build environment
is portable: GNU make is portable to every UNIX-like system, plus VMS,
Windows, DOS, and Amiga. And a native OS/2 port will be in the next
version.
If you can't impose the requirement that users of your build system
compile GNU make first, and you must use the native system make, then
you will have to forego all special capabilities of all of them and
write to the lowest common denominator, which is basically POSIX
make... which is pretty low :).
--
-------------------------------------------------------------------------------
Paul D. Smith <psmith@gnu.org> Find some GNU make tips at:
[url]http://www.gnu.org[/url] [url]http://make.paulandlesley.org[/url]
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
Paul D. Smith Guest



Reply With Quote

