> I'm trying to move some existing Makefiles written for Solaris over to
> HP-UX 10.20 systems. The Makefiles are used to install host specific
> configuation files.
> On the Suns I can define the machine's hostname with:
> HOSTNAME=sh:uname -n
> However, on the HPs I don't have the option of using '=sh:'. I tried using
> single backquotes. From what I was able to find from HP it looked like I
> should have been able to do:
> HOSTNAME=`uname -n`
Hmm, (quickly) looking through the man page, I couldn't find anything
that said so.
Quote:> Unfortunately, this results in make telling me that it can't make
What is happening is that HOSTNAME gets the value `uname -n`
(i.e. this exact string); it is not evaluated at the time of the
assignment. In a setting like
HOSTNAME = `uname -n`
it would still work, because the "echo $(HOSTNAME)" is fed to the
shell after textually replacing the HOSTNAME macro with its
definition, resulting in "echo `uname -n`" getting evaluated by the
shell, which executes uname, etc. and finally prints the host name.
If, however, HOSTNAME ends up in an environment where it isn't
evaluated by the shell (e.g., in single quotes), you'll simply get the
literal text there, which is not what you want.
> Explictly setting the shell in the Makefile to Bourne doesn't help. I can
> get the make to work correctly if I specify the HOSTNAME variable on the
> command line:
> HOSTNAME=`uname -n` make -d install
This works because the shell does the work first.
Quote:> Since this option sorts of negates at least part of the point in using
> make to deal with these files I'd like to find a better solution.
> It looks like I can use GNU Make and be able to run (shell <cmd>) to get
> the info I need, but I'd rather not install it unless I have to.
> Any ideas?
Unfortunately, I'm not a make file expert. I'd recommend to check the
book "Managing Projects With Make" by Steve Talbot (O'Reilly). If you
run into more problems with make and you're only using it internally,
you might also want to look into alternatives to make, such as Cons
Department of Computational Linguistics --- University of Erlangen, Germany