Subject: Re: Using BSD-style Makefiles & pkgsrc
To: Peter Bex <Peter.Bex@student.kun.nl>
From: Frederick Bruckman <fredb@immanent.net>
List: netbsd-users
Date: 11/04/2004 22:16:36
In article <20041103143255.GA2515@frohike.nvie.com>,
Peter.Bex@student.kun.nl (Peter Bex) writes:
>
> For example, I know pkgsrc sets PREFIX and with DESTDIR I can control where
> BSD-style Makefiles see the `root' for installation (although it expects
> that there is a /usr dir, which isn't under /usr/local usually), so I
> currently have something that looks like this in Makefile.inc:
>
> PREFIX?= /usr/local
>
> DESTDIR?= ${PREFIX}
> LIBDIR?= /lib
> BINDIR?= /bin
> Is this the correct way to do this or is this something I should not want (=
> or isn't even possible)?
The usual convention, is that ${DESTDIR} is reserved for cross-building.
It's empty by default. You install to ${DESTDIR}${PREFIX}, but any paths,
including run-paths embedded in shared libraries, omit the ${DESTDIR}
part. If you use <bsd.prog.mk>, or <bsd.lib.mk>, the ${DESTDIR} handling
is automatic. ${PREFIX} isn't recognized as anything special though, so
your ${LIBDIR} should probably be ${PREFIX}/lib, and ${BINDIR} should be
${PREFIX}/bin.
"pkgsrc" does know about ${PREFIX}, and will set it in the environment
before invoking the package's own "make" mechanism. It tries to do the
right thing with ${DESTDIR}, too. In fact, it typically sets ${PREFIX}
to "${DESTDIR}/usr/pkg". Therefore, you shouldn't set or use ${DESTDIR}
at all, but just set ${PREFIX} conditionally, and key off of that.
Frederick