forked from nDenerserve/SmartPi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
132 lines (118 loc) · 3.21 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
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
130
131
132
BINARY_READOUT=smartpireadout
BINARY_SERVER=smartpiserver
BINARY_FTPUPLOAD=smartpiftpupload
BINARY_MODBUSSERVER=smartpimodbusserver
#VERSION=0.3.7
VERSION := $(shell git describe --always --long --dirty)
BUILD_TIME := $(shell date -u '+%Y-%m-%d_%I:%M:%S%p')
BUILDPATH=$(CURDIR)
GO=$(shell which go)
GOFMT?=$(GO)fmt
GOBUILD=$(GO) build
GOINSTALL=$(GO) install
GOCLEAN=$(GO) clean
GOGET=$(GO) get
pkgs = $(shell $(GO) list ./src/...)
all: format makedir get buildsmartpireadout buildsmartpiserver buildsmartpiftpupload buildsmartpimodbusserver
#all: makedir get buildsmartpireadout
makedir:
@echo "start building tree..."
@if [ ! -d $(BUILDPATH)/bin ] ; then mkdir -p $(BUILDPATH)/bin ; fi
@if [ ! -d $(BUILDPATH)/pkg ] ; then mkdir -p $(BUILDPATH)/pkg ; fi
get:
style:
@echo "checking code style"
! $(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
format:
@echo "formatting code..."
@$(GO) fmt $(pkgs)
buildsmartpireadout:
@echo "start building smartpireadout..."
$(GOBUILD) -o bin/$(BINARY_READOUT) -ldflags="-X main.appVersion=${VERSION}_${BUILD_TIME}" src/readout/*.go
@echo "building smartpireadout done"
buildsmartpiserver:
@echo "start building smartpiserver..."
$(GOBUILD) -o bin/$(BINARY_SERVER) -ldflags="-X main.appVersion=${VERSION}_${BUILD_TIME}" src/main/server.go
@echo "building smartpiserver done"
buildsmartpiftpupload:
@echo "start building smartpiftpupload..."
$(GOBUILD) -o bin/$(BINARY_FTPUPLOAD) -ldflags="-X main.appVersion=${VERSION}_${BUILD_TIME}" src/main/ftpupload.go
@echo "building smartpiftpupload done"
buildsmartpimodbusserver:
@echo "start building smartpimodbusserver..."
$(GOBUILD) -o bin/$(BINARY_MODBUSSERVER) -ldflags="-X main.appVersion=${VERSION}_${BUILD_TIME}" src/modbus/modbusserver.go
@echo "building smartpimodbusserver done"
install:
@echo install
# if [ `pidof smartpireadout` > "0" ]
# then killall smartpireadout
# fi
#
# if [ `pidof smartpiserver` > "0" ]
# then killall smartpiserver
# fi
#
# if [ `pidof smartpimodbusserver` > "0" ]
# then killall smartpimodbusserver
# fi
#
# if [ `pidof smartpiftpupload` > "0" ]
# then killall smartpiftpupload
# fi
#
# if [ ! -d /var/tmp/smartpi ];
# then mkdir -p /var/tmp/smartpi
# fi
#
# cat /etc/fstab | grep smartpi | grep -v "#"
# if [ $? = 0 ];
# then
# :
# else
# echo "tmpfs /var/tmp/smartpi tmpfs nodev,nosuid,size=100M 0 0" >> /etc/fstab
# fi
#
#
# cat /etc/modules | grep i2c-bcm2708 | grep -v "#"
# if [ $? = 0 ];
# then
# :
# else
# echo "i2c-bcm2708" >> /etc/modules
# fi
#
# cat /etc/modules | grep i2c-dev | grep -v "#"
# if [ $? = 0 ];
# then
# :
# else
# echo "i2c-dev" >> /etc/modules
# fi
#
# cat /boot/config.txt | grep dtparam=i2c1=on | grep -v "#"
# if [ $? = 0 ];
# then
# :
# else
# echo "dtparam=i2c1=on" >> /boot/config.txt
# fi
#
# cat /boot/config.txt | grep dtparam=i2c_arm=on | grep -v "#"
# if [ $? = 0 ];
# then
# :
# else
# echo "dtparam=i2c_arm=on" >> /boot/config.txt
# fi
#
# if [ ! -d /var/smartpi/db ];
# then mkdir -p /var/smartpi/db
# fi
#
# if [ ! -d /var/smartpi/www ];
# then mkdir -p /var/smartpi/www
# fi
#
# cp $(BUILDPATH)/bin/* /usr/local/bin
# cp $(BUILDPATH)/config/smartpi.conf /etc/smartpi
# cp -r $(BUILDPATH)/public_html/* /var/smartpi/www