Re: dpkg-buildflags
On Wed, Jun 30, 2010 at 03:05:10PM +0200, Goswin von Brederlow wrote:
> Pierre Habouzit <madcoder@madism.org> writes:
>
> > On Mon, Jun 07, 2010 at 08:53:03AM +0200, Raphael Hertzog wrote:
> >> > * If packages should set all the flags, have you considered having a
> >> > mode where it lists them all (like dpkg-architecture -l), perhaps
> >> > with export statements?
> >>
> >> Would you like this? I have no problem adding this feature to
> >> dpkg-buildflags.
> >
> > That would be very useful, and you want it to be suitable for $(eval).
> >
> > It's likely that you will have to support various escapings for it to be
> > suitable for sh eval, make eval, and maybe other languages.
> >
> > something like:
> >
> > dpkg-buildflags --export=[sh|make]
> >
> >
> > One would use it this way with the shell:
> >
> > eval $(dpkg-buildflags --export=sh || echo exit $?)
> >
> > and in make:
> >
> > $(eval $(shell dpkg-buildflags --export=make || echo '$$(error dpkg-buildflags failed with code '$$?')')))
> >
> > It's likely to be wise that the output "exports" the variables (as in
> > shell or make "export" feature to make this bit of the environment
> > available to sub-shells).
>
> 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....
(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.
--- with your example: ---
┌─(17:03)────
└[apollon] cat Makefile
-include a.mk
a.mk:
(echo FOO=1; echo BAR=2) > $@
$(info FOO=$(FOO))
$(info BAR=$(BAR))
┌─(17:03)────
└[apollon] make
FOO=
BAR=
(echo FOO=1; echo BAR=2) > a.mk
FOO=1
BAR=2
make: `a.mk' is up to date.
┌─(17:03)────
└[apollon] cat a.mk
FOO=1
BAR=2
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
Reply to: