make 3.91 KB
Newer Older
1 2 3
#!/usr/bin/make -f
# -*- makefile -*-

lafont's avatar
lafont committed
4 5 6 7
# Configure quilt.
export QUILT_PATCHES=debian/patches
export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'

8 9 10 11 12
# The absolute path of the rules file.
RULES_PATH := $(realpath $(firstword $(MAKEFILE_LIST)))

# The working directory is obtained by removing the
# "/make" string at the end of RULES_PATH.
13
WORKING_DIR := $(realpath $(RULES_PATH:/make=))/src
14 15 16

# List of files in the working directory which do not belong
# to the git repository (all files except the debian/ directory).
lafont's avatar
lafont committed
17
FILES_TO_CLEAN := $(shell cd $(WORKING_DIR) && \ls | grep -v debian)
18 19 20

# Version number in the changelog to create the tarball
# of the upstream application with the good name.
lafont's avatar
lafont committed
21 22 23 24 25
# Typically, during the first call, ie `./make install_env`,
# the dpkg-parsechangelog will be not installed and the VERSION
# variable will be equal to "UNDEFINED".
VERSION := $(shell cd $(WORKING_DIR) && (dpkg-parsechangelog 2>/dev/null || echo Version UNDEFINED) \
             | awk '/^Version/ {print $$2}' | cut -d'-' -f1)
26

27
# URL of the upstream tarball during the last commit.
28
MASTER_TARBALL := https://github.com/pfautrero/xia/archive/master.tar.gz
lafont's avatar
lafont committed
29 30


lafont's avatar
lafont committed
31 32


33
# lintian is not necessary to build the package but can help to
34
# detect any things which are not Debian policy compliant.
lafont's avatar
lafont committed
35
install_env:
36 37
	# wget and libwww-perl are necessary for uscan.
	apt-get update && apt-get install --no-install-recommends --yes wget libwww-perl
38
	apt-get install --no-install-recommends --yes devscripts equivs lsb-release build-essential lintian dput
39
	cd "$(WORKING_DIR)" && mk-build-deps --install --tool 'apt-get --yes --no-install-recommends' --remove ./debian/control
40

41
clean:
42
	# Remove all files which mustn't belong to the git repository.
43
	cd "$(WORKING_DIR)" && { which dh_clean >/dev/null && dh_clean; } || true
44 45 46 47 48 49 50 51 52 53 54 55
	cd "$(WORKING_DIR)" && rm -fr *.egg-info/
	cd "$(WORKING_DIR)" && rm -fr build/
	cd "$(WORKING_DIR)" && rm -f .gitignore
	# All files in the working directory are removed except the debian/ directory.
	{ cd "$(WORKING_DIR)" && [ ! -z "$(FILES_TO_CLEAN)" ] && rm -rf $(FILES_TO_CLEAN); } || true
	# All files in the parent directory created by the building.
	cd "$(WORKING_DIR)" && rm -f ../*.deb
	cd "$(WORKING_DIR)" && rm -f ../*.dsc
	cd "$(WORKING_DIR)" && rm -f ../*.changes
	cd "$(WORKING_DIR)" && rm -f ../*.debian.tar.gz
	cd "$(WORKING_DIR)" && rm -f ../*.debian.tar.xz
	cd "$(WORKING_DIR)" && rm -f ../*.build
56
	cd "$(WORKING_DIR)" && rm -f ../*.buildinfo
Lafont François's avatar
Lafont François committed
57
	cd "$(WORKING_DIR)" && rm -f .gitlab-ci.yml
58
	cd "$(WORKING_DIR)" && rm -f .travis.yml
lafont's avatar
lafont committed
59
	cd "$(WORKING_DIR)" && rm -fr .pc/
60 61 62 63

# Remove the upstream archive too.
clean_all: clean
	cd "$(WORKING_DIR)" && rm -f ../*.orig.tar.gz
64 65
	cd "$(WORKING_DIR)" && rm -f ../archive.tar.gz

66 67 68 69 70
populate_with_master: clean
	cd "$(WORKING_DIR)" && rm -f "../archive.tar.gz"
	cd "$(WORKING_DIR)" && rm -f "../xia_$(VERSION).orig.tar.gz"
	cd "$(WORKING_DIR)" && wget "$(MASTER_TARBALL)" -O "../archive.tar.gz"
	cd "$(WORKING_DIR)" && ln -s "archive.tar.gz" "../xia_$(VERSION).orig.tar.gz"
71
	cd "$(WORKING_DIR)" && tar --strip-components=1 -zxf ../xia_$(VERSION).orig.tar.gz -C .
lafont's avatar
lafont committed
72 73 74
	# This is crucial to apply all patches, because this is not always
	# automatic. For instance, patches are not pushed if debuild use
	# the -b option.
lafont's avatar
lafont committed
75
	cd "$(WORKING_DIR)" && quilt push -a
76 77

populate: clean
78
	cd "$(WORKING_DIR)" && if [ ! -e "../archive.tar.gz" ]; then uscan --download-current-version --force-download; else true; fi
79
	cd "$(WORKING_DIR)" && tar --strip-components=1 -zxf "../xia_$(VERSION).orig.tar.gz" -C .
lafont's avatar
lafont committed
80 81 82
	# This is crucial to apply all patches, because this is not always
	# automatic. For instance, patches are not pushed if debuild use
	# the -b option.
lafont's avatar
lafont committed
83
	cd "$(WORKING_DIR)" && quilt push -a
84

85
# -b and -sa --> man dpkg-genchanges
86
build: populate
87
	cd "$(WORKING_DIR)" && debuild -b -us -uc --lintian-opts --pedantic -i -I && echo 'Building is OK!'
88

89 90 91
build_sign: populate
	cd "$(WORKING_DIR)" && debuild -sa --lintian-opts --pedantic -i -I && echo 'Building is OK!'