On Mon, Oct 04, 2004 at 09:47:45PM +0100, Alistair Crooks wrote:
>
> One thing that we could look at doing is to have a parent directory
> "Makefile.inc"-style file, similar to those in src/, which would
> provide a common way of defining _PKGSRCDIR, and include bsd.pkg.mk
> appropriately.
What I had in mind was to create Makefile.inc files (great minds think
alike, eh, Al?) in all package category directories ("subordinate"
catagories included) that just contain the lines:
.if exists("../Makefile.inc")
. include "../Makefile.inc"
.endif
And then at the top level pkgsrc directory, add a Makefile.inc that
looks like:
# Calculate depth
.if !defined(_PKGSRC_TOPDIR)
. if exists(${.CURDIR}/../../../../mk/bsd.pkg.mk)
_PKGSRC_TOPDIR= ${.CURDIR}/../../../..
. elif exists(${.CURDIR}/../../../mk/bsd.pkg.mk)
_PKGSRC_TOPDIR= ${.CURDIR}/../../..
. elif exists(${.CURDIR}/../../mk/bsd.pkg.mk)
_PKGSRC_TOPDIR= ${.CURDIR}/../..
. elif exists(${.CURDIR}/../mk/bsd.pkg.mk)
_PKGSRC_TOPDIR= ${.CURDIR}/..
. elif exists(${.CURDIR}/mk/bsd.pkg.mk)
_PKGSRC_TOPDIR= ${.CURDIR}
. endif
.endif
.if !defined(PKGSRCDIR)
PKGSRCDIR!= cd ${_PKGSRC_TOPDIR} && pwd
.endif
We could do some sort of autodetection of the path to the pwd executable
by searching for "pwd" in the PATH environment variable if that proves
necessary. These changes have no impact on the existing package
structure.
The next step would be to modify each package Makefile to include
"../Makefile.inc" at the top of the Makefile, and to change all
references for including other files from starting with "../.." to
starting with "${PKGSRCDIR}", e.g., change:
.include "../../devel/gettext-lib/buildlink3.mk"
.include "../../mk/pthread.buildlink.mk"
.include "../../mk/bsd.pkg.mk"
into:
.include "${PKGSRCDIR}/devel/gettext-lib/buildlink3.mk"
.include "${PKGSRCDIR}/mk/pthread.buildlink.mk"
.include "${PKGSRCDIR}/mk/bsd.pkg.mk"
It's a very simple, mechanical set of changes. If we approve this
plan of attack, then it's very simple to crank out and commit all of
these changes in one go.
Cheers,
-- Johnny Lam <jlam@NetBSD.org>