File: rules

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 (96 lines) | stat: -rwxr-xr-x 3,279 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
#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

PLUGINS := $(shell find $(CURDIR) -mindepth 1 -maxdepth 1 -name .git -prune -o -name .pc -prune -o -name debian -prune -o -type d -printf '%f\n' | sort)

%:
	dh $@ --with quilt,python2 --parallel

# Here follows a small shell snipped to call dh_auto_* for all plugins
# Currently
# - if a Makefile exists in the plugin directory
#   we run dh_auto_$(1) with -O--sourcedirectory="$$plugin"
# - if $${plugin}/src exists, we run dh_auto_$(1) on that directory
# - else: fail :)
DH_AUTO_CALL = 	  if [ -f $(CURDIR)/$$plugin/Makefile ]; then \
			$$auto_command -O--sourcedirectory="$${plugin}" $$options; \
		  elif [ -d $(CURDIR)/$$plugin/src ]; then \
			$$auto_command -O--sourcedirectory="$${plugin}/src" $$options; \
		  else \
			echo failed to build $$plugin; exit 255 ; \
		  fi

PACKAGING_HELPER = /usr/bin/python $(CURDIR)/debian/packaging-helper.py


clean: $(PLUGINS:%=clean-%) debian/copyright debian/control
	dh $@ --with quilt,python2 --parallel
	rm -f debian/nagios-plugins-contrib.install
	rm -f debian/README.Debian.plugins

clean-%:
	rm -rf debian/$*

dh_auto_install-%:
	# run dh_auto_install to debian/$plugin
	set -e ;\
	    export auto_command="dh_auto_install" ;\
	    export plugin="$*" ;\
	    export options="--destdir=debian/$*" ;\
	    $(DH_AUTO_CALL)
	# add files to debian/nagios-plugins-contrib.install
	set -e; find debian/$* -type f -printf '%h\n' | sort -u  |\
	    while read dir; do \
	        echo "$$dir/* `echo $$dir | sed 's,debian/$*/,,'`" ;\
	    done >> debian/nagios-plugins-contrib.install
	# create shlibdeps for the plugin into a temp file
	set -e; \
	   opts=`find debian/$* -type f -exec file {} \; |\
	   grep -E ' ELF ' |\
	   sed 's,:.*,,;s,^,-e,' |\
	   tr '\n' ' '` ;\
	   if [ -n "$$opts" ]; then \
	   	dpkg-shlibdeps -O $$opts | grep shlibs:Depends > debian/$*/substvars ;\
	   fi
       
dh_auto_%:
	set -e; \
	    export auto_command=`echo $* | sed 's,-.*,,;s,^,dh_auto_,'` ;\
	    export plugin=`echo $* | sed 's,.*-,,'` ;\
	    $(DH_AUTO_CALL)


override_dh_auto_build: $(PLUGINS:%=dh_auto_build-%)

override_dh_auto_clean: $(PLUGINS:%=dh_auto_clean-%)

override_dh_auto_configure: $(PLUGINS:%=dh_auto_configure-%)

override_dh_auto_install: $(PLUGINS:%=dh_auto_install-%)
	$(PACKAGING_HELPER) --generate-readme

#override_dh_auto_test: $(PLUGINS:%=dh_auto_test-%)
override_dh_auto_test: 
	# nothign to do right now.

override_dh_python2:
	dh_python2 usr/lib/nagios/plugins usr/lib/nagios/cronjobs

CONTROL_FILES := $(shell for p in $(PLUGINS); do echo $$p/control; done)
COPYRIGHT_FILES := $(shell for p in $(PLUGINS); do echo $$p/copyright; done)
debian/copyright: debian/copyright.in debian/packaging-helper.py $(CONTROL_FILES) $(COPYRIGHT_FILES)
	$(PACKAGING_HELPER) --copyright
	-if [ -d .git ]; then git add $@; git commit -m 'Auto update of $@' $@; fi

debian/control: debian/control.in debian/packaging-helper.py $(CONTROL_FILES)
	$(PACKAGING_HELPER) --control
	-if [ -d .git ]; then git add $@; git commit -m 'Auto update of $@' $@; fi


watch:
	@$(PACKAGING_HELPER) --watch

.PHONY: watch override_dh_auto_build override_dh_auto_clean override_dh_auto_configure override_dh_auto_install override_dh_auto_test