forked from damicon/zfswatcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
118 lines (105 loc) · 3.4 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
#
# Makefile - ZFS pool monitoring and notification daemon
#
# Copyright © 2012-2013 Damicon Kraa Oy
#
# This file is part of zfswatcher.
#
# Zfswatcher is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Zfswatcher is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with zfswatcher. If not, see <http://www.gnu.org/licenses/>.
#
# Shell:
SHELL = /bin/sh
# Go tool and library path:
GO = /usr/local/go/bin/go
GOPATH = `pwd`/golibs
# Installation directories:
prefix = /usr
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
sbindir = $(exec_prefix)/sbin
datarootdir = $(prefix)/share
datadir = $(datarootdir)
sysconfdir = /etc
docdir = $(datarootdir)/doc/zfswatcher
mandir = $(datarootdir)/man
man1dir = $(mandir)/man1
man5dir = $(mandir)/man5
man8dir = $(mandir)/man8
VERSION = `fgrep VERSION version.go | cut -d\" -f2`
# Rules:
all: zfswatcher
zfswatcher: zfswatcher.go leds.go setup.go util.go version.go webserver.go \
webpagehandlers.go zparse.go \
osutil_linux.go osutil_freebsd.go osutil_solaris.go
GOPATH=$(GOPATH) $(GO) build -o $@
clean:
GOPATH=$(GOPATH) $(GO) clean
version=$(VERSION) && \
rm -f zfswatcher \
zfswatcher-$${version}.tar.gz \
zfswatcher-$${version}-*.rpm \
zfswatcher_$${version}-*.deb \
zfswatcher_$${version}-*.changes
install: zfswatcher
install -d $(DESTDIR)$(sbindir) $(DESTDIR)$(sysconfdir)/zfs \
$(DESTDIR)$(datadir)/zfswatcher \
$(DESTDIR)$(man8dir)
install -c zfswatcher $(DESTDIR)$(sbindir)/zfswatcher
test -e $(DESTDIR)$(sysconfdir)/zfs/zfswatcher.conf \
|| install -c -m 644 etc/zfswatcher.conf \
$(DESTDIR)$(sysconfdir)/zfs/zfswatcher.conf
install -c -m 644 doc/zfswatcher.8 \
$(DESTDIR)$(man8dir)/zfswatcher.8
cp -R www $(DESTDIR)$(datadir)/zfswatcher/
# Make tarball:
dist:
version=$(VERSION) && \
git archive --prefix=zfswatcher-$${version}/ \
-o zfswatcher-$${version}.tar.gz $${version}
# Make a new Debian package version:
newdebversion:
version=$(VERSION) && \
dch --newversion $${version}-1 \
--upstream \
--distribution unstable \
"New version $${version}"
# Make Debian package:
deb:
version=$(VERSION) && \
dpkg-buildpackage -b -uc -tc && \
mv ../zfswatcher_$${version}-*.deb \
../zfswatcher_$${version}-*.changes \
.
# Make RPM package:
rpm: dist
version=$(VERSION) && \
rpmbuild=`mktemp -d "/tmp/zfswatcher-rpmbuild-XXXXXXXX"`; \
mkdir -p $$rpmbuild/TMP && \
mkdir -p $$rpmbuild/BUILD && \
mkdir -p $$rpmbuild/RPMS && \
mkdir -p $$rpmbuild/SRPMS && \
mkdir -p $$rpmbuild/SPECS && \
cp zfswatcher.spec $$rpmbuild/SPECS/ && \
mkdir -p $$rpmbuild/SOURCES && \
cp zfswatcher-$${version}.tar.gz $$rpmbuild/SOURCES/ && \
rpmbuild -ba \
--define "_topdir $$rpmbuild" \
--define "_tmppath $$rpmbuild/TMP" \
--define "version $${version}" \
zfswatcher.spec && \
cp $$rpmbuild/RPMS/*/* . && \
cp $$rpmbuild/SRPMS/* . && \
rm -r $$rpmbuild && \
echo "RPM build finished"
# eof