| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: go-package.mk,v 1.12 2018/06/05 15:42:20 leot Exp $ | | 1 | # $NetBSD: go-package.mk,v 1.13 2018/07/08 12:55:00 bsiegert Exp $ |
2 | # | | 2 | # |
3 | # This file implements common logic for compiling Go programs in pkgsrc. | | 3 | # This file implements common logic for compiling Go programs in pkgsrc. |
4 | # | | 4 | # |
5 | # === Package-settable variables === | | 5 | # === Package-settable variables === |
6 | # | | 6 | # |
7 | # GO_SRCPATH (required) | | 7 | # GO_SRCPATH (required) |
8 | # The patch that can be used with "go get" to import the current | | 8 | # The patch that can be used with "go get" to import the current |
9 | # package. This is usually the URL without the leading protocol. | | 9 | # package. This is usually the URL without the leading protocol. |
10 | # | | 10 | # |
11 | # Examples: | | 11 | # Examples: |
12 | # github.com/username/repository | | 12 | # github.com/username/repository |
13 | # gopkg.in/check.v1 | | 13 | # gopkg.in/check.v1 |
14 | # | | 14 | # |
| @@ -41,26 +41,31 @@ | | | @@ -41,26 +41,31 @@ |
41 | # 2. Install binaries into bin/. | | 41 | # 2. Install binaries into bin/. |
42 | # 3. Install source code and packages into a separate gopkg tree. | | 42 | # 3. Install source code and packages into a separate gopkg tree. |
43 | # | | 43 | # |
44 | # In the future, we may implement buildlink by creating a separate tree during | | 44 | # In the future, we may implement buildlink by creating a separate tree during |
45 | # the build and linking only the packages explicitly mentioned in dependencies | | 45 | # the build and linking only the packages explicitly mentioned in dependencies |
46 | # there. | | 46 | # there. |
47 | # | | 47 | # |
48 | # All packages build-depend on the "master" Go release. Go packages | | 48 | # All packages build-depend on the "master" Go release. Go packages |
49 | # need to be revbumped when lang/go is updated. | | 49 | # need to be revbumped when lang/go is updated. |
50 | # | | 50 | # |
51 | | | 51 | |
52 | .include "../../lang/go/version.mk" | | 52 | .include "../../lang/go/version.mk" |
53 | | | 53 | |
| | | 54 | # How to find the Go tool. |
| | | 55 | GOVERSSUFFIX?= |
| | | 56 | GO= ${PREFIX}/go${GOVERSSUFFIX}/bin/go |
| | | 57 | |
| | | 58 | |
54 | _GO_DIST_BASE!= basename ${GO_SRCPATH} | | 59 | _GO_DIST_BASE!= basename ${GO_SRCPATH} |
55 | GO_DIST_BASE?= ${_GO_DIST_BASE} | | 60 | GO_DIST_BASE?= ${_GO_DIST_BASE} |
56 | GO_BUILD_PATTERN?= ${GO_SRCPATH}/... | | 61 | GO_BUILD_PATTERN?= ${GO_SRCPATH}/... |
57 | | | 62 | |
58 | WRKSRC= ${WRKDIR}/src/${GO_SRCPATH} | | 63 | WRKSRC= ${WRKDIR}/src/${GO_SRCPATH} |
59 | | | 64 | |
60 | BUILD_DEPENDS+= go-${GO_VERSION}*:../../lang/go | | 65 | BUILD_DEPENDS+= go-${GO_VERSION}*:../../lang/go |
61 | | | 66 | |
62 | MAKE_JOBS_SAFE= no | | 67 | MAKE_JOBS_SAFE= no |
63 | INSTALLATION_DIRS+= bin gopkg | | 68 | INSTALLATION_DIRS+= bin gopkg |
64 | USE_TOOLS+= pax | | 69 | USE_TOOLS+= pax |
65 | | | 70 | |
66 | GO_PLATFORM= ${LOWER_OPSYS}_${GOARCH} | | 71 | GO_PLATFORM= ${LOWER_OPSYS}_${GOARCH} |
| @@ -69,26 +74,26 @@ GOTOOLDIR= ${PREFIX}/go/pkg/tool/${GO_P | | | @@ -69,26 +74,26 @@ GOTOOLDIR= ${PREFIX}/go/pkg/tool/${GO_P |
69 | PRINT_PLIST_AWK+= /${GO_PLATFORM}/ { gsub(/${GO_PLATFORM}/, \ | | 74 | PRINT_PLIST_AWK+= /${GO_PLATFORM}/ { gsub(/${GO_PLATFORM}/, \ |
70 | "$${GO_PLATFORM}"); \ | | 75 | "$${GO_PLATFORM}"); \ |
71 | print; next; } | | 76 | print; next; } |
72 | | | 77 | |
73 | .if !target(post-extract) | | 78 | .if !target(post-extract) |
74 | post-extract: | | 79 | post-extract: |
75 | ${RUN} ${MKDIR} ${WRKSRC} | | 80 | ${RUN} ${MKDIR} ${WRKSRC} |
76 | ${RUN} ${RM} -fr ${WRKDIR}/${GO_DIST_BASE}/.hg | | 81 | ${RUN} ${RM} -fr ${WRKDIR}/${GO_DIST_BASE}/.hg |
77 | ${RUN} ${MV} ${WRKDIR}/${GO_DIST_BASE}/* ${WRKSRC} | | 82 | ${RUN} ${MV} ${WRKDIR}/${GO_DIST_BASE}/* ${WRKSRC} |
78 | .endif | | 83 | .endif |
79 | | | 84 | |
80 | .if !target(do-build) | | 85 | .if !target(do-build) |
81 | do-build: | | 86 | do-build: |
82 | ${RUN} env GOPATH=${WRKDIR}:${BUILDLINK_DIR}/gopkg go install -v ${GO_BUILD_PATTERN} | | 87 | ${RUN} env GOPATH=${WRKDIR}:${BUILDLINK_DIR}/gopkg ${GO} install -v ${GO_BUILD_PATTERN} |
83 | .endif | | 88 | .endif |
84 | | | 89 | |
85 | .if !target(do-test) | | 90 | .if !target(do-test) |
86 | do-test: | | 91 | do-test: |
87 | ${RUN} env GOPATH=${WRKDIR}:${BUILDLINK_DIR}/gopkg go test -v ${GO_BUILD_PATTERN} | | 92 | ${RUN} env GOPATH=${WRKDIR}:${BUILDLINK_DIR}/gopkg ${GO} test -v ${GO_BUILD_PATTERN} |
88 | .endif | | 93 | .endif |
89 | | | 94 | |
90 | .if !target(do-install) | | 95 | .if !target(do-install) |
91 | do-install: | | 96 | do-install: |
92 | ${RUN} cd ${WRKDIR}; [ ! -d bin ] || ${PAX} -rw bin ${DESTDIR}${PREFIX} | | 97 | ${RUN} cd ${WRKDIR}; [ ! -d bin ] || ${PAX} -rw bin ${DESTDIR}${PREFIX} |
93 | ${RUN} cd ${WRKDIR}; [ ! -d pkg ] || ${PAX} -rw src pkg ${DESTDIR}${PREFIX}/gopkg | | 98 | ${RUN} cd ${WRKDIR}; [ ! -d pkg ] || ${PAX} -rw src pkg ${DESTDIR}${PREFIX}/gopkg |
94 | .endif | | 99 | .endif |