File: rules

package info (click to toggle)
nagios2 2.6-2%2Betch5
  • links: PTS
  • area: main
  • in suites: etch
  • size: 6,856 kB
  • ctags: 4,475
  • sloc: ansic: 64,870; sh: 4,676; makefile: 787; perl: 722
file content (198 lines) | stat: -rwxr-xr-x 6,437 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
#!/usr/bin/make -f
# debian/rules makefile for nagios2
# Last modified:
# $Id: rules 1091 2006-12-19 22:00:24Z zugschlus $

# export DH_VERBOSE=1

b := $(shell pwd)/debian
bnc := $b/nagios2-common
bnd := $b/nagios2-doc

export DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

# -Wall disabled until source is fixed to not print tons of warnings with it. :)
#CFLAGS = -Wall -g
CFLAGS = -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif

SHELL		= /bin/sh -e
CONFIGURE	= CFLAGS='$(CFLAGS)' ./configure --prefix=/usr \
				--mandir=/usr/share/man \
				--bindir=/usr/sbin \
				--sbindir=/usr/lib/cgi-bin/nagios2 \
				--datadir=/usr/share/nagios2/htdocs \
				--sysconfdir=/etc/nagios2 \
				--infodir=/usr/share/info \
				--libexecdir=/usr/lib/nagios/plugins \
				--localstatedir=/var/lib/nagios2 \
				--enable-event-broker \
				--enable-embedded-perl \
				--with-nagios-user=nagios \
				--with-nagios-group=nagios \
				--with-command-user=nagios \
				--with-command-group=nagios \
				--with-init-dir=/etc/init.d \
				--with-lockfile=/var/run/nagios2/nagios2.pid \
				--with-mail=/usr/bin/mail \
				--with-perlcache \
				--build=$(DEB_BUILD_GNU_TYPE) \
				--host=$(DEB_HOST_GNU_TYPE) \
				--with-htmurl=/nagios2 \
				--with-cgiurl=/cgi-bin/nagios2

unpack-configs: unpack-configs-stamp
unpack-configs-stamp: configure-stamp
	mkdir -p debian-configs
	for cfg in $$(ls debian/cfg-*.diff); do \
	  TARGETNAME=$$(basename $$cfg .diff | sed 's/^cfg-//'); \
	  echo $$TARGETNAME; \
	  DISTNAME="sample-config/$$TARGETNAME"; \
	  if ! [ -e "$$DISTNAME" ]; then \
	    DISTNAME="sample-config/template-object/$$TARGETNAME"; \
	  fi; \
	  echo patch -o debian-configs/$$TARGETNAME $$DISTNAME $$cfg; \
	  patch -o debian-configs/$$TARGETNAME $$DISTNAME $$cfg; \
	done; \
	if [ -e "debian-configs/*.rej" ]; then \
	  echo "diffs to config file didn't match. Stop."; \
	  exit 1; \
	fi
	touch unpack-configs-stamp

