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

Re: target specific variables in makefiles



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.

Cheers,

-- 
Colin Watson                                  [cjwatson@flatline.org.uk]



Reply to: