go.port.mk 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # $OpenBSD: go.port.mk,v 1.16 2017/04/22 09:55:16 ajacoutot Exp $
  2. ONLY_FOR_ARCHS ?= ${GO_ARCHS}
  3. MODGO_BUILDDEP ?= Yes
  4. MODGO_RUN_DEPENDS = lang/go
  5. MODGO_BUILD_DEPENDS = lang/go
  6. .if ${NO_BUILD:L} == "no" && ${MODGO_BUILDDEP:L} == "yes"
  7. BUILD_DEPENDS += ${MODGO_BUILD_DEPENDS}
  8. .endif
  9. MODGO_PACKAGE_PATH = ${PREFIX}/go-pkg
  10. MODGO_PACKAGES = go-pkg/pkg/openbsd_${MACHINE_ARCH:S/i386/386/}
  11. MODGO_SOURCES = go-pkg/src
  12. MODGO_TOOLS = go-pkg/tool/openbsd_${MACHINE_ARCH:S/i386/386/}
  13. SUBST_VARS += MODGO_TOOLS MODGO_PACKAGES MODGO_SOURCES
  14. MODGO_SUBDIR ?= ${WRKDIST}
  15. MODGO_TYPE ?= bin
  16. MODGO_WORKSPACE ?= ${WRKDIR}/go
  17. MODGO_GOPATH ?= ${MODGO_WORKSPACE}:${MODGO_PACKAGE_PATH}
  18. MODGO_ENV += GOPATH="${MODGO_GOPATH}" PATH="${PORTPATH}"
  19. MODGO_CMD ?= ${SETENV} ${MODGO_ENV} go
  20. MODGO_BUILD_CMD = ${MODGO_CMD} install ${MODGO_FLAGS}
  21. MODGO_TEST_CMD = ${MODGO_CMD} test ${MODGO_FLAGS}
  22. .if ! empty(MODGO_LDFLAGS)
  23. MODGO_BUILD_CMD += -ldflags="${MODGO_LDFLAGS}"
  24. MODGO_TEST_CMD += -ldflags="${MODGO_LDFLAGS}"
  25. .endif
  26. .if defined(GH_ACCOUNT) && defined(GH_PROJECT)
  27. ALL_TARGET ?= github.com/${GH_ACCOUNT}/${GH_PROJECT}
  28. .endif
  29. TEST_TARGET ?= ${ALL_TARGET}
  30. SEPARATE_BUILD ?= Yes
  31. WRKSRC ?= ${MODGO_WORKSPACE}/src/${ALL_TARGET}
  32. MODGO_SETUP_WORKSPACE = mkdir -p ${WRKSRC:H}; mv ${MODGO_SUBDIR} ${WRKSRC};
  33. CATEGORIES += lang/go
  34. MODGO_BUILD_TARGET = ${MODGO_BUILD_CMD} ${ALL_TARGET}
  35. MODGO_FLAGS += -x
  36. .if empty(DEBUG)
  37. # by default omit symbol table, debug information and DWARF symbol table
  38. MODGO_LDFLAGS += -s -w
  39. .endif
  40. INSTALL_STRIP =
  41. .if ${MODGO_TYPE:L:Mbin}
  42. MODGO_INSTALL_TARGET = ${INSTALL_PROGRAM} ${MODGO_WORKSPACE}/bin/* \
  43. ${PREFIX}/bin;
  44. .endif
  45. # Go source files serve the purpose of libraries, so sources should be included
  46. # with library ports.
  47. .if ${MODGO_TYPE:L:Mlib}
  48. MODGO_INSTALL_TARGET += ${INSTALL_DATA_DIR} ${MODGO_PACKAGE_PATH} && \
  49. cd ${MODGO_WORKSPACE} && \
  50. find src pkg -type d -exec ${INSTALL_DATA_DIR} \
  51. ${MODGO_PACKAGE_PATH}/{} \; && \
  52. find src pkg -type f -exec ${INSTALL_DATA} -p \
  53. ${MODGO_WORKSPACE}/{} \
  54. ${MODGO_PACKAGE_PATH}/{} \;
  55. # This is required to force rebuilding of go libraries upon changes in
  56. # toolchain.
  57. RUN_DEPENDS += ${MODGO_RUN_DEPENDS}
  58. .endif
  59. MODGO_TEST_TARGET = ${MODGO_TEST_CMD} ${TEST_TARGET}
  60. .if empty(CONFIGURE_STYLE)
  61. MODGO_post-patch += ${MODGO_SETUP_WORKSPACE}
  62. . if !target(do-build)
  63. do-build:
  64. ${MODGO_BUILD_TARGET}
  65. . endif
  66. . if !target(do-install)
  67. do-install:
  68. ${MODGO_INSTALL_TARGET}
  69. . endif
  70. . if !target(do-test)
  71. do-test:
  72. ${MODGO_TEST_TARGET}
  73. . endif
  74. .endif