pack-configs: patch
	for cfg in $$(ls debian-configs/*); do \
	  TARGETNAME=$$(basename $$cfg); \
	  DISTNAME="sample-config/$$TARGETNAME"; \
	  if ! [ -e "$$DISTNAME" ]; then \
	    DISTNAME="sample-config/template-object/$$TARGETNAME"; \
	  fi; \
	  echo diff -u $$DISTNAME $$cfg; \
	  diff -uN $$DISTNAME $$cfg > debian/cfg-$${TARGETNAME}.diff || true; \
	done
	rm -f unpack-configs-stamp

clean: clean-patched unpatch
clean-patched:
	dh_testdir -a
	dh_testroot -a
	#-rm -Rf docs examples {build,config}-nagios-{text,pgsql,mysql}-stamp
	if test -f Makefile; then make distclean; fi
	#-rm -Rf {cgi,base}/*.{mysql,pgsql,text}
	rm -f {patch,install,configure,build,unpack-configs}-stamp
	rm -rf debian-configs
	#-rm debian/templates.merged subst
	find -type d -name autom4te.cache -print0 | xargs -0 -r rm -rf \;
	-rm -f platform.h auto-include.h
	find -type d -name build -print0 | xargs -0 -r rm -rf \;
	find \( -name config.sub -o -name config.guess \) -print0 | xargs -0 -r rm -f \;
	dh_clean
	debconf-updatepo

configure: configure-stamp
configure-stamp:
	dh_testdir -a
	@echo "Doing $@"
	if test -f Makefile; then make clean; fi
	ln -sf /usr/share/misc/config.sub .
	ln -sf /usr/share/misc/config.guess .
	rm -f config.cache
	$(CONFIGURE)
	touch configure-stamp

build: build-stamp
build-stamp: patch-stamp configure-stamp
	dh_testdir -a
	@echo "Doing $@"
	$(MAKE) all
	touch build-stamp

patch: patch-stamp
patch-stamp:
	@echo "Doing $@"
	dpatch  --with-cpp apply-all
	dpatch  --with-cpp cat-all >patch-stamp 

unpatch:
	@echo "Doing $@"
	dpatch --with-cpp deapply-all
	rm -rf patch-stamp debian/patched

install: install-stamp
install-stamp: build-stamp unpack-configs-stamp
	@echo "Doing $@"
	dh_testdir -a
	dh_testroot -a
	dh_installdirs -a -i
	# zero out INSTALL_OPTS to prevent chowning at build-time
	make install-unstripped DESTDIR=$b/nagios2 INSTALL_OPTS=""
	# move some arch-indep stuff to the other packages
	cp -a $b/nagios2/usr/share/nagios2/htdocs ${bnd}/usr/share/nagios2/
	rm -rf $b/nagios2/usr/share/nagios2
	# remove empty directory
	rmdir --ignore-fail-on-non-empty -p $b/nagios2/var/lib/nagios2/archives
	# set up /var/cache/nagios2 for access by www-data
	chgrp www-data ${bnc}/var/cache/nagios2
	chmod g+s ${bnc}/var/cache/nagios2
	chown root:www-data ${bnc}/var/lib/nagios2/rw
	chmod 700 ${bnc}/var/lib/nagios2/rw
	# alter some installed filenames/locations
	mv ${b}/nagios2/usr/sbin/nagios ${b}/nagios2/usr/sbin/nagios2
	mv ${b}/nagios2/usr/sbin/nagiostats ${b}/nagios2/usr/sbin/nagios2stats
	mv ${b}/nagios2/usr/sbin/p1.pl ${b}/nagios2/usr/lib/nagios2/p1.pl
	chmod 755 ${b}/nagios2/usr/lib/nagios2/p1.pl
	dh_installdocs       -i
	dh_installman        -a -pnagios2
	dh_installlogrotate
	dh_installchangelogs -i
	dh_install           -i
	dh_installinit 	     --name nagios2 -- defaults 30 18
	dh_installexamples   -i
	# and now set up the "nagios1 version" of the apache2.conf
	sed -e 's,^#\(ScriptAlias /cgi-bin/nagios /usr/lib/cgi-bin/nagios2\),\1,' \
	    -e 's,^#\(ScriptAlias /nagios/cgi-bin /usr/lib/cgi-bin/nagios2\),\1,' \
		-e 's,^#\(Alias /nagios /usr/share/nagios2/htdocs\),\1,' \
		-e 's,^ #\(AuthUserFile /etc/nagios/htpasswd.users\),   \1,' \
		${bnc}/usr/share/doc/nagios2-common/examples/apache2.conf > ${bnc}/usr/share/doc/nagios2-common/examples/apache2.nagios1.conf
	touch install-stamp

binary: binary-arch binary-indep
binary-arch: install-stamp
	@echo "Doing $@"
	dh_testdir           -a
	dh_testroot          -a
	dh_link		     -a
	dh_installchangelogs -a
	dh_installdocs       -a
	dh_install           -a
	chmod 600 ${b}/nagios2-common/etc/nagios2/resource.cfg
	dh_strip             -a  --dbg-package=nagios2-dbg
	dh_compress          -a
	dh_fixperms          -a -X/var/cache/nagios2
	dh_installdeb        -a
	dh_perl		     -a
	dh_shlibdeps         -a
	dh_gencontrol        -a
	dh_makeshlibs        -a -V
	dh_md5sums           -a
	dh_builddeb          -a

binary-indep: install-stamp
	# XXX some stuff below here is commented out
	#install -m 755 cgi/grouplist.cgi.in debian/$@/usr/lib/cgi-bin/nagios/grouplist.cgi
	dh_link		     -i
	dh_compress          -i
	dh_fixperms          -i -Xnagios2/resource.cfg
	dh_installdebconf    -i
	dh_perl		     -i
	dh_installdeb        -i
	dh_gencontrol        -i
	dh_md5sums           -i
	dh_builddeb          -i

.PHONY: binary-indep binary-arch build configure binary install patch unpatch