1# Copyright (C) 2012-2019  Dridi Boukelmoune
2# All rights reserved.
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17DEB_ORIG = $(PACKAGE)_$(VERSION).orig.tar.gz
18DPKG_BUILDPACKAGE ?= dpkg-buildpackage -us -uc
19PDEBUILD ?= pdebuild
20SBUILD ?= sbuild
21
22$(DEB_ORIG): distdir
23	tar -zcf $(DEB_ORIG) $(distdir)
24
25deb: $(DEB_ORIG) deb-clean
26	mkdir dpkgbuild/
27	mv $(distdir) $(DEB_ORIG) dpkgbuild/
28	cd dpkgbuild/$(distdir) && \
29		$(DPKG_BUILDPACKAGE) $(DPKG_BUILDPACKAGE_OPTS)
30	rm -rf dpkgbuild/$(distdir) dpkgbuild/$(DEB_ORIG)
31
32lintian: deb
33	lintian $(PACKAGE)_$(VERSION)-1_*.deb
34
35pdebuild: $(DEB_ORIG) pdebuild-clean
36	mkdir pdebuild/
37	cd $(distdir) && $(PDEBUILD) $(PDEBUILD_OPTS) \
38		--buildresult "$(abs_builddir)/pdebuild"
39	rm -rf $(distdir) $(DEB_ORIG)
40
41sbuild: $(DEB_ORIG) sbuild-clean
42	mkdir sbuild/
43	mv $(distdir) $(DEB_ORIG) sbuild/
44	cd sbuild/$(distdir) && \
45		$(DPKG_BUILDPACKAGE) $(DPKG_BUILDPACKAGE_OPTS) -S -d
46	cd sbuild && $(SBUILD) $(PACKAGE)_$(VERSION)-1.dsc $(SBUILD_OPTS)
47	rm -rf sbuild/$(distdir) $(DEB_ORIG)
48
49deb-clean:
50	rm -rf dpkgbuild/
51
52pdebuild-clean:
53	rm -rf pdebuild/
54
55sbuild-clean:
56	rm -rf sbuild/
57
58clean-local: deb-clean pdebuild-clean sbuild-clean
59
60.PHONY: deb-clean pdebuild-clean sbuild-clean
61