spec file to build zabbix packages.
[monitor.git] / Makefile
1 # $Id$
2 CURL    := curl -H Pragma: -O -R -S --fail --show-error
3 SHA1SUM = sha1sum
4
5 # default - overridden by the build
6 SPECFILE = zabbix.spec
7
8 main.URL        := http://voxel.dl.sourceforge.net/sourceforge/zabbix/zabbix-1.6.1.tar.gz 
9 main.SHA1SUM:= 6e66efdbbdf23dc3de01379b30ded7b005fb49d9
10 main.FILE       := $(notdir $(main.URL))
11
12 # Thierry - when called from within the build, PWD is /build
13 SOURCEFILES := $(main.FILE)
14
15 $(main.FILE): #FORCE
16         @if [ ! -e "$@" ] ; then echo "$(CURL) $(main.URL)" ; $(CURL) $(main.URL) ; fi
17         @if [ ! -e "$@" ] ; then echo "Could not download source file: $@ does not exist" ; exit 1 ; fi
18         @if test "$$(sha1sum $@ | awk '{print $$1}')" != "$(main.SHA1SUM)" ; then \
19             echo "sha1sum of the downloaded $@ does not match the one from 'sources' file" ; \
20             echo "Local copy: $$(sha1sum $@)" ; \
21             echo "In sources: $$(grep $@ sources)" ; \
22             exit 1 ; \
23         else \
24             ls -l $@ ; \
25         fi
26
27 sources: $(SOURCEFILES)
28 .PHONY: sources
29
30 PWD=$(shell pwd)
31 PREPARCH ?= noarch
32 RPMDIRDEFS = --define "_sourcedir $(PWD)" --define "_builddir $(PWD)" --define "_srcrpmdir $(PWD)" --define "_rpmdir $(PWD)"
33
34 trees: sources
35         rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bp --target $(PREPARCH) $(SPECFILE)
36
37 srpm: sources
38         rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bs $(SPECFILE)
39
40 TARGET ?= $(shell uname -m)
41 rpm: sources
42         rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps --target $(TARGET) -bb $(SPECFILE)
43
44 clean:
45         rm -f *.rpm *.tgz *.bz2 *.gz
46 clean:
47         rm *.pyc *.dat *.log