Operating System - Linux
1753962 Members
7665 Online
108811 Solutions
New Discussion юеВ

Make File Conditiona Compilation in HP UNIX

 
CA1490051
Frequent Advisor

Make File Conditiona Compilation in HP UNIX

Hi All,

I am trying to put a if condition in a Makefile.
The Makefile is as follows
HOSTNAME = `uname`
HP = HP-UX

all:TARGET
ifeq ($(HOSTNAME),$(HP))
echo $(HOSTNAME)
else
echo "NOT HP"
endif

If i try to make I get the following error message

Make: Must be a separator on rules line 7. Stop.

Can Someone correct me where i am going wrong.

thanks and regards
Vikram

5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: Make File Conditiona Compilation in HP UNIX

>Can someone correct me where i am going wrong.

You aren't using gmake:
http://hpux.cs.utah.edu/hppd/hpux/Gnu/make-3.81/
Peter Nikitka
Honored Contributor

Re: Make File Conditiona Compilation in HP UNIX

Hi,

even with gmake, the character before your 'echo's must be a TAB, no spaces, because that's part of a makerule.
The result of 'make' after this correction will be the output
Don't know how to make 'TARGET'
when the above lines are your complete Makefile.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
CA1490051
Frequent Advisor

Re: Make File Conditiona Compilation in HP UNIX

Hi All,

There was an error in my copy paste

The Makefile looks as below

HOSTNAME = `uname`
HP = HP-UX

all:TARGET
TARGET :
ifeq ($(HOSTNAME),$(HP))
echo $(HOSTNAME)
#uname
else
endif

and there is a tab fo rthe echo statement not spaces.

I am not using gmake i am using make. IS this not possible to achieve this through make.

thanks and regards
Vikram

Steven Schweda
Honored Contributor

Re: Make File Conditiona Compilation in HP UNIX

> I am not using gmake i am using make.

Why not? What were you using (where) when
you created this "make" file? (For that
matter, it's just possible that knowing which
HP-UX you're using (hardware, version) might
be interesting, too.)

> IS this not possible to achieve this
> through make.

If "man make" doesn't mention conditionals
like "ifeq", then I'd assume that this "make"
program doesn't support them.

Depending on exactly what you wish to do
conditionally, it may be possible (if not
convenient) to devise more complex rules
which do (a lot of) "uname -s" testing to
decide what to do differently on different
host systems. If you need more complex
OS-dependency in the "make" file structure,
then you may need to use a "make" program
which allows it.
Dennis Handly
Acclaimed Contributor

Re: Make File Conditiona Compilation in HP UNIX

>I am not using gmake, i am using make. Is this not possible to achieve this through make?

That's what I said. HP-UX's make doesn't support this.

>Steven: it's just possible that knowing which HP-UX you're using (hardware, version) might be interesting, too.)

Not in this case with make. :-(

>it may be possible (if not convenient) to devise more complex rules which do (a lot of) "uname -s" testing

Right but simpler to use a real make.