summaryrefslogtreecommitdiffstats
path: root/scripts/Makefile
blob: 88f9a734862a813745022fdae4ec185f23341aa3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
include ../Makefile.common
include /usr/share/dpkg/vendor.mk
DESTDIR =

define \n


endef

VERSION_FILE = ../version
VERSION = $(shell cat $(VERSION_FILE))

PL_FILES := $(wildcard *.pl)
SH_FILES = $(wildcard *.sh)
CWRAPPERS = debpkg-wrapper
SCRIPTS = $(patsubst %.pl,%,$(PL_FILES)) $(patsubst %.sh,%,$(SH_FILES))
PL_CHECKS = $(patsubst %.pl,%.pl_check,$(PL_FILES))
SH_CHECKS = $(patsubst %.sh,%.sh_check,$(SH_FILES))
COMPL_FILES := $(wildcard *.bash_completion)
BC_BUILD_DIR:=bash_completion
COMPLETION = $(patsubst %.bash_completion,$(BC_BUILD_DIR)/%,$(COMPL_FILES))
COMPL_DIR := $(shell pkg-config --variable=completionsdir bash-completion)
PKGNAMES := \
	build-rdeps \
	dd-list \
	debcheckout \
	debsnap \
	dget \
	getbuildlog \
	grep-excuses \
	mass-bug \
	mk-build-deps \
	pts-subscribe \
	pts-unsubscribe \
	rc-alert \
	rmadison \
	transition-check \
	who-uploads \
	whodepends \
	wnpp-alert \
	wnpp-check \

GEN_MAN1S += \
	deb-why-removed.1 \
	debbisect.1 \
	debootsnap.1 \
	debrebuild.1 \
	debrepro.1 \
	ltnu.1 \
	mk-origtargz.1 \
	salsa.1 \
	reproducible-check.1 \
	uscan.1 \

all: $(SCRIPTS) $(GEN_MAN1S) $(CWRAPPERS) $(COMPLETION)

scripts: $(SCRIPTS)

$(VERSION_FILE):
	$(MAKE) -C .. version

%: %.sh

debchange: debchange.pl $(VERSION_FILE)
	sed "s/###VERSION###/$(VERSION)/" $< > $@
	chmod --reference=$< $@
ifeq ($(DEB_VENDOR),Ubuntu)
# On Ubuntu always default to targeting the release that it's built on,
# not the current devel release, since its primary use on stable releases
# will be for preparing PPA uploads.
	sed -i 's/get_ubuntu_devel_distro()/"$(shell lsb_release -cs)"/' $@
endif

%.tmp: %.sh $(VERSION_FILE)
	sed -e "s/###VERSION###/$(VERSION)/" $<  > $@
%.tmp: %.pl $(VERSION_FILE)
	sed -e "s/###VERSION###/$(VERSION)/" $<  > $@
%: %.tmp
	cp $< $@
	chmod +x $@

%.1: %.pl
	podchecker $<
	pod2man --utf8 --center=" " --release="Debian Utilities" $< > $@
%.1: %.pod
	podchecker $<
	pod2man --utf8 --center=" " --release="Debian Utilities" $< > $@
%.1: %.dbk
	xsltproc --nonet -o $@ \
	  /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl $<

# Syntax checker
test_sh: $(SH_CHECKS)
%.sh_check: %
	bash -n $<

test_pl: $(PL_CHECKS)
%.pl_check: %
	perl -I ../lib -c $<; \

test_py: $(VERSION_FILE)
	$(foreach python,$(shell py3versions -r ../debian/control),$(python) setup.py test$(\n))

debbisect.1: debbisect
	help2man \
		--name="bisect snapshot.debian.org" \
		--version-string=$(VERSION) \
		--no-info \
		--no-discard-stderr \
		./$< >$@

debootsnap.1: debootsnap
	help2man \
		--name="create debian chroot using snapshot.debian.org" \
		--version-string=$(VERSION) \
		--no-info \
		--no-discard-stderr \
		./$< >$@

debrebuild.1: debrebuild
	help2man \
		--name="use a buildinfo file and snapshot.d.o to recreate binary packages" \
		--version-string=$(VERSION) \
		--no-info \
		--no-discard-stderr \
		./$< >$@

reproducible-check.1: reproducible-check
	help2man \
		--name="Reports on the reproducible status of installed packages" \
		--no-info \
		--no-discard-stderr \
		./$< >$@

$(BC_BUILD_DIR):
	mkdir $(BC_BUILD_DIR)

$(COMPLETION): $(BC_BUILD_DIR)/% : %.bash_completion $(BC_BUILD_DIR)
	cp $< $@

clean:
	rm -f devscripts/__init__.py
	find -name '*.pyc' -delete
	find -name __pycache__ -delete
	rm -rf devscripts.egg-info $(BC_BUILD_DIR) .pylint.d
	rm -f $(SCRIPTS) $(patsubst %,%.tmp,$(SCRIPTS)) \
		$(GEN_MAN1S) $(SCRIPT_LIBS) $(CWRAPPERS)


test: test_pl test_sh test_py

install: all
	python3 setup.py install --root="$(DESTDIR)" --no-compile --install-layout=deb
	cp $(SCRIPTS) $(DESTDIR)$(BINDIR)
	ln -sf edit-patch $(DESTDIR)$(BINDIR)/add-patch
	install -d $(DESTDIR)$(COMPL_DIR)
	cp $(BC_BUILD_DIR)/* $(DESTDIR)$(COMPL_DIR)/
	for i in $(PKGNAMES); do                        \
	    ln -sf pkgnames $(DESTDIR)$(COMPL_DIR)/$$i;  \
	done
	ln -sf debchange $(DESTDIR)$(COMPL_DIR)/dch
	ln -sf debi $(DESTDIR)$(COMPL_DIR)/debc
	# Special treatment for debpkg and run_bisect
	install -d $(DESTDIR)$(DATA_DIR)
	mv $(DESTDIR)$(BINDIR)/debpkg $(DESTDIR)$(DATA_DIR)
	cp debpkg-wrapper $(DESTDIR)$(BINDIR)/debpkg
	install -d $(DESTDIR)$(DATA_DIR)/scripts
	mv $(DESTDIR)$(BINDIR)/run_bisect $(DESTDIR)$(DATA_DIR)/scripts
	mv $(DESTDIR)$(BINDIR)/run_bisect_qemu $(DESTDIR)$(DATA_DIR)/scripts

.PHONY: test test_pl test_sh test_py all install clean scripts