forked from sflow/host-sflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
146 lines (130 loc) · 5.1 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
133
134
135
136
137
138
139
140
141
142
143
144
145
# This software is distributed under the following license:
# http://sflow.net/license.html
# note - shell invocation with `` quotes is portable
# between GNU and BSD make
PROG=hsflowd
MY_RPM_TOP=/tmp/HSFLOWD_RPM_TOP
MY_RPM_BUILDROOT=/tmp/HSFLOWD_RPM_BUILD_ROOT
all: $(PROG)
$(PROG):
cd src/sflow; $(MAKE)
cd src/json; $(MAKE)
PLATFORM=`uname`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
cd src/$$PLATFORM; $(MAKE) VERSION=$$MYVER RELEASE=$$MYREL
clean:
cd src/sflow; $(MAKE) clean
cd src/json; $(MAKE) clean
PLATFORM=`uname`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
cd src/$$PLATFORM; $(MAKE) VERSION=$$MYVER RELEASE=$$MYREL clean
install:
PLATFORM=`uname`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
cd src/$$PLATFORM; $(MAKE) VERSION=$$MYVER RELEASE=$$MYREL install
schedule:
PLATFORM=`uname`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
cd src/$$PLATFORM; $(MAKE) VERSION=$$MYVER RELEASE=$$MYREL schedule
dist:
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
MYTARBALL=$(PROG)-$$MYVER-$$MYREL.tar.gz; \
git archive HEAD --prefix=$(PROG)-$$MYVER-$$MYREL/ | gzip >$$MYTARBALL;
rpm:
MYARCH=`uname -m`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
MYTARBALL=$(PROG)-$$MYVER-$$MYREL.tar.gz; \
git archive HEAD --prefix=$(PROG)-$$MYVER-$$MYREL/ | gzip >$$MYTARBALL; \
mkdir -p $(MY_RPM_TOP)/BUILD; \
mkdir -p $(MY_RPM_TOP)/SRPMS; \
mkdir -p $(MY_RPM_TOP)/RPMS; \
MYSRCDIR=$(MY_RPM_TOP)/SOURCES; \
rm -rf $$MYSRCDIR; \
mkdir -p $$MYSRCDIR; \
cp $$MYTARBALL $$MYSRCDIR; \
rpmbuild --define "_topdir $(MY_RPM_TOP)" --define "_FEATURES \"$(FEATURES)\"" --buildroot=$(MY_RPM_BUILDROOT) -ba $(PROG).spec; \
echo "==============="; \
MYRPM="$(MY_RPM_TOP)/RPMS/$$MYARCH/$(PROG)-$$MYVER-$$MYREL.$$MYARCH.rpm"; \
MYSRPM="$(MY_RPM_TOP)/SRPMS/$(PROG)-$$MYVER-$$MYREL.src.rpm"; \
echo "copying new RPMs $$MYRPM and $$MYSRPM back to current directory"; \
cp $$MYRPM $$MYSRPM .
xenrpm:
MYARCH=`uname -m`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
VDIR=$(PROG)-$$MYVER-$$MYREL; \
rm -rf /tmp/$$VDIR; \
mkdir /tmp/$$VDIR && cp -r * /tmp/$$VDIR && mv /tmp/$$VDIR . && tar cvzf $$VDIR.tar.gz $$VDIR; \
MYSRCDIR=$(MY_RPM_TOP)/SOURCES; \
rm -rf $$MYSRCDIR; \
mkdir -p $$MYSRCDIR; \
cp $$VDIR.tar.gz $$MYSRCDIR; \
mkdir $(MY_RPM_TOP)/SRPMS; \
mkdir $(MY_RPM_TOP)/RPMS; \
mkdir $(MY_RPM_TOP)/RPMS/x86_64; \
rpmbuild --define "_topdir $(MY_RPM_TOP)" --buildroot=$(MY_RPM_BUILDROOT) -ba $(PROG)-xen.spec; \
echo "==============="; \
MYRPM="$(MY_RPM_TOP)/RPMS/$$MYARCH/$(PROG)-$$MYVER-$$MYREL.$$MYARCH.rpm"; \
MYSRPM="$(MY_RPM_TOP)/SRPMS/$(PROG)-$$MYVER-$$MYREL.src.rpm"; \
echo "copying new RPMs $$MYRPM and $$MYSRPM back to current directory"; \
cp $$MYRPM $$MYSRPM .
aixrpm:
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
SOURCES=/opt/freeware/src/packages/SOURCES; \
MYSRCDIR=$$SOURCES/$(PROG)-$$MYVER; \
rm -rf $$MYSRCDIR; \
cp -r . $$MYSRCDIR; \
tar cf $$MYSRCDIR.tar -C $$SOURCES $(PROG)-$$MYVER; \
gzip -f $$MYSRCDIR.tar; \
rpm -ba $(PROG).spec.aix
pkg:
PLATFORM=`uname`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
MYSRCDIR=src/$$PLATFORM/scripts/$(PROG)-$$MYVER; \
rm -rf $$MYSRCDIR; \
mkdir -p $$MYSRCDIR; \
mkdir -p $$MYSRCDIR/etc; cp src/$$PLATFORM/scripts/hsflowd.conf $$MYSRCDIR/etc; \
mkdir -p $$MYSRCDIR/usr/sbin; cp src/$$PLATFORM/hsflowd $$MYSRCDIR/usr/sbin; \
mkdir -p $$MYSRCDIR/lib/svc/method; cp src/$$PLATFORM/scripts/svc-hsflowd $$MYSRCDIR/lib/svc/method; \
mkdir -p $$MYSRCDIR/var/svc/manifest/site; cp src/$$PLATFORM/scripts/hsflowd.xml $$MYSRCDIR/var/svc/manifest/site; \
pkgmk -o -r $$MYSRCDIR -f src/$$PLATFORM/scripts/Prototype ; \
pkgtrans /var/spool/pkg /tmp/$(PROG)-$$MYVER-$$MYREL hsflowd; \
mv /tmp/$(PROG)-$$MYVER-$$MYREL .
deb: $(PROG)
MYARCH=`uname -m|sed 's/x86_64/amd64/'`; \
MYVER=`./getVersion`; \
MYREL=`./getRelease`; \
mkdir -p debian/DEBIAN; \
mkdir -p debian/usr/sbin; \
mkdir -p debian/etc/init.d; \
mkdir -p debian/etc/hsflowd/modules; \
mkdir -p debian/lib/systemd/system; \
install DEBIAN_build/control debian/DEBIAN; \
sed -i -e s/_PACKAGE_/$(PROG)/g debian/DEBIAN/control; \
sed -i -e s/_VERSION_/$${MYVER}-$${MYREL}/g debian/DEBIAN/control; \
chmod 644 debian/DEBIAN/control; \
install -m 555 DEBIAN_build/conffiles debian/DEBIAN; \
install -m 555 DEBIAN_build/preinst debian/DEBIAN; \
install -m 555 DEBIAN_build/postinst debian/DEBIAN; \
install -m 555 DEBIAN_build/prerm debian/DEBIAN; \
install -m 700 src/Linux/hsflowd debian/usr/sbin; \
install -m 755 src/Linux/mod_*.so debian/etc/hsflowd/modules; \
install -m 755 src/Linux/scripts/hsflowd.deb debian/etc/init.d/hsflowd; \
install -m 644 src/Linux/scripts/hsflowd.conf debian/etc; \
install -m 644 src/Linux/scripts/hsflowd.service debian/lib/systemd/system; \
cd debian; \
find . -type d | xargs chmod 755; \
md5sum `find usr etc -type f` > DEBIAN/md5sums; \
cd ..; \
dpkg-deb --build debian hsflowd_$${MYVER}-$${MYREL}_$$MYARCH.deb
xenserver: xenrpm
cd xenserver-ddk; $(MAKE) clean; $(MAKE)
.PHONY: $(PROG) clean install schedule rpm xenserver