Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to call PHONY target from within the conditional statement

15 views
Skip to first unread message

rk.so...@gmail.com

unread,
Apr 25, 2007, 7:50:00 AM4/25/07
to
How to call PHONY target from within the conditional statement.

That is i want to call given PHONY target depending on the condition,
weather it is true or false.

eg:

I want to check for an environment variable weather, if it is defined
then PHONY target should be executed, else it should echo message that
Environment variable is not defined.


Plz do help -- its urgent

rk.so...@gmail.com

unread,
Apr 25, 2007, 7:50:44 AM4/25/07
to

Paul Floyd

unread,
Apr 25, 2007, 4:47:20 PM4/25/07
to
On 25 Apr 2007 04:50:00 -0700, rk.so...@gmail.com

Isn't this a make question, rather than gcc?

Firstly, the target is .PHONY, not PHONY. The purpose of .PHONY is to
have 'targets' that don't exist (like clean, clobber or all).

If I understand rightly, you'd like to make the default target based on
an environment (or command line) argument. So instead of typing

make foo

you'd have

FOO=make in the environement and

make

would make foo.

In this case, something like this might do the trick

ifndef FOO
$(error FOO not defined)
else
# check that $(FOO) matches one of bar, baz ... targets
endif

.PHONY: all

all: $(FOO)

bar:
@echo bar

baz:
@echo baz

A bientot
Paul

0 new messages