check_logfiles: update to 3.7.1
[omd.git] / Makefile
blobd015568b41b8f8382fbd6ad38f5a6612b525c3c3
1 SHELL = /bin/bash
2 # You can select a subset of the packages by overriding this
3 # variale, e.g. make PACKAGES='nagios rrdtool' pack
4 PACKAGES=perl-modules \
5 python-modules \
6 apache-omd \
7 mod_python \
8 check_logfiles \
9 check_mk \
10 check_multi \
11 check_mysql_health \
12 check_oracle_health \
13 check_webinject \
14 dokuwiki \
15 example \
16 jmx4perl \
17 mk-livestatus \
18 mysql-omd \
19 icinga \
20 nagios \
21 monitoring-plugins \
22 nagvis \
23 nrpe \
24 nsca \
25 omd \
26 pnp4nagios \
27 rrdtool \
28 shinken \
29 thruk \
30 maintenance \
31 gearmand \
32 mod-gearman \
33 patch \
34 nail \
35 notifications-tt
37 include Makefile.omd
39 # If you just want to test package building, you can reduce the
40 # number of packages to just "omd" - to speed up your tests.
41 # PACKAGES="omd"
43 # This file is kept by 'make config' and also may override
44 # the list of packages
45 -include .config
47 DESTDIR ?=$(shell pwd)/destdir
48 RPM_TOPDIR=$$(pwd)/rpm.topdir
49 DPKG_TOPDIR=$$(pwd)/dpkg.topdir
50 SOURCE_TGZ=omd-$(OMD_VERSION).tar.gz
51 BIN_TGZ=omd-bin-$(OMD_VERSION).tar.gz
52 NEWSERIAL=$$(($(OMD_SERIAL) + 1))
53 APACHE_NAME=$(APACHE_INIT_NAME)
55 .PHONY: install-global
57 omd: build
59 build:
60 @set -e ; cd packages ; for p in $(PACKAGES) ; do \
61 $(MAKE) -C $$p build ; \
62 done
64 speed:
65 @set -e ; cd packages ; for p in $(PACKAGES) ; do \
66 ( NOW=$$(date +%s) ; \
67 $(MAKE) -C $$p build > ../$$p.log 2>&1 \
68 && echo "$$p(ok - $$(( $$(date +%s) - NOW ))s)" \
69 || echo "$$p(ERROR - $$(( $$(date +%s) - NOW ))s)" ) & \
70 done ; wait ; echo "FINISHED."
72 pack:
73 rm -rf $(DESTDIR)
74 mkdir -p $(DESTDIR)$(OMD_PHYSICAL_BASE)
75 A="$(OMD_PHYSICAL_BASE)" ; ln -s $${A:1} $(DESTDIR)/omd
76 @set -e ; cd packages ; for p in $(PACKAGES) ; do \
77 $(MAKE) -C $$p DESTDIR=$(DESTDIR) install ; \
78 for hook in $$(cd $$p ; ls *.hook 2>/dev/null) ; do \
79 mkdir -p $(DESTDIR)$(OMD_ROOT)/lib/omd/hooks ; \
80 install -m 755 $$p/$$hook $(DESTDIR)$(OMD_ROOT)/lib/omd/hooks/$${hook%.hook} ; \
81 done ; \
82 done
84 # Repair packages that install with silly modes (such as Nagios)
85 chmod -R o+Xr $(DESTDIR)$(OMD_ROOT)
86 $(MAKE) install-global
88 # Install skeleton files (subdirs skel/ in packages' directories)
89 mkdir -p $(DESTDIR)$(OMD_ROOT)/skel
90 @set -e ; cd packages ; for p in $(PACKAGES) ; do \
91 if [ -d "$$p/skel" ] ; then \
92 tar cf - -C $$p/skel --exclude="*~" --exclude=".gitignore" . | tar xvf - -C $(DESTDIR)$(OMD_ROOT)/skel ; \
93 fi ;\
94 $(MAKE) SKEL=$(DESTDIR)$(OMD_ROOT)/skel -C $$p skel ;\
95 done
97 # Create permissions file for skel
98 mkdir -p $(DESTDIR)$(OMD_ROOT)/share/omd
99 @set -e ; cd packages ; for p in $(PACKAGES) ; do \
100 if [ -e $$p/skel.permissions ] ; then \
101 echo "# $$p" ; \
102 cat $$p/skel.permissions ; \
103 fi ; \
104 done > $(DESTDIR)$(OMD_ROOT)/share/omd/skel.permissions
106 # Make sure, all permissions in skel are set to 0755, 0644
107 @failed=$$(find $(DESTDIR)$(OMD_ROOT)/skel -type d -not -perm 0755) ; \
108 if [ -n "$$failed" ] ; then \
109 echo "Invalid permissions for skeleton dirs. Must be 0755:" ; \
110 echo "I'll fix this for you this time..." ; \
111 chmod -c 755 $$failed ; \
112 echo "$$failed" ; \
114 @failed=$$(find $(DESTDIR)$(OMD_ROOT)/skel -type f -not -perm 0644) ; \
115 if [ -n "$$failed" ] ; then \
116 echo "Invalid permissions for skeleton files. Must be 0644:" ; \
117 echo "$$failed" ; \
118 echo "I'll fix this for you this time..." ; \
119 chmod -c 644 $$failed ; \
122 # Fix packages which did not add ###ROOT###
123 find $(DESTDIR)$(OMD_ROOT)/skel -type f | xargs -n1 sed -i -e 's+$(OMD_ROOT)+###ROOT###+g'
125 # Remove site-specific directories that went under /omd/version
126 rm -rf $(DESTDIR)/{var,tmp}
128 # Pack the whole stuff into a tarball
129 tar czf $(BIN_TGZ) --owner=root --group=root -C $(DESTDIR) .
131 clean:
132 rm -rf $(DESTDIR)
133 @for p in packages/* ; do \
134 $(MAKE) -C $$p clean ; \
135 done
137 mrproper:
138 git clean -xfd
140 config:
141 @inarray () { \
142 elem="$$1" ; \
143 shift ; \
144 for x in "$$@" ; do if [ $$elem = $$x ] ; then return 0 ; fi ; done ; \
145 return 1 ; \
146 } ; \
147 if [ "$(PACKAGES)" = '*' ] ; \
148 then \
149 enabled='*' ; \
150 else \
151 enabled=( $(PACKAGES) ) ; \
152 fi ; \
153 echo "$$enabled" ; \
154 avail=$$(for p in $$(cd packages ; ls) ; do if [ "$$enabled" = '*' ] || inarray $$p $${enabled[@]} ; then en=on ; else en="-" ; fi ; echo -n "$$p - $$en " ; done) ; \
155 if packages=$$(dialog --stdout --checklist "Package configuration" 1 0 0 $$avail ) ; \
156 then \
157 echo "PACKAGES = $$packages" | sed 's/"//g' > .config ; \
161 # Create installations files that do not lie beyond /omd/versions/$(OMD_VERSION)
162 # and files not owned by a specific package.
163 install-global:
164 # Create link to default version
165 ln -s $(OMD_VERSION) $(DESTDIR)$(OMD_BASE)/versions/default
167 # Create global symbolic links. Those links are share between
168 # all installed versions and refer to the default version.
169 mkdir -p $(DESTDIR)/usr/bin
170 ln -sfn /omd/versions/default/bin/omd $(DESTDIR)/usr/bin/omd
171 mkdir -p $(DESTDIR)/usr/share/man/man8
172 ln -sfn /omd/versions/default/share/man/man8/omd.8.gz $(DESTDIR)/usr/share/man/man8/omd.8.gz
173 mkdir -p $(DESTDIR)/etc/init.d
174 ln -sfn /omd/versions/default/share/omd/omd.init $(DESTDIR)/etc/init.d/omd
175 mkdir -p $(DESTDIR)$(APACHE_CONF_DIR)
176 ln -sfn /omd/versions/default/share/omd/apache.conf $(DESTDIR)$(APACHE_CONF_DIR)/zzz_omd.conf
178 # Base directories below /omd
179 mkdir -p $(DESTDIR)$(OMD_BASE)/sites
180 mkdir -p $(DESTDIR)$(OMD_BASE)/apache
183 # Information about distribution and OMD
184 mkdir -p $(DESTDIR)$(OMD_ROOT)/share/omd
185 install -m 644 distros/Makefile.$(DISTRO_NAME)_$(DISTRO_VERSION) $(DESTDIR)$(OMD_ROOT)/share/omd/distro.info
186 echo -e "OMD_VERSION = $(OMD_VERSION)\nOMD_PHYSICAL_BASE = $(OMD_PHYSICAL_BASE)" > $(DESTDIR)$(OMD_ROOT)/share/omd/omd.info
188 # README files and license information
189 mkdir -p $(DESTDIR)$(OMD_ROOT)/share/doc
190 install -m 644 README COPYING TEAM $(DESTDIR)$(OMD_ROOT)/share/doc
191 install -m 644 Changelog $(DESTDIR)$(OMD_ROOT)/share/doc/CHANGELOG
193 # Create source tarball. This currently only works in a checked out GIT
194 # repository.
195 $(SOURCE_TGZ) dist:
196 rm -rf omd-$(OMD_VERSION)
197 mkdir -p omd-$(OMD_VERSION)
198 git archive HEAD | tar xf - -C omd-$(OMD_VERSION)
199 tar czf $(SOURCE_TGZ) omd-$(OMD_VERSION)
200 rm -rf omd-$(OMD_VERSION)
202 # Creates source tarball. This does only work well in directories extracted
203 # from a CLEAN git archive tarball.
204 $(SOURCE_TGZ)-snap snap:
205 rm -rf omd-$(OMD_VERSION)
206 mkdir -p omd-$(OMD_VERSION)
207 tar cf - --exclude="rpm.topdir" --exclude="*~" --exclude=".gitignore" --exclude "omd-$(OMD_VERSION)" . | tar xf - -C omd-$(OMD_VERSION)
208 tar czf $(SOURCE_TGZ) omd-$(OMD_VERSION)
209 rm -rf omd-$(OMD_VERSION)
211 # Build RPM from source code.
212 # When called from a git repository this uses 'make dist' and thus 'git archive'
213 # to create the source rpm.
214 # The second choice is to call this form a CLEAN git archive directory which
215 # then uses 'make snap' to use that snapshot.
216 rpm:
217 sed -e 's/^Requires:.*/Requires: $(OS_PACKAGES)/' \
218 -e 's/%{version}/$(OMD_VERSION)/g' \
219 -e 's/^Version:.*/Version: $(DISTRO_CODE)/' \
220 -e 's/^Release:.*/Release: $(OMD_SERIAL)/' \
221 -e 's#@APACHE_CONFDIR@#$(APACHE_CONF_DIR)#g' \
222 -e 's#@APACHE_NAME@#$(APACHE_NAME)#g' \
223 omd.spec.in > omd.spec
224 rm -f $(SOURCE_TGZ)
225 test -d .git && $(MAKE) $(SOURCE_TGZ) || $(MAKE) $(SOURCE_TGZ)-snap
226 mkdir -p $(RPM_TOPDIR)/{SOURCES,BUILD,RPMS,SRPMS,SPECS}
227 cp $(SOURCE_TGZ) $(RPM_TOPDIR)/SOURCES
228 # NO_BRP_STALE_LINK_ERROR ignores errors when symlinking from skel to
229 # share,lib,bin because the link has a invalid target until the site is created
230 NO_BRP_STALE_LINK_ERROR="yes" \
231 rpmbuild -ba --define "_topdir $(RPM_TOPDIR)" \
232 --buildroot=$$(pwd)/rpm.buildroot omd.spec
233 mv -v $(RPM_TOPDIR)/RPMS/*/*.rpm .
234 mv -v $(RPM_TOPDIR)/SRPMS/*.src.rpm .
235 rm -rf $(RPM_TOPDIR) rpm.buildroot
237 # Build DEB from prebuild binary. This currently needs 'make dist' and thus only
238 # works within a GIT repository.
239 deb-environment:
240 @if test -z "$(DEBFULLNAME)" || test -z "$(DEBEMAIL)"; then \
241 echo "please read 'man dch' and set DEBFULLNAME and DEBEMAIL" ;\
242 exit 1; \
245 # create a debian/changelog to build the package
246 deb-changelog: deb-environment
247 # this is a hack!
248 rm -f debian/changelog
249 dch --create --package omd-$(OMD_VERSION) \
250 --newversion 0.$(DISTRO_CODE) "`cat debian/changelog.tmpl`"
251 dch --release "releasing ...."
253 deb: deb-changelog
254 sed -e 's/###OMD_VERSION###/$(OMD_VERSION)/' \
255 -e 's/###BUILD_PACKAGES###/$(BUILD_PACKAGES)/' \
256 -e 's/###OS_PACKAGES###/$(OS_PACKAGES)/' \
257 -e '/Depends:/s/\> /, /g' \
258 -e '/Depends:/s/@/ /g' \
259 `pwd`/debian/control.in > `pwd`/debian/control
260 fakeroot debian/rules clean
261 debuild --no-lintian -i\.git -I\.git \
262 -iomd-bin-$(OMD_VERSION).tar.gz \
263 -Iomd-bin-$(OMD_VERSION).tar.gz \
264 -i.gitignore -I.gitignore \
265 -uc -us -rfakeroot
266 # -- renaming deb package to DISTRO_CODE dependend name
267 # arch=`dpkg-architecture -qDEB_HOST_ARCH` ; \
268 # build=`sed -e '1s/.*(\(.*\)).*/\1/;q' debian/changelog` ; \
269 # distro=`echo $$build | sed -e 's/build/$(DISTRO_CODE)/' ` ; \
270 # echo "$$arch $$build $$distro"; \
271 # mv "../omd-$(OMD_VERSION)_$${build}_$${arch}.deb" \
272 # "../omd-$(OMD_VERSION)_$${distro}_$${arch}.deb" ;
274 deb-snap: deb-environment
275 make clean && git checkout -- Makefile.omd packages/omd/omd && \
276 make VERSION=`./get_version` version && make deb && \
277 git checkout -- Makefile.omd packages/omd/omd
279 # Only to be used for developement testing setup
280 setup: pack xzf alt
282 # Only for development: install tarball below /
283 xzf:
284 tar xzf $(BIN_TGZ) -C / # HACK: Add missing suid bits if compiled as non-root
285 chmod 4755 $(OMD_ROOT)/lib/nagios/plugins/check_{icmp,dhcp}
286 $(APACHE_CTL) -k graceful
288 # On debian based systems register the alternative switches
289 alt:
290 @if which update-alternatives >/dev/null 2>&1; then \
291 update-alternatives --install /omd/versions/default \
292 omd /omd/versions/$(OMD_VERSION) $(OMD_SERIAL) \
293 --slave /usr/bin/omd omd.bin /omd/versions/$(OMD_VERSION)/bin/omd \
294 --slave /usr/share/man/man8/omd.8.gz omd.man8 \
295 /omd/versions/$(OMD_VERSION)/share/man/man8/omd.8.gz ; \
296 fi ;
298 version:
299 @if [ -z "$(VERSION)" ] ; then \
300 newversion=$$(dialog --stdout --inputbox "New Version:" 0 0 "$(OMD_VERSION)") ; \
301 else \
302 newversion=$(VERSION) ; \
303 fi ; \
304 if [ -n "$$newversion" ] && [ "$$newversion" != "$(OMD_VERSION)" ]; then \
305 sed -ri 's/^(OMD_VERSION[[:space:]]*= *).*/\1'"$$newversion/" Makefile.omd ; \
306 sed -ri 's/^(OMD_SERIAL[[:space:]]*= *).*/\1'"$(NEWSERIAL)/" Makefile.omd ; \
307 sed -ri 's/^(OMD_VERSION[[:space:]]*= *).*/\1"'"$$newversion"'"/' packages/omd/omd ; \
308 fi ;
310 test:
311 t/test_all.sh