Fix the logic to support version 1.0.0!
[mythtv-status.git] / Makefile
1 #!/usr/bin/make -f
2
3 BINDIR=$(DESTDIR)/usr/bin
4 MANDIR=$(DESTDIR)/usr/man
5
6 package=mythtv-status
7 releases=sid
8 release=sid
9 sponsor_keyid=19D03486
10
11 build=dpkg-buildpackage -rfakeroot -i'(.git|build|.gitignore|testing)*' -I.git -Ibuild -I.gitignore -Itesting -tc -kC603FC4E600F1CECD1C8D97C4B53D931E4D3E863
12 ifeq ($(version),)
13 version=$(shell git tag -l | grep '^[0-9]' | sort -t"." -k 1,1 -k 2,2 -k 3,3 -n | tail -1)
14 endif
15 deb_version=$(shell git tag -l | grep ^debian-$(release)-[[:digit:]] | sed 's/debian-$(release)-//' | sort -t"." -k 1,1 -k 2,2 -k 3,3 -n | tail -1 | sed 's/@/~/')
16
17 deb=$(package)_$(deb_version)_all.deb
18 orig_tarball=../$(package)_$(version).orig.tar.gz
19 tarball=build/tarball/$(package)-$(version).tar.gz
20 tarball_dir=../$(package)_tarballs
21
22 DEBS=$(foreach release, $(releases), build/$(release)/$(deb))
23
24 RELEASE_FILES=$(orig_tarball) build/tarball/mythtv-status-${version}.tar.gz $(DEBS)
25
26 TEST_VERBOSE=0
27 TEST_FILES=t/*.t
28
29 all: test release
30
31 release: $(RELEASE_FILES)
32
33 $(orig_tarball): $(tarball)
34         @rm -f $@
35         @ln -s `basename \`pwd\``/$< $@
36
37 sponsor: $(orig_tarball)
38         dpkg-buildpackage -rfakeroot -k$(sponsor_keyid) -i'(.git|build|Makefile|testing)' -I.git -IMakefile -I.gitignore -Ibuild -Itesting -tc
39
40 $(tarball):
41         @mkdir -p $(@D)
42         @git archive --format=tar --prefix=$(package)-$(version)/ $(version) `git ls-tree --name-only $(version) | egrep -v "(.gitignore|debian|Makefile|testing)"` | gzip > $(tarball)
43
44 build/$(release)/$(deb): $(orig_tarball)
45         @echo Building $(release)
46         @ssh -t build-$(release)-amd64 "cd `pwd`; $(build)"
47         @ssh build-$(release)-amd64 "cd `pwd`/..; /usr/bin/lintian -i -I $(package)_$(version)*.changes" || true
48         #@ssh build-$(release)-amd64 "cd `pwd`/..; /usr/bin/linda -i $(package)_$(version)*.changes" || true
49         @mkdir -p build/$(release)
50         @cp ../$(deb)  \
51                 ../$(package)_$(deb_version)_*.changes \
52                 ../$(package)_$(deb_version)_*.buildinfo \
53                 ../$(package)_$(deb_version).dsc \
54                 ../$(package)_$(version).orig.tar.?z \
55                 ../$(package)_$(deb_version).debian.tar.?z \
56                 build/$(release)
57
58 publish: $(RELEASE_FILES)
59         for release in $(releases); do reprepro includedsc $$release build/$$release/$(package)_$(deb_version).dsc; done
60         @cp $(tarball) $(tarball_dir)
61         @chmod o+r $(tarball_dir)/*-$(version).*
62         @ln -sf `basename $(tarball)` $(tarball_dir)/$(package)-latest.tar.gz
63
64 upload: $(RELEASE_FILES)
65         for release in $(releases); do cd build/$$release; dput $(package)_$(deb_version)*.changes; done
66
67 install:
68         install -d $(BINDIR)
69         install -d $(MANDIR)/man1
70         install -m 775 bin/mythtv-status $(BINDIR)
71         install -m 775 bin/mythtv_recording_now $(BINDIR)
72         install -m 775 bin/mythtv_recording_soon $(BINDIR)
73         pod2man bin/mythtv-status > $(MANDIR)/man1/mythtv-status.1
74         install -m 644 man/mythtv_recording_now.1 $(MANDIR)/man1
75         install -m 644 man/mythtv_recording_soon.1 $(MANDIR)/man1
76
77 test:
78         PERL_DL_NONLAZY=1 perl "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE))" $(TEST_FILES)
79
80
81 clean:
82         @rm -rf build
83         @rm -f ../$(package)*.changes ../$(package)*.dsc ../$(package)*.tar.gz ../$(package)*.deb
84
85 .PHONY: release clean sponsor install test