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

Re: dpkg-buildflags



On Thu, Jul 01, 2010 at 10:04:02AM +0200, Goswin von Brederlow wrote:
> Pierre Habouzit <madcoder@madism.org> writes:
> 
> > On Wed, Jun 30, 2010 at 03:05:10PM +0200, Goswin von Brederlow wrote:
> >> mrvn@book:~% cat Makefile
> >> $(eval $(shell echo FOO=1; echo BAR=2))
> >> $(info FOO=$(FOO))
> >> $(info BAR=$(BAR))
> >> all:
> >> 
> >> mrvn@book:~% make
> >> FOO=1 BAR=2
> >> BAR=
> >> make: Nothing to be done for `all'.
> >> 
> >> 
> >> How do you get make to honor line breaks in $(eval ...)?
> >
> > gah, make is annoying. Well there is always the possibility:
> >
> > -include dpkg-buildflags.mk
> > dpkg-buildflags.mk:
> > 	$(shell dpkg-buildflags --export=make) > $@
> >
> > Which is probably a hell of a lot simpler.
> > Stupid make....
> 
> Indeed.
> 
> > (for those not very comfortable with make, the -include
> > dpkg-buildflags.mk will check if the file exist, if not won't complain
> > but will find if there is a target named 'dpkg-buildflags.mk', if yes
> > will do its rules and retry to include the file.
> >
> > Which in the end does what is meant.
> 
> Except it won't make the file ever again even if the dpkg-buildflags
> output changes. So if you want to preserve timestamps unless the output
> changes you need something like this. If the timestamp doesn't matter
> you just need the .PHONY.
> 
> -include dpkg-buildflags.mk
> dpkg-buildflags.mk:
>  	$(shell dpkg-buildflags --export=make) > $@.new
>         @if ! cmp 2>/dev/null --quiet $@.new $@; then \
>           echo Updating $@; \
>           mv $@.new $@; \
>         else \
>           rm $@.new; \
>         fi

You don't need to protect the regeneration with your
update-only-if-changed trick because no rule will ever depend upon the
dpkg-buildflags.mk freshness, so the sole need you have is to mark the
rule PHONY if you need such a thing.

-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org


Reply to: