summaryrefslogtreecommitdiff
path: root/lang/go
diff options
context:
space:
mode:
authorbsiegert <bsiegert@pkgsrc.org>2015-01-02 14:04:00 +0000
committerbsiegert <bsiegert@pkgsrc.org>2015-01-02 14:04:00 +0000
commit58ac3701757bb510f538caf988c30708616d3029 (patch)
tree630a7c3dd9c9c79d7c0c258065e92637f777f54a /lang/go
parent4839a3360edfc01765dbe1ba3a1f0f70a9faad15 (diff)
downloadpkgsrc-58ac3701757bb510f538caf988c30708616d3029.tar.gz
Add infrastructure for compiling software written in Go to pkgsrc. This
used to be in wip/go.
Diffstat (limited to 'lang/go')
-rw-r--r--lang/go/go-package.mk43
1 files changed, 43 insertions, 0 deletions
diff --git a/lang/go/go-package.mk b/lang/go/go-package.mk
new file mode 100644
index 00000000000..614e45206f4
--- /dev/null
+++ b/lang/go/go-package.mk
@@ -0,0 +1,43 @@
+# $NetBSD: go-package.mk,v 1.1 2015/01/02 14:04:00 bsiegert Exp $
+#
+# This file implements common logic for compiling Go programs in pkgsrc.
+# The compiled Go code is tied to a specific compiler version, and the
+# compilation is fast. So the plan is:
+#
+# 1. Compile everything.
+# 2. Install binaries into bin/.
+# 3. Install source code and packages into a separate gopkg tree.
+#
+# In the future, we may implement buildlink by creating a separate tree during
+# the build and linking only the packages explicitly mentioned in dependencies
+# there.
+#
+# All packages build-depend on the "master" Go release. Go packages
+# need to be revbumped when lang/go is updated.
+#
+# Packages using this should set GO_SRCPATH to the path that could
+# be used with "go get" (usually the URL without the leading protocol).
+
+.include "../../lang/go/version.mk"
+
+GO_DIST_BASE?= ${GO_SRCPATH}
+GO_BUILD_PATTERN?= ${GO_SRCPATH}/...
+
+WRKSRC= ${WRKDIR}/src/${GO_SRCPATH}
+
+BUILD_DEPENDS+= go-${GO_VERSION}*:../../lang/go
+
+MAKE_JOBS_SAFE= no
+INSTALLATION_DIRS+= bin gopkg
+
+post-extract:
+ ${MKDIR} ${WRKSRC}
+ ${RM} -fr ${WRKDIR}/`basename ${GO_DIST_BASE}`/.hg
+ ${MV} ${WRKDIR}/`basename ${GO_DIST_BASE}`/* ${WRKSRC}
+
+do-build:
+ env GOPATH=${WRKDIR}:${PREFIX}/gopkg go install -v ${GO_BUILD_PATTERN}
+
+do-install:
+ -cd ${WRKDIR} && [ -d bin ] && ${PAX} -rw bin ${DESTDIR}${PREFIX}
+ -cd ${WRKDIR} && [ -d pkg ] && ${PAX} -rw src pkg ${DESTDIR}${PREFIX}/gopkg