openbsd-ports/lang/go/go.port.mk
sthen 4c9d7e6039 No need for a special MODGO_ENV for go.port.mk, just use normal MAKE_ENV
like the rest of the ports tree. This also allows removing a bunch of
manual setting of PATH="${PORTPATH}" HOME="${PORTHOME}" done in various
ports etc. This also makes sure CFLAGS is passed through (not everything
honours it but it does improve at least some ports).

Remove NO_CCACHE from www/honk that was added because the above problem
resulted in ccache variables not being passed through correctly breaking
the cc calls in this.

ok kmos@
2019-05-04 21:46:16 +00:00

100 lines
2.6 KiB
Makefile

# $OpenBSD: go.port.mk,v 1.22 2019/05/04 21:46:16 sthen Exp $
ONLY_FOR_ARCHS ?= ${GO_ARCHS}
MODGO_BUILDDEP ?= Yes
MODGO_RUN_DEPENDS = lang/go
MODGO_BUILD_DEPENDS = lang/go
.if ${NO_BUILD:L} == "no" && ${MODGO_BUILDDEP:L} == "yes"
BUILD_DEPENDS += ${MODGO_BUILD_DEPENDS}
.endif
MODGO_PACKAGE_PATH = ${PREFIX}/go-pkg
MODGO_PACKAGES = go-pkg/pkg/openbsd_${MACHINE_ARCH:S/i386/386/}
MODGO_SOURCES = go-pkg/src
MODGO_TOOLS = go-pkg/tool/openbsd_${MACHINE_ARCH:S/i386/386/}
SUBST_VARS += MODGO_TOOLS MODGO_PACKAGES MODGO_SOURCES
MODGO_SUBDIR ?= ${WRKDIST}
MODGO_TYPE ?= bin
MODGO_WORKSPACE ?= ${WRKDIR}/go
MODGO_GOCACHE ?= ${WRKDIR}/go-cache
MODGO_GOPATH ?= ${MODGO_WORKSPACE}:${MODGO_PACKAGE_PATH}
MAKE_ENV += GOCACHE="${MODGO_GOCACHE}" GOPATH="${MODGO_GOPATH}"
MODGO_CMD ?= ${SETENV} ${MAKE_ENV} go
MODGO_BUILD_CMD = ${MODGO_CMD} install ${MODGO_FLAGS}
MODGO_TEST_CMD = ${MODGO_CMD} test ${MODGO_FLAGS} ${MODGO_TEST_FLAGS}
.if ! empty(MODGO_LDFLAGS)
MODGO_BUILD_CMD += -ldflags="${MODGO_LDFLAGS}"
MODGO_TEST_CMD += -ldflags="${MODGO_LDFLAGS}"
.endif
.if defined(GH_ACCOUNT) && defined(GH_PROJECT)
ALL_TARGET ?= github.com/${GH_ACCOUNT}/${GH_PROJECT}
.endif
TEST_TARGET ?= ${ALL_TARGET}
SEPARATE_BUILD ?= Yes
WRKSRC ?= ${MODGO_WORKSPACE}/src/${ALL_TARGET}
MODGO_SETUP_WORKSPACE = mkdir -p ${WRKSRC:H}; mv ${MODGO_SUBDIR} ${WRKSRC};
CATEGORIES += lang/go
MODGO_BUILD_TARGET = ${MODGO_BUILD_CMD} ${ALL_TARGET}
MODGO_FLAGS += -v -p ${MAKE_JOBS}
.if empty(DEBUG)
# by default omit symbol table, debug information and DWARF symbol table
MODGO_LDFLAGS += -s -w
.else
MODGO_FLAGS += -x
.endif
INSTALL_STRIP =
.if ${MODGO_TYPE:L:Mbin}
MODGO_INSTALL_TARGET = ${INSTALL_PROGRAM} ${MODGO_WORKSPACE}/bin/* \
${PREFIX}/bin;
.endif
# Go source files serve the purpose of libraries, so sources should be included
# with library ports.
.if ${MODGO_TYPE:L:Mlib}
MODGO_INSTALL_TARGET += ${INSTALL_DATA_DIR} ${MODGO_PACKAGE_PATH} && \
cd ${MODGO_WORKSPACE} && \
find src pkg -type d -exec ${INSTALL_DATA_DIR} \
${MODGO_PACKAGE_PATH}/{} \; \
-o -type f -exec ${INSTALL_DATA} -p \
${MODGO_WORKSPACE}/{} \
${MODGO_PACKAGE_PATH}/{} \;
# This is required to force rebuilding of go libraries upon changes in
# toolchain.
RUN_DEPENDS += ${MODGO_RUN_DEPENDS}
.endif
MODGO_TEST_TARGET = ${MODGO_TEST_CMD} ${TEST_TARGET}
.if empty(CONFIGURE_STYLE)
MODGO_pre-configure += ${MODGO_SETUP_WORKSPACE}
. if !target(do-build)
do-build:
${MODGO_BUILD_TARGET}
. endif
. if !target(do-install)
do-install:
${MODGO_INSTALL_TARGET}
. endif
. if !target(do-test)
do-test:
${MODGO_TEST_TARGET}
. endif
.endif