Mk/Uses/go.mk: Default to "." instead of PORTNAME

If neither GO_PKGNAME or GO_TARGET are set explicitly, go install
tries to install a package named ${PORTNAME} which is almost always
wrong.  This forces Go ports to set GO_PKGNAME or GO_TARGET although
their value is often redundant.

Update do-build to default to the "." package instead ("the package
in the current directory") and teach do-install to install the "."
package.  In many cases, this removes the need to explicitly set
GO_PKGNAME and GO_TARGET making USES=go:modules alone sufficient
for simpler ports.

This is a backward compatible change.

- Assign maintainership to Dmitri

Submitted by:	Dmitri Goutnik <dg@syrec.org>
Approved by:	jlaffaye (maintainer timeout, ~3 weeks)
Differential Revision:	https://reviews.freebsd.org/D20813
This commit is contained in:
Tobias Kortkamp 2019-07-26 07:15:08 +00:00
parent c0c2aeaebf
commit 3c5839ab5a
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=507340

View File

@ -48,7 +48,7 @@
#
# This variable must not be set by individual ports!
#
# MAINTAINER: jlaffaye@FreeBSD.org
# MAINTAINER: dg@syrec.org
.if !defined(_INCLUDE_USES_GO_MK)
_INCLUDE_USES_GO_MK= yes
@ -117,13 +117,13 @@ post-extract:
.if !target(do-build) && empty(go_ARGS:Mno_targets)
do-build:
(cd ${GO_WRKSRC}; \
${SETENV} ${MAKE_ENV} ${GO_ENV} ${GO_CMD} install ${GO_BUILDFLAGS} ${GO_TARGET})
${SETENV} ${MAKE_ENV} ${GO_ENV} ${GO_CMD} install ${GO_BUILDFLAGS} ${GO_TARGET:S/^${PORTNAME}$/./})
.endif
.if !target(do-install) && empty(go_ARGS:Mno_targets)
do-install:
.for _TARGET in ${GO_TARGET}
${INSTALL_PROGRAM} ${GO_WRKDIR_BIN}/${_TARGET:T} ${STAGEDIR}${PREFIX}/bin
${INSTALL_PROGRAM} ${GO_WRKDIR_BIN}/${_TARGET:T:S/^.$/${PORTNAME}/} ${STAGEDIR}${PREFIX}/bin
.endfor
.endif