aboutsummaryrefslogtreecommitdiffstats
path: root/Mk/Uses/go.mk
diff options
context:
space:
mode:
authorKoop Mast <koop@beyonit.nl>2019-09-25 01:10:20 +0800
committerKoop Mast <koop@beyonit.nl>2019-09-25 01:10:20 +0800
commitc5d4cd5d5cbcd9f16aa5bd8e5fcfdc96e17a81f6 (patch)
tree4b5a3cd1d243ff0c74465ea743ec310199c5edb5 /Mk/Uses/go.mk
parentfe87ebd172e9d689d85015844fb5a85fb32b3e50 (diff)
parent54294ad9726b349cbad4ebbbe9711550f8b1e53d (diff)
downloadfreebsd-ports-gnome-c5d4cd5d5cbcd9f16aa5bd8e5fcfdc96e17a81f6.tar.gz
freebsd-ports-gnome-c5d4cd5d5cbcd9f16aa5bd8e5fcfdc96e17a81f6.tar.zst
freebsd-ports-gnome-c5d4cd5d5cbcd9f16aa5bd8e5fcfdc96e17a81f6.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'Mk/Uses/go.mk')
-rw-r--r--Mk/Uses/go.mk53
1 files changed, 38 insertions, 15 deletions
diff --git a/Mk/Uses/go.mk b/Mk/Uses/go.mk
index a087b4bb1fa6..e14334936a66 100644
--- a/Mk/Uses/go.mk
+++ b/Mk/Uses/go.mk
@@ -20,23 +20,27 @@
# You can set the following variables to control the process.
#
# GO_PKGNAME
-# The name of the package. When building in GOPATH mode, this is
-# the directory that will be created in GOPATH/src and seen by the
-# `go` command. When building in modules-aware mode, no directories
-# will be created and GO_PKGNAME value will be only used as a default
-# for GO_TARGET. If not set explicitly and GH_SUBDIR is present,
-# GO_PKGNAME will be inferred from GH_SUBDIR.
+# The name of the package when building in GOPATH mode. This
+# is the directory that will be created in GOPATH/src and seen
+# by the `go` command. If not set explicitly and GH_SUBDIR or
+# GL_SUBDIR is present, GO_PKGNAME will be inferred from it.
+# It is not needed when building in modules-aware mode.
#
# GO_TARGET
-# The names of the package(s) to build. If not set explicitly,
-# defaults to GO_PKGNAME.
+# The packages to build. If not set explicitly, defaults to
+# GO_PKGNAME. GO_TARGET can also be a tuple in the form
+# package:path where path can be either a simple filename or a
+# full path starting with ${PREFIX}. Specifying a full path
+# like ${PREFIX}/sbin/binary will install the resulting binary
+# as ${PREFIX}/sbin/binary. Using just simple filename is a
+# shortcut to installing it as ${PREFIX}/bin/filename.
#
# CGO_CFLAGS
-# Addional CFLAGS variables to be passed to the C compiler by the `go`
+# Additional CFLAGS variables to be passed to the C compiler by the `go`
# command
#
# CGO_LDFLAGS
-# Addional LDFLAGS variables to be passed to the C compiler by the `go`
+# Additional LDFLAGS variables to be passed to the C compiler by the `go`
# command
#
# GO_BUILDFLAGS
@@ -48,7 +52,7 @@
#
# This variable must not be set by individual ports!
#
-# MAINTAINER: dg@syrec.org
+# MAINTAINER: dmgk@FreeBSD.org
.if !defined(_INCLUDE_USES_GO_MK)
_INCLUDE_USES_GO_MK= yes
@@ -61,6 +65,8 @@ IGNORE= USES=go has invalid arguments: ${go_ARGS:Nmodules:Nno_targets:Nrun}
.if empty(GO_PKGNAME)
. if !empty(GH_SUBDIR)
GO_PKGNAME= ${GH_SUBDIR:S|^src/||}
+. elif !empty(GL_SUBDIR)
+GO_PKGNAME= ${GL_SUBDIR:S|^src/||}
. else
GO_PKGNAME= ${PORTNAME}
. endif
@@ -116,14 +122,31 @@ 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:S/^${PORTNAME}$/./})
+ for t in ${GO_TARGET}; do \
+ out=$$(${BASENAME} $$(${ECHO_CMD} $${t} | \
+ ${SED} -Ee 's/^[^:]*:([^:]+).*$$/\1/' -e 's/^\.$$/${PORTNAME}/')); \
+ pkg=$$(${ECHO_CMD} $${t} | \
+ ${SED} -Ee 's/^([^:]*).*$$/\1/' -e 's/^${PORTNAME}$$/./'); \
+ ${ECHO_MSG} "===> Building $${out} from $${pkg}"; \
+ ${SETENV} ${MAKE_ENV} ${GO_ENV} ${GO_CMD} build ${GO_BUILDFLAGS} \
+ -o ${GO_WRKDIR_BIN}/$${out} \
+ $${pkg}; \
+ done)
.endif
.if !target(do-install) && empty(go_ARGS:Mno_targets)
do-install:
-.for _TARGET in ${GO_TARGET}
- ${INSTALL_PROGRAM} ${GO_WRKDIR_BIN}/${_TARGET:T:S/^.$/${PORTNAME}/} ${STAGEDIR}${PREFIX}/bin
-.endfor
+ for t in ${GO_TARGET}; do \
+ dst=$$(${ECHO_CMD} $${t} | \
+ ${SED} -Ee 's/^[^:]*:([^:]+).*$$/\1/' -e 's/^\.$$/${PORTNAME}/'); \
+ src=$$(${BASENAME} $${dst}); \
+ case $${dst} in \
+ /*) dst=${STAGEDIR}$${dst}; ${MKDIR} $$(${DIRNAME} $${dst}) ;; \
+ *) dst=${STAGEDIR}${PREFIX}/bin/$${src} ;; \
+ esac; \
+ ${ECHO_MSG} "===> Installing $${src} as $${dst}"; \
+ ${INSTALL_PROGRAM} ${GO_WRKDIR_BIN}/$${src} $${dst}; \
+ done
.endif
# Helper targets for port maintainers