Subject: Re: packaging: how to use official target explicitly in Makefile
To: None <pkgsrc-users@NetBSD.org>
From: Johnny Lam <jlam@pkgsrc.org>
List: pkgsrc-users
Date: 07/25/2006 09:06:47
Klaus Heinz wrote:
> Klaus Heinz wrote:
> 
>> I want to use one of the official stage targets as an explicit
>> requirement for a helper target "foo" in a package Makefile, like this:
>>   
>>   foo: extract
>>         do something with extracted files
> 
> While this works now, after PR pkg/34061 was closed, I do not understand
> why the patch stage is also completed if "foo" only depends on
> "extract":
> 
>    $ make foo
>    ...
>    ===> Overriding tools...
>    ===> Creating toolchain wrappers...
>    ===> Extracting...
>    ===> Patching...
>    => Applying pkgsrc patches...
>    => Verifying patch-aa...
>    ...

This is a side-effect of the barrier code.  When it hits the "extract" 
source dependency for "foo", it tries to pass through the barrier by 
invoking a new make process.  Unfortunately, the barrier code doesn't 
know about "foo", so it ends up just calling a bare "make".  You can see 
this if you do the above while setting PKG_VERBOSE=yes.  If there was a 
way to get the list of make targets passed to the make process within 
the Makefile, then this would be extremely easy to solve, but my close 
reading of the make(1) man page shows no way to do this.

I would like to preserve the barrier code because it flattens out the 
pkgsrc build process and speeds it up.  I don't see a way to make "foo" 
depend directly on "extract" without passing more information to the 
barrier routines.  Would the following syntax be acceptable?

     BARRIER_TARGETS+=	foo

     foo-barrier: extract
             do something with extracted files

Then from the command line, you would do "make foo".  It's certainly 
more roundabout, but I can easily insert code into bsd.pkg.barrier.mk to 
make this work.  This syntax would be needed wherever you used one of 
the "barrier-aware" targets as a source dependency.  The current list of 
"barrier-aware" targets can be listed with:

     make show-var VARNAME=_BARRIER_POST_TARGETS

Thoughts?

	Cheers,

	-- Johnny Lam <jlam@pkgsrc.org>