help-make
[Top][All Lists]
Advanced

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

Re: Knowing whether a target exists


From: JS
Subject: Re: Knowing whether a target exists
Date: Fri, 17 Jan 2003 14:55:12 +0100
User-agent: Mutt/1.4i

On Fri, Jan 17, 2003 at 12:56:21PM +0100, Andre Majorel wrote:
# Hello all. Is there a way to know programatically whether a GNU
# makefile defines some target ?
...
# 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.

POSIX make supports the -n (dryrun) option. Simply do

        #!/bin/sh
        if make -n target >/dev/null 2>&1; then
                echo target is defined
        else
                echo target is not defined
        fi

This should be as portable and lightweight as it gets. I don't know
Cygwin, however.

Regards,

        Jens
-- 
Jens Schweikhardt  http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)







reply via email to

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