Home > Archive > Unix Programming > August 2006 > How do you execute a target in a Makefile?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How do you execute a target in a Makefile?
|
|
| Thierry 2006-08-25, 7:00 pm |
| Let's say I have the following in my makefile:
CURRDIR = ""
# ... CURRDIR might get initialized or not ...
hello:
@echo "Hello World"
ERR = $(error Testing)
ifeq ($(CURRDIR),"")
$(ERR)
endif
How can I execute the target hello when CURRDIR is not initialized?
Basically, when CURRDIR is not initialized, I want to see the
following:
*** Testing. Stop
Hello World
Thanks
Thierry
| |
|
| Thierry wrote:
> Let's say I have the following in my makefile:
>
> CURRDIR = ""
>
> # ... CURRDIR might get initialized or not ...
>
> hello:
> @echo "Hello World"
>
> ERR = $(error Testing)
>
> ifeq ($(CURRDIR),"")
> $(ERR)
> endif
>
>
> How can I execute the target hello when CURRDIR is not initialized?
The commands associated with the 'hello' target will be executed when
make tries to build 'hello'. If you throw the error, it won't build
anything. So in this case you could get the effect by not throwing the
error, but conditionally defining the (default, first) rule only when
CURRDIR is empty.
But I suspect there is more to this than you're telling. What's the
purpose?
> Basically, when CURRDIR is not initialized, I want to see the
> following:
>
> *** Testing. Stop
> Hello World
>
>
> Thanks
> Thierry
| |
| Thierry 2006-08-28, 7:00 pm |
| I just want my makefile to stop processing if CURRDIR is not
initialised. When it stops processing, I also want it to list a bunch
of messages defined by a target, in that case hello.
The only way I can think to stop the makefile is by using the error
function. I could potentially duplicate the contents of the hello
target in my ifeq check but that would be bad programming. Any ideas?
Thierry
toby wrote:[color=darkred]
> Thierry wrote:
>
> The commands associated with the 'hello' target will be executed when
> make tries to build 'hello'. If you throw the error, it won't build
> anything. So in this case you could get the effect by not throwing the
> error, but conditionally defining the (default, first) rule only when
> CURRDIR is empty.
>
> But I suspect there is more to this than you're telling. What's the
> purpose?
>
|
|
|
|
|