summaryrefslogtreecommitdiffstats
path: root/plugins/go/go.mk
blob: 7a3a526e5388634095d7eeeb8f8a32c931bed3e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# This file is part of MXE. See LICENSE.md for licensing information.

PKG             := go
$(PKG)_WEBSITE  := https://golang.org/
$(PKG)_OWNER    := https://github.com/starius
$(PKG)_IGNORE   :=
$(PKG)_VERSION  := 1.7.4
$(PKG)_CHECKSUM := 4c189111e9ba651a2bb3ee868aa881fab36b2f2da3409e80885ca758a6b614cc
$(PKG)_SUBDIR   := go
$(PKG)_FILE     := go$($(PKG)_VERSION).src.tar.gz
$(PKG)_URL      := https://storage.googleapis.com/golang/$($(PKG)_FILE)
$(PKG)_DEPS     :=

define $(PKG)_UPDATE
    $(WGET) -q -O- 'https://golang.org/dl/' | \
    $(SED) -n 's,.*go\(1.[0-9][^>]*\)\.src\.tar.*,\1,p' | \
    $(SORT) -h | tail -1
endef

define $(PKG)_BUILD
    cd '$(1)/src' && \
        GOROOT_BOOTSTRAP='$(PREFIX)/$(BUILD)/go' \
        GOROOT_FINAL='$(PREFIX)/$(TARGET)/go' \
        GOOS=windows \
        GOARCH='$(if $(findstring x86_64,$(TARGET)),amd64,386)' \
        DYLD_INSERT_LIBRARIES= \
        ./make.bash

    mkdir -p '$(PREFIX)/$(TARGET)/go'
    for d in include src bin pkg; do \
        cp -a '$(1)'/$$d '$(PREFIX)/$(TARGET)/go/' ; \
    done

    #create prefixed go wrapper script
    mkdir -p '$(PREFIX)/bin/$(TARGET)'
    (echo '#!/usr/bin/env bash'; \
     echo 'echo "== Using MXE Go wrapper: $(PREFIX)/bin/$(TARGET)-go"'; \
     echo 'set -xue'; \
     echo 'CGO_ENABLED=1 \'; \
     echo 'GOOS=windows \'; \
     echo 'GOARCH=$(if $(findstring x86_64,$(TARGET)),amd64,386) \'; \
     echo 'DYLD_INSERT_LIBRARIES= \'; \
     echo 'CC=$(PREFIX)/bin/$(TARGET)-gcc \'; \
     echo 'CXX=$(PREFIX)/bin/$(TARGET)-g++ \'; \
     echo 'PKG_CONFIG=$(PREFIX)/bin/$(TARGET)-pkg-config \'; \
     echo 'exec $(PREFIX)/$(TARGET)/go/bin/go \'; \
     echo '"$$@"'; \
    ) \
             > '$(PREFIX)/bin/$(TARGET)-go'
    chmod 0755 '$(PREFIX)/bin/$(TARGET)-go'

    GOPATH=$(PWD)/plugins/go \
    '$(TARGET)-go' build \
        -o '$(PREFIX)/$(TARGET)/go/bin/test-go.exe' \
        mxe-test
endef

# -buildmode=shared not supported on windows
# See https://golang.org/s/execmodes
$(PKG)_BUILD_SHARED =