tech-pkg archive

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

Re: Purpose of mk/find-prefix.mk



Thank you very much to all who replied!

My goal in asking my original question was to ensure I write my package
in the correct way.  I thought I could determine this based on the
answer to my initial question, but now I'm still wondering.  It seems
like the answers conflict a little, or I'm misunderstanding (quite
possible).

So, PREFIX is the right variable to use when referring to the package's
own installation path.  I think all the answers agree with this.

But now I start to become unclear on the best approach for the rest of
the use cases.

I'm hearing that LOCALBASE is the right variable to use at build-time if
constructing "-I" or "-L" arguments to the compiler, or, more generally,
when referring to the prefix of other packages.

On the other hand, some answers say mk/find-prefix.mk (or EVAL_PREFIX)
is the right thing to be using for determining the prefix of a
build-time dependency.  Why is mk/find-prefix.mk better than LOCALBASE?

Is LOCALBASE the right variable to use at *run-time* if referring to
the prefix of another package?  For example, say I want to embed in a
program provided by my package the absolute path of a program on which
my package has a run-time dependency.  Is LOCALBASE the right choice?

I'm still wondering about the best way to invoke a build-dependency
program during the build phase of my package.  In particular, I'm
concerned about the case where the build-dependency is satisfied by a
built-in.  I think a concrete example is the easiest way to discuss
this.

Let's say I have a build dependency on apache-ant because I want to
use the ant program it provides to build some Java source files for my
package.  I would specify my build dependency like this:

  BUILD_DEPENDS+= apache-ant-[0-9]*:../../devel/apache-ant

Then, I would specify a do-build target like this:

  FIND_PREFIX:= ANT_PREFIX=apache-ant
  .include "../../mk/find-prefix.mk"

  do-build:
  	cd ${WORKSRC} && "${ANT_PREFIX}/bin/ant"

Why is that better than "${PREFIX}/bin/ant" or "${LOCALBASE}/bin/ant"?

Now, let's go one step further and pretend that devel/apache-ant is
satisfied as a built-in (i.e. my base system comes with apache-ant by
default and devel/apache-ant has a builtin.mk).  In this case, the
ant program might be at /usr/bin/ant, or some other path *not* under
the pkgsrc LOCALBASE.  Will mk/find-prefix.mk work in this case?  I'm
worried that it won't.  This makes me wonder if a bare invocation of
"ant" is more appropriate, like this:

  do-build:
  	cd ${WORKSRC} && ant

This assumes pkgsrc sets up the PATH environment variable (or wrappers?)
to make my do-build ant invocation find the correct ant program (from
pkgsrc or from the (built-in) base system).  Is this valid?  If so, is
this actually better than any absolute path invocation because it works
regardless of whether the program is from a pkgsrc package or the base
system (built-in)?

Thank you!

Lewis


Home | Main Index | Thread Index | Old Index