-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakefileAMD64Lnx
83 lines (62 loc) · 2.35 KB
/
MakefileAMD64Lnx
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
SHELL := /bin/bash
# The name of the executable (default is current directory name)
BASENAME := $(shell echo $${PWD\#\#*/})
TARGET := linux-amd64-basd
.DEFAULT_GOAL: $(TARGET)
# These will be provided to the target
VERSION := 1.0.1
BUILD := `git rev-parse HEAD`
BUILDTIME := `date "+%Y-%m-%d/%H:%M:%S/%Z"`
#include .Makefile
# Use linker flags to provide version/build settings to the target
#LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD) -X=main.BuildTime=$(BUILDTIME) -linkmode=external -v"
LDFLAGS=-x -ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD) -X=main.BuildTime=$(BUILDTIME) -w"
#LDFLAGS=-race -x -ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD) -X=main.BuildTime=$(BUILDTIME)"
# go source files, ignore vendor directory
SRC = $(shell find . -type f -name '*.go' -not -path "./test/*")
.PHONY: all build clean install uninstall fmt simplify check run Test preinst
all: check build
Test:
@echo $(LDFLAGS)
@echo $(eval srcname:= $(shell which ${BASENAME}))
@echo $(BUILDTIME)
@echo $$(which ${BASENAME}) $(subst ${BASENAME},$(TARGET),$(srcname))
rpcservice := app/cmdpb
#dhtrpc := dht/pb
#assetdir := ui/asset
#wifiapdir := wifiap/control
proto:
protoc -I=$(rpcservice) --go_out=plugins=grpc:${rpcservice} ${rpcservice}/*.proto
# protoc -I=$(dhtrpc) --go_out=plugins=grpc:${dhtrpc} ${dhtrpc}/*.proto
staticfile2bin:
go-bindata -o $(assetdir)/res.go -pkg=asset ui/xadmin/...
go-bindata -o $(wifiapdir)/res.go -pkg=control wifiap/staticfile/...
#$(TARGET): staticfile2bin proto $(SRC)
# @go build $(LDFLAGS) -o $(TARGET)
$(TARGET): proto $(SRC)
@GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(TARGET)
build: $(TARGET)
@true
clean:
@rm -f $(TARGET)
@rm -f $(rpcservice)/*.pb.go $(assetdir)/res.go
#install: preinst
# #@go install $(LDFLAGS)
# @mv $$(which ${BASENAME}) $(subst ${BASENAME},$(TARGET),$$(which ${BASENAME}))
preinst: $(TARGET)
@go install $(LDFLAGS)
install: preinst
@$(eval srcname:= $(shell which ${BASENAME}))
@mv $(srcname) $(subst $(BASENAME),$(TARGET),$(srcname))
uninstall: clean
@rm -f $$(which ${TARGET})
fmt:
@gofmt -l -w $(SRC)
simplify:
@gofmt -s -l -w $(SRC)
check:
@test -z $(shell gofmt -l main.go | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make fmt'"
@for d in $$(go list ./... | grep -v /test/); do golint $${d}; done
#@go vet ${SRC}
run: install
@$(TARGET)