help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Knowing whether a target exists


From: Andre Majorel
Subject: Knowing whether a target exists
Date: Fri, 17 Jan 2003 12:56:21 +0100
User-agent: Mutt/1.4i

Hello all. Is there a way to know programatically whether a GNU
makefile defines some target ?

The reason I ask is that I'm maintaining an automatic build
program that should be able to build two different versions of an
application. Building version 1 of the application requires
running :

    make norge porge

Building version 2 requires running :

    make norge

If the build program had a way of knowing whether porge is
defined, it would be able to build either version with no
problems.

I see three ways out of this :

a) The obvious: in version 2, add a dummy porge target. This is
   what I'm doing right now.

b) Make the build program parse the makefile. It can be done but
   it's complex and error prone.

c) Make the build program parse the output of make -d. It's
   relatively complex and, since the output of -d is AFAIK
   undocumented, there's no guarantee that it's not going to
   change radically at some time in the future.

(a) is not all that neat but (b) and (c) seem worse than the
disease.

Is there a simple, supported way of knowing from outside make
whether a target is defined ? It would have to run on all Unixen
plus Cygwin, for versions of GNU make >= 3.79.

Thanks.

-- 
André Majorel <address@hidden>
http://www.teaser.fr/~amajorel/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]