help-make
[Top][All Lists]
Advanced

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

Partial generation of recipe and dependencies


From: Andre Majorel
Subject: Partial generation of recipe and dependencies
Date: Tue, 19 Jun 2012 19:30:25 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Most targets in my makefile need to fail early if $(DESTDIR) is
defined. Simplest way I've found is to make them depend on a
target like this one :

.PHONY: destdir-unsafe
destdir-unsafe:
ifdef DESTDIR
        @printf 'Target does not honour $$(DESTDIR)\n' >&2; false
else
        @:
endif

.PHONY: target1
target1: destdir-unsafe
        do something

.PHONY: target2
target2: destdir-unsafe
        do something else

To eliminate some of the redundancy, I thought of doing this :

define tgt
.PHONY: $(1)
$(1): destdir-unsafe
endef

$(eval $(call tgt, target1))
        do something

$(eval $(call tgt, target2))
        do something else

Unfortunately, the splicing of the two lines coming from $(tgt)
and the "do something" line does not take place and Make bombs
with

  Makefile:#: *** commands commence before first target.  Stop.

on the "do something" line. Any way to make it work ? Thanks in
advance.

-- 
André Majorel http://www.teaser.fr/~amajorel/



reply via email to

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