-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
55 lines (43 loc) · 1.75 KB
/
Makefile
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
.PHONY: all clean
PREFIX = /usr
DEB_TARGET_ARCH ?= armhf
ifeq ($(DEB_TARGET_ARCH),armel)
GO_ENV := GOARCH=arm GOARM=5 CC_FOR_TARGET=arm-linux-gnueabi-gcc CC=$$CC_FOR_TARGET CGO_ENABLED=1
endif
ifeq ($(DEB_TARGET_ARCH),armhf)
GO_ENV := GOARCH=arm GOARM=6 CC_FOR_TARGET=arm-linux-gnueabihf-gcc CC=$$CC_FOR_TARGET CGO_ENABLED=1
endif
ifeq ($(DEB_TARGET_ARCH),arm64)
GO_ENV := GOARCH=arm64 CC_FOR_TARGET=aarch64-linux-gnu-gcc CC=$$CC_FOR_TARGET CGO_ENABLED=1
endif
ifeq ($(DEB_TARGET_ARCH),amd64)
GO_ENV := GOARCH=amd64 CC=x86_64-linux-gnu-gcc
endif
ifeq ($(DEB_TARGET_ARCH),i386)
GO_ENV := GOARCH=386 CC=i586-linux-gnu-gcc
endif
GO_ENV := GO111MODULE=on $(GO_ENV)
GO ?= go
GO_FLAGS = -ldflags "-s -w -X main.version=`git describe --tags --always --dirty`"
all: clean wb-rules
clean:
rm -rf wb-rules
amd64:
$(MAKE) DEB_TARGET_ARCH=amd64
test:
cp amd64.wbgo.so wbrules/wbgo.so
CC=x86_64-linux-gnu-gcc go test -v -trimpath -ldflags="-s -w" -cover ./wbrules
wb-rules: main.go wbrules/*.go
$(GO_ENV) $(GO) build -trimpath $(GO_FLAGS)
install:
mkdir -p $(DESTDIR)$(PREFIX)/share/wb-rules-modules/ $(DESTDIR)/etc/wb-rules-modules/
install -Dm0755 wb-rules -t $(DESTDIR)$(PREFIX)/bin
install -Dm0644 rules/rules.js -t $(DESTDIR)/etc/wb-rules
install -Dm0644 wb-rules.wbconfigs $(DESTDIR)/etc/wb-configs.d/13wb-rules
install -Dm0644 scripts/lib.js -t $(DESTDIR)$(PREFIX)/share/wb-rules-system/scripts
install -Dm0644 rules/load_alarms.js -t $(DESTDIR)$(PREFIX)/share/wb-rules
install -Dm0644 $(DEB_TARGET_ARCH).wbgo.so $(DESTDIR)$(PREFIX)/lib/wb-rules/wbgo.so
install -Dm0644 rules/alarms.conf -t $(DESTDIR)/etc/wb-rules
install -Dm0644 rules/alarms.schema.json -t $(DESTDIR)$(PREFIX)/share/wb-mqtt-confed/schemas
deb:
$(GO_ENV) dpkg-buildpackage -b -a$(DEB_TARGET_ARCH) -us -uc