File: Makefile

package info (click to toggle)
munin 1.4.5-3+deb6u1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 4,988 kB
  • ctags: 806
  • sloc: perl: 8,936; sh: 3,105; java: 1,754; makefile: 585; python: 143
file content (405 lines) | stat: -rw-r--r-- 15,350 bytes parent folder | download | duplicates (2)
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# -*- makefile -*-
#
# Gnu make only.  Seriously.
#
# $Id: Makefile 3265 2009-12-29 16:03:49Z janl $

# Defaults/paths. Allows $(CONFIG) to be overrided by
# make command line
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/^.*\///')
INFILES          := $(shell find . -name '*.in' | sed 's/\.\/\(.*\)\.in$$/build\/\1/')
INFILES_MASTER   := $(shell find master -name '*.in' | sed 's/\(.*\)\.in$$/build\/\1/')
CLASSFILES       := $(shell find plugins/javalib/ -name '*.java' | sed 's/\(.*\)\.java$$/build\/\1.class/')
PLUGINS		 := $(wildcard plugins/node.d.$(OSTYPE)/* plugins/node.d/*)
MANCENTER        := "Munin Documentation"
MAN8		 := master/_bin/munin-graph master/_bin/munin-update \
			master/_bin/munin-limits master/_bin/munin-html
PODMAN8          := build/master/doc/munin-cron master/doc/munin master/doc/munin-check
PODMAN5          := build/master/doc/munin.conf node/doc/munin-node.conf


.PHONY: install install-pre install-master-prime install-node-prime install-node-pre install-common-prime install-doc install-man \
        build build-common-prime build-common-pre build-doc \
        source_dist \
        test clean \
        clean-% test-% build-% install-% \
	tags

.SECONDARY: node/Build master/Build plugins/Build

.SUFFIXES: .java .class

.java.class:
	cd plugins/javalib && $(JC) $(JFLAGS) $(subst plugins/javalib/,,$*.java)

default: build

uninstall: 
	echo "Uninstall is not implemented yet"

# This removes the installed config so that the next install-pass installs
# a new config.  Target _only_ suitable for maintainers.
unconfig:
	rm -f $(HTMLDIR)/.htaccess
	rm -f $(CONFDIR)/munin.conf

tags:
	-rm -f TAGS
	find master common -type f | egrep -v '/(build/|_build/|blib/|\.svn/)' | grep -v '\.t$$' | fgrep -v '~' | xargs etags -l perl -a

######################################################################

ifeq ($(JCVALID),yes)
install: install-master-prime install-common-prime install-node-prime install-plugins-prime install-plugins-java install-man
else
install: install-master-prime install-common-prime install-node-prime install-plugins-prime install-man
endif

install-pre: Makefile Makefile.config
	@$(CHECKUSER)
	mkdir -p $(LOGDIR)
	mkdir -p $(STATEDIR)
	mkdir -p $(CONFDIR)
	$(CHOWN) $(USER) $(LOGDIR) $(STATEDIR)

install-master-prime: $(INFILES_MASTER) install-pre install-master
	mkdir -p $(CONFDIR)/templates
	mkdir -p $(CONFDIR)/templates/partial
	mkdir -p $(CONFDIR)/munin-conf.d
	mkdir -p $(LIBDIR)
	mkdir -p $(BINDIR)
	mkdir -p $(PERLLIB)
	mkdir -p $(PERLLIB)/Munin/Master
	mkdir -p $(HTMLDIR)
	mkdir -p $(DBDIR)
	mkdir -p $(CGIDIR)

	$(CHOWN) $(USER) $(HTMLDIR) $(DBDIR) 
	$(CHMOD) 0755 $(DBDIR)

	for p in master/www/*.tmpl master/www/*.png master/www/*.css resources/favicon.ico; do \
		$(INSTALL) -m 0644 "$$p" $(CONFDIR)/templates/ ; \
	done

	for p in master/www/partial/*.tmpl; do \
		$(INSTALL) -m 0644 "$$p" $(CONFDIR)/templates/partial/ ; \
	done

	$(INSTALL) -m 0644 master/www/definitions.html $(CONFDIR)/templates/
	$(INSTALL) -m 0755 master/DejaVuSansMono.ttf $(LIBDIR)/
	$(INSTALL) -m 0755 master/DejaVuSans.ttf $(LIBDIR)/

	test -f $(HTMLDIR)/.htaccess || $(INSTALL) -m 0644 build/master/www/munin-htaccess $(HTMLDIR)/.htaccess
	test -f "$(CONFDIR)/munin.conf"  || $(INSTALL) -m 0644 build/master/munin.conf $(CONFDIR)/

	$(INSTALL) -m 0755 build/master/_bin/munin-cron $(BINDIR)/
	$(INSTALL) -m 0755 build/master/_bin/munin-check $(BINDIR)/
	$(INSTALL) -m 0755 build/master/_bin/munin-update $(LIBDIR)/
	$(INSTALL) -m 0755 build/master/_bin/munin-graph $(LIBDIR)/
	$(INSTALL) -m 0755 build/master/_bin/munin-html $(LIBDIR)/
	$(INSTALL) -m 0755 build/master/_bin/munin-limits $(LIBDIR)/
	$(INSTALL) -m 0755 build/master/_bin/munin-cgi-graph $(CGIDIR)/
	$(INSTALL) -m 0755 build/master/_bin/munin-fastcgi-graph $(CGIDIR)/

# Not ready to be installed yet	
# $(INSTALL) -m 0755 build/master/_bin/munin-gather $(LIBDIR)/

# ALWAYS DO THE OS SPECIFIC PLUGINS LAST! THAT WAY THEY OVERWRITE THE
# GENERIC ONES

install-node-plugins: install-plugins-prime

# Some HP-UX plugins needs *.adv support files in LIBDIR
install-plugins-prime: install-plugins build $(PLUGINS) Makefile Makefile.config
	@$(CHECKGROUP)

	mkdir -p $(CONFDIR)/plugins
	mkdir -p $(CONFDIR)/plugin-conf.d
	mkdir -p $(LIBDIR)/plugins
	mkdir -p $(PLUGSTATE)

	$(CHOWN) $(PLUGINUSER):$(GROUP) $(PLUGSTATE)
	$(CHMOD) 0775 $(PLUGSTATE)
	$(CHMOD) 0755 $(CONFDIR)/plugin-conf.d

	for p in build/plugins/node.d/* build/plugins/node.d.$(OSTYPE)/* ; do \
	    if test -f "$$p" ; then                            \
		echo Installing $$p;                           \
		$(INSTALL) -m 0755 $$p $(LIBDIR)/plugins/;     \
	    fi                                                 \
	done
	-mv $(LIBDIR)/plugins/*.adv $(LIBDIR)
	$(INSTALL) -m 0644 build/plugins/plugins.history $(LIBDIR)/plugins/
	$(INSTALL) -m 0644 build/plugins/plugin.sh $(LIBDIR)/plugins/

install-plugins-java: build-plugins-java
	mkdir -p $(JAVALIBDIR)
	$(INSTALL) -m 0644 build/plugins/javalib/munin-jmx-plugins.jar $(JAVALIBDIR)/

#TODO:
# configure plugins.  Or not. Better done under the direction of the installer
# or the packager.

install-node-prime: install-node-pre install-node

install-node-pre: build/node/munin-node.conf install-pre
	test -f "$(CONFDIR)/munin-node.conf" || $(INSTALL) -m 0644 build/node/munin-node.conf $(CONFDIR)/


install-common-prime: build-common install-common


install-man: build-man Makefile Makefile.config
	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-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) -m 0644 build/doc/munin-check.8 $(MANDIR)/man8/
	$(INSTALL) -m 0644 build/doc/munin.8 $(MANDIR)/man8/


install-doc: build-doc
	mkdir -p $(DOCDIR)/resources
	$(INSTALL) -m 0644 README $(DOCDIR)/
	$(INSTALL) -m 0644 COPYING $(DOCDIR)/
	$(INSTALL) -m 0644 build/resources/* $(DOCDIR)/resources

######################################################################

ifeq ($(JCVALID),yes)
build: $(INFILES) build-master build-common-prime build-node build-plugins build-plugins-java build-man
else
build: $(INFILES) build-master build-common-prime build-node build-plugins build-man
endif

build/%: %.in
	@echo "$< -> $@"
	@mkdir -p build/`dirname $<`
	@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|@@RUBY@@|$(RUBY)|g'                          \
             -e 's|@@JAVARUN@@|$(JAVARUN)|g'                    \
             -e 's|@@JAVALIBDIR@@|$(JAVALIBDIR)|g'              \
             -e 's|@@OSTYPE@@|$(OSTYPE)|g'                      \
             -e 's|@@HOSTNAME@@|$(HOSTNAME)|g'                  \
             -e 's|@@MKTEMP@@|$(MKTEMP)|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'              \
             -e 's|@@GOODSH@@|$(GOODSH)|g'                      \
             -e 's|@@BASH@@|$(BASH)|g'                          \
             -e 's|@@HASSETR@@|$(HASSETR)|g'                    \
             -e 's|@@SSPOOLDIR@@|$(SSPOOLDIR)|g'                \
             $< > $@;


build-common-prime: build-common-pre common/blib/lib/Munin/Common/Defaults.pm build-common

build-common-pre: common/Build
	cd common && $(PERL) Build code
	rm -f common/blib/lib/Munin/Common/Defaults.pm

common/blib/lib/Munin/Common/Defaults.pm: common/lib/Munin/Common/Defaults.pm build-common-pre
	$(PERL) -pe 's{(PREFIX     \s+=\s).*}{\1q{$(PREFIX)};}x;   \
                  s{(CONFDIR    \s+=\s).*}{\1q{$(CONFDIR)};}x;     \
                  s{(BINDIR     \s+=\s).*}{\1q{$(BINDIR)};}x;      \
                  s{(SBINDIR    \s+=\s).*}{\1q{$(SBINDIR)};}x;     \
                  s{(DOCDIR     \s+=\s).*}{\1q{$(DOCDIR)};}x;      \
                  s{(LIBDIR	\s+=\s).*}{\1q{$(LIBDIR)};}x;      \
                  s{(MANDIR	\s+=\s).*}{\1q{$(MANDIR)};}x;      \
                  s{(LOGDIR	\s+=\s).*}{\1q{$(LOGDIR)};}x;      \
                  s{(HTMLDIR	\s+=\s).*}{\1q{$(HTMLDIR)};}x;     \
                  s{(DBDIR	\s+=\s).*}{\1q{$(DBDIR)};}x;       \
                  s{(STATEDIR	\s+=\s).*}{\1q{$(STATEDIR)};}x;    \
                  s{(PERL	\s+=\s).*}{\1q{$(PERL)};}x;        \
                  s{(PERLLIB	\s+=\s).*}{\1q{$(PERLLIB)};}x;     \
                  s{(PYTHON	\s+=\s).*}{\1q{$(PYTHON)};}x;      \
                  s{(RUBY       \s+=\s).*}{\1q{$(RUBY)};}x;        \
                  s{(OSTYPE	\s+=\s).*}{\1q{$(OSTYPE)};}x;      \
                  s{(HOSTNAME	\s+=\s).*}{\1q{$(HOSTNAME)};}x;    \
                  s{(MKTEMP	\s+=\s).*}{\1q{$(MKTEMP)};}x;      \
                  s{(VERSION	\s+=\s).*}{\1q{$(VERSION)};}x;     \
                  s{(PLUGSTATE	\s+=\s).*}{\1q{$(PLUGSTATE)};}x;   \
                  s{(CGIDIR	\s+=\s).*}{\1q{$(CGIDIR)};}x;      \
                  s{(USER	\s+=\s).*}{\1q{$(USER)};}x;        \
                  s{(GROUP	\s+=\s).*}{\1q{$(GROUP)};}x;       \
                  s{(PLUGINUSER	\s+=\s).*}{\1q{$(PLUGINUSER)};}x;  \
                  s{(GOODSH	\s+=\s).*}{\1q{$(GOODSH)};}x;      \
                  s{(BASH	\s+=\s).*}{\1q{$(BASH)};}x;        \
                  s{(HASSETR	\s+=\s).*}{\1q{$(HASSETR)};}x;     \
	          s{(SSPOOLDIR	\s+=\s).*}{\1q{$(SSPOOLDIR)};}x;'  \
                  $< > $@

build-doc: build-doc-stamp Makefile Makefile.config

build-doc-stamp:
	touch build-doc-stamp
	mkdir -p build/doc

build-man: build-man-stamp 

build-man-stamp: build Makefile Makefile.config
	touch build-man-stamp
	mkdir -p build/doc
	for f in $(MAN8); do \
	   pod2man --section=8 --release=$(RELEASE) --center=$(MANCENTER) build/"$$f" > build/doc/`basename $$f`.8; \
	done
	for f in $(PODMAN8); do \
	   pod2man --section=8 --release=$(RELEASE) --center=$(MANCENTER) "$$f".pod > build/doc/`basename $$f .pod`.8; \
	done
	for f in $(PODMAN5); do \
	   pod2man --section=5 --release=$(RELEASE) --center=$(MANCENTER) "$$f".pod > build/doc/`basename $$f .pod`.5; \
	done

build-plugins-java: build/plugins/javalib/munin-jmx-plugins.jar

build/plugins/javalib/munin-jmx-plugins.jar: $(CLASSFILES)
	cd build/plugins/javalib && $(JAR) cf munin-jmx-plugins.jar org/munin/plugin/jmx

build/%.class: %.class
	mkdir -p build/`dirname $*.class`
	cp $*.class build/$*.class

######################################################################
# DIST RULES

tar-pre:
	(! grep MAINTAINER Makefile.config)
	find . -name '*~' -exec rm -fv {} \;
	PWD=`pwd`
	-rm -f ../munin-$(VERSION)
	(cd ..; ln -s $(PWD) munin-$(VERSION))

tar: tar-pre
	GZIP=-9 tar -C .. --dereference --exclude .svn -cvzf ../munin-$(RELEASE).tar.gz munin-$(VERSION)/


suse-pre:
	(! grep MAINTAINER Makefile.config)
	@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)

source_dist: clean
	(! grep MAINTAINER Makefile.config)
	(cd .. && ln -s $(DIR) munin-$(VERSION))
	tar -C .. --dereference --exclude .svn -cvzf ../munin_$(RELEASE).tar.gz munin-$(VERSION)/
	(cd .. && rm munin-$(VERSION))

######################################################################

ifeq ($(MAKELEVEL),0)
clean: clean-node clean-master clean-plugins clean-common
else
clean:
endif
	-rm -rf build
	-rm -f build-stamp
	-rm -f build-doc-stamp
	-rm -f build-man-stamp
	-rm -rf t/install

	-rm -f dists/redhat/munin.spec
	-rm -f dists/suse/munin.spec


######################################################################

test: test-common test-master test-node test-plugins

ifeq ($(MAKELEVEL),0)
# Re-exec make with the test config
old-test: t/*.t
	$(MAKE) $@ CONFIG=t/Makefile.config
else
test_plugins = id_default id_root env
old-test: t/*.t t/install $(addprefix $(CONFDIR)/plugins/,$(test_plugins))
	@for test in t/*.t; do \
		echo -n "$$test: "; \
		PERL5LIB=$(PERLLIB) $(PERL) $$test;\
	done
endif

node-monkeywrench: install-node
	rm -rf $(CONFDIR)/plugins
	rm -rf $(LIBDIR)/plugins
	mkdir -p $(LIBDIR)/plugins
	mkdir -p $(CONFDIR)/plugins
	cp monkeywrench/plugin-break*_ $(LIBDIR)/plugins/
	$(SBINDIR)/munin-node-configure --suggest
	echo 'Done?'

t/install: 
	$(MAKE) clean install-node-prime install-node-plugins CONFIG=t/Makefile.config INSTALL_PLUGINS=test


######################################################################

# This builds */Build from Build.PL
%/Build: %/Build.PL
	cd $* && $(PERL) Build.PL

build-%: %/Build
	cd $* && $(PERL) Build

build-common: common/Build
	cd common && $(PERL) Build && rm -f common/blib/lib/Munin/Common/Defaults.pm && true


# BUG: the Build script writes files under PWD when it does "install"
# can't seem to find a way to persuade it to write otherwhere.
install-%: %/Build
	cd $* && $(PERL) Build install			\
            --install_path lib=$(PERLLIB)		\
            --install_path bin=$(BINDIR)		\
            --install_path script=$(BINDIR)		\
            --install_path sbin=$(SBINDIR)		\
            --install_path bindoc=$(MANDIR)/man1	\
            --install_path libdoc=$(MANDIR)/man3	\

test-%: %/Build
	cd $* && $(PERL) Build test || true

clean-%: %/Build common/blib/lib/Munin/Common/Defaults.pm
	cd $* && $(PERL) Build realclean