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

Re: target specific variables in makefiles



Quoting Colin Watson <cjwatson@debian.org> (2003-09-09 00:50:24 BST):
> On Mon, Sep 08, 2003 at 07:22:02PM -0400, Neil Roeth wrote:
> > I recently read about target-specific variables in make, so I thought I could
> > do this:
> > 
> > pkg1-stamp: pkg1
> > pkg2-stamp: pkg2
> > 
> > %-stamp: $(@:%-stamp=%)
> > 	touch $@
> > 
> > pkg1: DH_OPTIONS=-p$@
> > 	...
> > 	dh_install
> > 	dh_installxfonts
> > 	...
> > 
> > pkg2: DH_OPTIONS=-p$@
> > 	...
> > 	dh_install
> > 	dh_installemacsen
> > 	...
> > 
> > and avoid the extra call to make, but I get an error:
> > "*** commands commence before first target.  Stop."
> 
> Lines containing target-specific variables can't be followed by
> commands, I think, so you need to name the target again:
> 
> pkg1: DH_OPTIONS=-p$@
> pkg1: any-other-prerequisites-of-pkg1
>         ...
> 
> pkg2: DH_OPTIONS=-p$@
> pkg2: any-other-prerequisites-of-pkg2
>         ...
> 
> If you want a real-life example, I can unashamedly plug the groff
> package, although I've just noticed that the DH_EXCLUDE := -Ngroff-x11
> stuff is now obsolete.

In addition to this, I think you need to 'export DH_OPTIONS' to make
this work. Otherwise it won't be in the environment at all, whatever
it's set to ;)

-- 
Andrew Stribblehill <ads@debian.org>
Systems programmer, IT Service, University of Durham, England



Reply to: