File: common.mk

package info (click to toggle)
nagios-plugins-contrib 4.20120702
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,128 kB
  • sloc: perl: 23,621; sh: 3,668; lex: 550; makefile: 368; php: 333; python: 301; ruby: 96; awk: 81
file content (66 lines) | stat: -rw-r--r-- 1,870 bytes parent folder | download | duplicates (3)
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

# import buildflags
CFLAGS += $(shell dpkg-buildflags --get CFLAGS)
CPPFLAGS += $(shell dpkg-buildflags --get CPPFLAGS)
CXXFLAGS += $(shell dpkg-buildflags --get CXXFLAGS)
LDFLAGS += $(shell dpkg-buildflags --get LDFLAGS)

# define common directories
PLUGINDIR := /usr/lib/nagios/plugins
CRONJOBDIR := /usr/lib/nagios/cronjobs
CONFIGDIR := /etc/nagios-plugins/config
INIDIR := /etc/nagios-plugins
CONFIGFILES := $(wildcard *.cfg)

# guess the name of the plugin to build if not defined
PLUGINNAME := $(shell basename $(CURDIR))
ifndef PLUGIN
PLUGIN := $(PLUGINNAME)
endif

DOCDIR := /usr/share/doc/nagios-plugins-contrib/$(PLUGINNAME)

# add some default files to clean
# we actually need strip here. make is weird sometimes.
CLEANEXTRAFILES := $(strip $(wildcard *.o) $(wildcard *.a) $(wildcard *.so))

# build the stuff actually
all:: $(PLUGIN) $(MANPAGES) $(INIFILES) $(CRONJOBS)

install::
	install -d $(DESTDIR)$(PLUGINDIR)
	install -m 755 -o root -g root $(PLUGIN) $(DESTDIR)$(PLUGINDIR)
ifdef CONFIGFILES
	install -d $(DESTDIR)$(CONFIGDIR)
	install -m 644 -o root -g root $(CONFIGFILES) $(DESTDIR)$(CONFIGDIR)
endif
ifdef MANPAGES
	set -e; for m in $(MANPAGES); do \
		section=`echo $$m | sed 's,\.gz$$,,;s,.*\.,,'` ;\
		mandir="/usr/share/man/man$${section}" ;\
		install -d $(DESTDIR)$${mandir} ;\
		install -m 644 -o root -g root $${m} $(DESTDIR)$${mandir} ;\
	done
endif
ifdef INIFILES
	install -d $(DESTDIR)$(INIDIR)
	install -m 644 -o root -g root $(INIFILES) $(DESTDIR)$(INIDIR)
endif
ifdef DOCFILES
	install -d $(DESTDIR)$(DOCDIR)
	install -m 644 -o root -g root $(DOCFILES) $(DESTDIR)$(DOCDIR)
endif
ifdef CRONJOBS
	install -d $(DESTDIR)$(CRONJOBDIR)
	install -m 755 -o root -g root $(CRONJOBS) $(DESTDIR)$(CRONJOBDIR)
endif

clean::
ifdef CLEANFILES
	rm -f $(CLEANFILES)
endif
ifneq (,$(CLEANEXTRAFILES))
	rm -f $(CLEANEXTRAFILES)
endif

.PHONY: clean