summaryrefslogtreecommitdiff
path: root/lang/go/files/bsd.go.mk
diff options
context:
space:
mode:
authorJulien Laffaye <jlaffaye@FreeBSD.org>2012-05-14 22:00:37 +0000
committerJulien Laffaye <jlaffaye@FreeBSD.org>2012-05-14 22:00:37 +0000
commit6d356025c0c46338d42c1e285203da905c4d2b33 (patch)
treef8ec817bf97cf1338a1f5da90ea3e8b1c8f1e7f7 /lang/go/files/bsd.go.mk
parent- Update to 2.8.0 (diff)
- Update to 1.0.1
- Only for amd64 until i386 is fixed
Notes
Notes: svn path=/head/; revision=296612
Diffstat (limited to 'lang/go/files/bsd.go.mk')
-rw-r--r--lang/go/files/bsd.go.mk61
1 files changed, 50 insertions, 11 deletions
diff --git a/lang/go/files/bsd.go.mk b/lang/go/files/bsd.go.mk
index 5192c49d9940..e524bfb98179 100644
--- a/lang/go/files/bsd.go.mk
+++ b/lang/go/files/bsd.go.mk
@@ -1,27 +1,66 @@
-# Date created: 2010-11-23
-# Whom: Wen Heping <wenheping@gmail.com>
+# This file contains logic to ease porting of Go packages or binaries using
+# the `go` command.
+# You can set the following variables to control the process.
#
+# GO_PKGNAME
+# The name of the package. This is the directory that will be
+# created in GOPATH/src and seen by the `go` command
+#
+# GO_TARGET
+# The names of the package(s) to build
+#
+# CGO_CFLAGS
+# Addional 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`
+# command
.if ${ARCH} == "i386"
GOARCH= 386
GOOBJ= 8
-GOOS= freebsd
.else
GOARCH= amd64
GOOBJ= 6
-GOOS= freebsd
.endif
-GO_CMD= ${LOCALBASE}/bin/${GOOBJ}g
+# Settable variables
+GO_PKGNAME?= ${PORTNAME}
+GO_TARGET?= ${GO_PKGNAME}
+CGO_CFLAGS+= -I${LOCALBASE}/include
+CGO_LDFLAGS+= -L${LOCALBASE}/lib
+
+# Read-only variables
+GO_CMD= ${LOCALBASE}/bin/go
GOROOT= ${LOCALBASE}/go
-GO_LIBDIR= go/pkg/${GOOS}_${GOARCH}
+GO_LIBDIR= go/pkg/freebsd_${GOARCH}
+GO_SRCDIR= go/src/pkg
+GO_LOCAL_LIBDIR=${LOCALBASE}/${GO_LIBDIR}
+GO_LOCAL_SRCDIR=${LOCALBASE}/${GO_SRCDIR}
+GO_WRKSRC= ${GO_WRKDIR_SRC}/${GO_PKGNAME}
+GO_WRKDIR_BIN= ${WRKDIR}/bin
+GO_WRKDIR_SRC= ${WRKDIR}/src
+GO_WRKDIR_PKG= ${WRKDIR}/pkg/freebsd_${GOARCH}
-.if defined(USE_GO)
BUILD_DEPENDS+= ${GO_CMD}:${PORTSDIR}/lang/go
+GO_ENV+= GOROOT=${GOROOT} \
+ GOPATH=${WRKDIR} \
+ GOARCH=${GOARCH} \
+ GOOS=freebsd \
+ CGO_CFLAGS="${CGO_CFLAGS}" \
+ CGO_LDFLAGS="${CGO_LDFLAGS}"
+PLIST_SUB+= GO_LIBDIR=${GO_LIBDIR} \
+ GO_SRCDIR=${GO_SRCDIR} \
+ GO_PKGNAME=${GO_PKGNAME}
-USE_GMAKE= yes
-
-MAKE_ENV+= GOROOT=${GOROOT} GOARCH=${GOARCH} GOOS=${GOOS}
+.if !target(post-extract)
+post-extract:
+ @${MKDIR} ${GO_WRKSRC:H}
+ @${LN} -s ${WRKSRC} ${GO_WRKSRC}
+.endif
-PLIST_SUB+= GO_LIBDIR=${GO_LIBDIR}
+.if !target(do-build)
+do-build:
+ @(cd ${GO_WRKSRC}; ${SETENV} ${GO_ENV} ${GO_CMD} install ${GO_TARGET})
.endif