forked from SynoCommunity/spksrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspksrc.cross-go.mk
129 lines (94 loc) · 2.8 KB
/
spksrc.cross-go.mk
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Build go programs
#
# prerequisites:
# - cross/module depends on native/go only
# - module does not require kernel (REQUIRE_KERNEL)
#
# remarks:
# - Restriction for minimal DSM version is not supported (toolchains are not used for go builds)
# - CONFIGURE_TARGET is not supported/bypassed
# - most content is taken from spksrc.cc.mk and modified for go build and install
#
# Common makefiles
include ../../mk/spksrc.common.mk
include ../../mk/spksrc.directories.mk
# Configure the included makefiles
URLS = $(PKG_DIST_SITE)/$(PKG_DIST_NAME)
NAME = $(PKG_NAME)
COOKIE_PREFIX = $(PKG_NAME)-
ifneq ($(PKG_DIST_FILE),)
LOCAL_FILE = $(PKG_DIST_FILE)
else
LOCAL_FILE = $(PKG_DIST_NAME)
endif
DIST_FILE = $(DISTRIB_DIR)/$(LOCAL_FILE)
DIST_EXT = $(PKG_EXT)
ifneq ($(ARCH),)
ARCH_SUFFIX = -$(ARCH)-$(TCVERSION)
TC = syno$(ARCH_SUFFIX)
endif
##### golang specific configurations
include ../../mk/spksrc.cross-go-env.mk
# avoid run of make configure
ifeq ($(strip $(CONFIGURE_TARGET)),)
CONFIGURE_TARGET = nop
endif
ifeq ($(strip $(COMPILE_TARGET)),)
ifneq ($(strip $(GO_SRC_DIR)),)
COMPILE_TARGET = go_build_target
endif
endif
# default go build:
go_build_target:
@$(MSG) - Compile with go build
cd $(GO_SRC_DIR) && env $(ENV) go build $(GO_BUILD_ARGS)
ifeq ($(strip $(INSTALL_TARGET)),)
ifneq ($(strip $(GO_BIN_DIR)),)
INSTALL_TARGET = go_install_target
endif
endif
# default go install:
go_install_target:
@$(MSG) - Install go binaries
install -m 755 -d $(STAGING_INSTALL_PREFIX)/bin
install -m 755 $(GO_BIN_DIR) $(STAGING_INSTALL_PREFIX)/bin/
#####
ifneq ($(REQUIRE_KERNEL),)
@$(error go modules cannot build when REQUIRE_KERNEL is set)
endif
include ../../mk/spksrc.pre-check.mk
include ../../mk/spksrc.cross-env.mk
include ../../mk/spksrc.download.mk
include ../../mk/spksrc.depend.mk
checksum: download
include ../../mk/spksrc.checksum.mk
extract: checksum depend
include ../../mk/spksrc.extract.mk
patch: extract
include ../../mk/spksrc.patch.mk
configure: patch
include ../../mk/spksrc.configure.mk
compile: configure
include ../../mk/spksrc.compile.mk
install: compile
include ../../mk/spksrc.install.mk
plist: install
include ../../mk/spksrc.plist.mk
### Clean rules
smart-clean:
rm -rf $(EXTRACT_PATH)/
rm -f $(WORK_DIR)/.$(COOKIE_PREFIX)*
clean:
rm -fr work work-*
all: install plist
### For make digests
include ../../mk/spksrc.generate-digests.mk
### For make dependency-tree
include ../../mk/spksrc.dependency-tree.mk
.PHONY: all-archs
all-archs: $(addprefix arch-,$(AVAILABLE_ARCHS))
####
arch-%:
@$(MSG) Building package for arch $*
@MAKEFLAGS= $(MAKE) ARCH=$(basename $(subst -,.,$(basename $(subst .,,$*)))) TCVERSION=$(if $(findstring $*,$(basename $(subst -,.,$(basename $(subst .,,$*))))),$(DEFAULT_TC),$(notdir $(subst -,/,$*))) 2>&1 | tee --append build-$*.log
####