File: Makefile

package info (click to toggle)
munin 1.2.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,940 kB
  • ctags: 98
  • sloc: sh: 4,215; makefile: 452; perl: 135
file content (254 lines) | stat: -rw-r--r-- 9,349 bytes parent folder | download
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#! /usr/bin/make -f

DEFAULTS = Makefile.config
CONFIG = Makefile.config

include $(DEFAULTS)
include $(CONFIG)

RELEASE          = $(shell cat RELEASE)
INSTALL_PLUGINS ?= "auto manual contrib snmpauto"
INSTALL          = ./install-sh
DIR              = $(shell /bin/pwd | sed 's/^.*\///')

default: build

install: install-main install-node install-node-plugins install-doc install-man

install-main: build
	$(CHECKUSER)
	mkdir -p $(CONFDIR)/templates
	mkdir -p $(LIBDIR)
	mkdir -p $(BINDIR)
	mkdir -p $(PERLLIB)

	mkdir -p $(LOGDIR)
	mkdir -p $(STATEDIR)
	mkdir -p $(HTMLDIR)
	mkdir -p $(DBDIR)
	mkdir -p $(CGIDIR)

	$(CHOWN) $(USER) $(LOGDIR) $(STATEDIR) $(RUNDIR) $(HTMLDIR) $(DBDIR)

	for p in build/server/*.tmpl; do    		              \
		$(INSTALL) -m 0644 "$$p" $(CONFDIR)/templates/ ; \
	done
	$(INSTALL) -m 0644 server/logo.png $(CONFDIR)/templates/
	$(INSTALL) -m 0644 server/style.css $(CONFDIR)/templates/
	$(INSTALL) -m 0644 server/definitions.html $(CONFDIR)/templates/

	test -f "$(CONFDIR)/munin.conf"  || $(INSTALL) -m 0644 build/server/munin.conf $(CONFDIR)/

	$(INSTALL) -m 0755 build/server/munin-cron $(BINDIR)/

	$(INSTALL) -m 0755 build/server/munin-update $(LIBDIR)/
	$(INSTALL) -m 0755 build/server/munin-graph $(LIBDIR)/
	$(INSTALL) -m 0755 build/server/munin-html $(LIBDIR)/
	$(INSTALL) -m 0755 build/server/munin-limits $(LIBDIR)/
	$(INSTALL) -m 0755 build/server/munin-cgi-graph $(CGIDIR)/

	$(INSTALL) -m 0644 build/server/Munin.pm $(PERLLIB)/

install-node: build install-node-non-snmp install-node-snmp
	echo Done.

install-node-snmp: build
	$(INSTALL) -m 0755 build/node/munin-node-configure-snmp $(SBINDIR)/

install-node-non-snmp: build
	$(CHECKGROUP)
	mkdir -p $(CONFDIR)/plugins
	mkdir -p $(CONFDIR)/plugin-conf.d
	mkdir -p $(LIBDIR)/plugins
	mkdir -p $(SBINDIR)
	mkdir -p $(PERLLIB)/Munin/Plugin

	mkdir -p $(LOGDIR)
	mkdir -p $(STATEDIR)
	mkdir -p $(PLUGSTATE)

	$(CHGRP) $(GROUP) $(PLUGSTATE)
	$(CHMOD) 775 $(PLUGSTATE)
	$(CHMOD) 755 $(CONFDIR)/plugin-conf.d

	$(INSTALL) -m 0755 build/node/munin-node $(SBINDIR)/
	$(INSTALL) -m 0755 build/node/munin-node-configure $(SBINDIR)/
	test -f "$(CONFDIR)/munin-node.conf" || $(INSTALL) -m 0644 build/node/munin-node.conf $(CONFDIR)/
	$(INSTALL) -m 0755 build/node/munin-run $(SBINDIR)/
	
install-node-plugins: build
	for p in build/node/node.d.$(OSTYPE)/* build/node/node.d/*; do    		\
		if test -f "$$p" ; then                                     		\
			family=`sed -n 's/^#%# family=\(.*\)$$/\1/p' $$p`;  		\
			test "$$family" || family=contrib;                  		\
			if echo $(INSTALL_PLUGINS) | grep $$family >/dev/null; then 	\
				test -f "$(LIBDIR)/plugins/`basename $$p`"		\
				|| $(INSTALL) -m 0755 $$p $(LIBDIR)/plugins/;    		\
			fi;                                                 		\
		fi                                                          		\
	done
	$(INSTALL) -m 0644 build/node/plugins.history $(LIBDIR)/plugins/

	#TODO:
	#configure plugins.

install-man: build-man
	mkdir -p $(MANDIR)/man1 $(MANDIR)/man5 $(MANDIR)/man8
	$(INSTALL) -m 0644 build/doc/munin-node.conf.5 $(MANDIR)/man5/
	$(INSTALL) -m 0644 build/doc/munin.conf.5 $(MANDIR)/man5/
	$(INSTALL) -m 0644 build/doc/munin-node.8 $(MANDIR)/man8/
	$(INSTALL) -m 0644 build/doc/munin-node-configure.8 $(MANDIR)/man8/
	$(INSTALL) -m 0644 build/doc/munin-node-configure-snmp.8 $(MANDIR)/man8/
	$(INSTALL) -m 0644 build/doc/munin-run.8 $(MANDIR)/man8/
	$(INSTALL) -m 0644 build/doc/munin-graph.8 $(MANDIR)/man8/
	$(INSTALL) -m 0644 build/doc/munin-update.8 $(MANDIR)/man8/
	$(INSTALL) -m 0644 build/doc/munin-limits.8 $(MANDIR)/man8/
	$(INSTALL) -m 0644 build/doc/munin-html.8 $(MANDIR)/man8/
	$(INSTALL) -m 0644 build/doc/munin-cron.8 $(MANDIR)/man8/

install-doc: build-doc
	mkdir -p $(DOCDIR)
	$(INSTALL) -m 0644 build/doc/munin-doc.html $(DOCDIR)/
	$(INSTALL) -m 0644 build/doc/munin-doc.pdf $(DOCDIR)/
	$(INSTALL) -m 0644 build/doc/munin-doc.txt $(DOCDIR)/
	$(INSTALL) -m 0644 build/doc/munin-faq.html $(DOCDIR)/
	$(INSTALL) -m 0644 build/doc/munin-faq.pdf $(DOCDIR)/
	$(INSTALL) -m 0644 build/doc/munin-faq.txt $(DOCDIR)/
	$(INSTALL) -m 0644 README.* $(DOCDIR)/
	$(INSTALL) -m 0644 COPYING $(DOCDIR)/
	$(INSTALL) -m 0644 node/node.d/README $(DOCDIR)/README.plugins

build: build-stamp

build-stamp:
	@for file in `find . -type f -name '*.in'`; do			\
		destname=`echo $$file | sed 's/.in$$//'`;		\
		echo Generating $$destname..;				\
		mkdir -p build/`dirname $$file`;			\
		sed -e 's|@@PREFIX@@|$(PREFIX)|g'			\
		    -e 's|@@CONFDIR@@|$(CONFDIR)|g'			\
		    -e 's|@@BINDIR@@|$(BINDIR)|g'			\
		    -e 's|@@SBINDIR@@|$(SBINDIR)|g'			\
		    -e 's|@@DOCDIR@@|$(DOCDIR)|g'			\
		    -e 's|@@LIBDIR@@|$(LIBDIR)|g'			\
		    -e 's|@@MANDIR@@|$(MANDIR)|g'			\
		    -e 's|@@LOGDIR@@|$(LOGDIR)|g'			\
		    -e 's|@@HTMLDIR@@|$(HTMLDIR)|g'			\
		    -e 's|@@DBDIR@@|$(DBDIR)|g'				\
		    -e 's|@@STATEDIR@@|$(STATEDIR)|g'			\
		    -e 's|@@PERL@@|$(PERL)|g'				\
		    -e 's|@@PERLLIB@@|$(PERLLIB)|g'			\
		    -e 's|@@PYTHON@@|$(PYTHON)|g'				\
		    -e 's|@@OSTYPE@@|$(OSTYPE)|g'				\
		    -e 's|@@HOSTNAME@@|$(HOSTNAME)|g'			\
		    -e 's|@@VERSION@@|$(VERSION)|g'			\
		    -e 's|@@PLUGSTATE@@|$(PLUGSTATE)|g'			\
		    -e 's|@@CGIDIR@@|$(CGIDIR)|g'			\
		    -e 's|@@USER@@|$(USER)|g'				\
		    -e 's|@@GROUP@@|$(GROUP)|g'				\
		    -e 's|@@PLUGINUSER@@|$(PLUGINUSER)|g'		\
		    $$file > build/$$destname;				\
	done
	touch build-stamp

build-doc: build-doc-stamp

build-doc-stamp:
	mkdir -p build/doc
	-htmldoc munin-doc-base.html > build/doc/munin-doc.html
	-htmldoc -t pdf --webpage build/doc/munin-doc.html > build/doc/munin-doc.pdf
	-html2text -style pretty -nobs build/doc/munin-doc.html > build/doc/munin-doc.txt

	-htmldoc munin-faq-base.html > build/doc/munin-faq.html
	-htmldoc -t pdf --webpage build/doc/munin-faq.html > build/doc/munin-faq.pdf
	-html2text -style pretty -nobs build/doc/munin-faq.html > build/doc/munin-faq.txt

	touch build-doc-stamp

build-man: build-man-stamp

build-man-stamp: build
	mkdir -p build/doc
	pod2man  --section=8 --release=$(RELEASE) --center="Munin Documentation" \
		build/node/munin-node > build/doc/munin-node.8
	pod2man  --section=8 --release=$(RELEASE) --center="Munin Documentation" \
		build/node/munin-run > build/doc/munin-run.8
	pod2man  --section=8 --release=$(RELEASE) --center="Munin Documentation" \
		build/node/munin-node-configure-snmp > build/doc/munin-node-configure-snmp.8
	pod2man  --section=8 --release=$(RELEASE) --center="Munin Documentation" \
		build/node/munin-node-configure > build/doc/munin-node-configure.8
	pod2man  --section=8 --release=$(RELEASE) --center="Munin Documentation" \
		build/server/munin-graph > build/doc/munin-graph.8
	pod2man  --section=8 --release=$(RELEASE) --center="Munin Documentation" \
		build/server/munin-update > build/doc/munin-update.8
	pod2man  --section=8 --release=$(RELEASE) --center="Munin Documentation" \
		build/server/munin-limits > build/doc/munin-limits.8
	pod2man  --section=8 --release=$(RELEASE) --center="Munin Documentation" \
		build/server/munin-html > build/doc/munin-html.8
	pod2man  --section=8 --release=$(RELEASE) --center="Munin Documentation" \
		server/munin-cron.pod > build/doc/munin-cron.8
	pod2man  --section=5 --release=$(RELEASE) --center="Munin Documentation" \
		server/munin.conf.pod > build/doc/munin.conf.5
	pod2man  --section=5 --release=$(RELEASE) --center="Munin Documentation" \
		node/munin-node.conf.pod > build/doc/munin-node.conf.5

	touch build-man-stamp

deb:
	-rm debian
	-ln -s dists/debian
	fakeroot debian/rules binary

rpm-pre:
	@for file in `find dists/redhat/ -type f -name '*.in'`; do			\
		destname=`echo $$file | sed 's/.in$$//'`;		\
		echo Generating $$destname..;				\
		sed -e 's|@@VERSION@@|$(VERSION)|g'			\
		    $$file > $$destname;				\
	done
	-cp dists/tarball/plugins.conf .
#	(cd ..; ln -s munin munin-$(VERSION))

rpm: rpm-pre
	tar -C .. --dereference --exclude .svn -cvzf ../munin_$(RELEASE).tar.gz munin-$(VERSION)/
	(cd ..; rpmbuild -tb munin-$(RELEASE).tar.gz)
	
rpm-src: rpm-pre
	tar -C .. --dereference --exclude .svn -cvzf ../munin_$(RELEASE).tar.gz munin-$(VERSION)/
	(cd ..; rpmbuild -ts munin-$(RELEASE).tar.gz)

+suse-pre:
	@for file in `find dists/suse/ -type f -name '*.in'`; do                \
		destname=`echo $$file | sed 's/.in$$//'`;               \
		echo Generating $$destname..;                           \
		sed -e 's|@@VERSION@@|$(VERSION)|g'                     \
		$$file > $$destname;                                \
	done
	-cp dists/tarball/plugins.conf .
#	(cd ..; ln -s munin munin-$(VERSION))

suse: suse-pre
	tar -C .. --dereference --exclude .svn -cvzf ../munin_$(RELEASE).tar.gz munin-$(VERSION)/
	(cd ..; rpmbuild -tb munin-$(RELEASE).tar.gz)

suse-src: suse-pre
	tar -C .. --dereference --exclude .svn -cvzf ../munin_$(RELEASE).tar.gz munin-$(VERSION)/
	(cd ..; rpmbuild -ts munin-$(RELEASE).tar.gz)

clean:
ifeq ($(MAKELEVEL),0)
	-rm -f debian
	-ln -sf dists/debian
	-fakeroot debian/rules clean
	-rm -f debian
endif
	-rm -rf build
	-rm -f build-stamp
	-rm -f build-doc-stamp
	-rm -f build-man-stamp

source_dist: clean
	(cd ..; ln -s $(DIR) munin-$(VERSION))
	tar -C .. --dereference --exclude .svn -cvzf ../munin_$(RELEASE).tar.gz munin-$(VERSION)/

.PHONY: install install-main install-node install-doc install-man build build-doc deb clean source_dist