summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 84dfad91bfe46ba58b4003a161c4237d42ce887a (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
#!/usr/bin/make -f 
#
# Copyright (C) 1998 Software in the Public Interest <www.debian.org>

SHELL	=	/bin/bash

BINS	=	tcpserver tcpclient tcprules addcr delcr

SHBINS	=	who@ date@ finger@ tcpcat mconnect

MAN1	=	tcpclient.1 tcpserver.1 tcprules.1 addcr.1 delcr.1

MAN5	=	tcp-environ.5

DOCS	=	BLURB README TCP THANKS TODO UCSPI

PACKAGE   = $(shell perl -e 'print <> =~ /(\S*)\s/' debian/changelog)
PKG_VER	  = $(shell perl -e 'print <> =~ /\((.*)\)/' debian/changelog)
PKG_UPVER = $(shell perl -e 'print <> =~ /\((.*)-[^-]*\)/' debian/changelog)

TMPSRC = debian/tmp-src

build:
	$(MAKE)
	touch build

clean:		checkdir debian/control
	rm -f build debian/files debian/substvars
	rm -f $(BINS) $(SHBINS)
	rm -f *.o *.a *.0
	rm -rf debian/tmp debian/misc $(TMPSRC)
	rm -f auto-ccld.sh make-load find-systype systype load \
		make-compile compile select.h make-makelib makelib \
		hassgprm.h hassgact.h dns.lib uint32.h haswaitp.h
	find . \( -name '#*#' -o -name '*~' -o -name DEADJOE -o		\
		-name '*.orig' -o -name '*.rej' -o -name '*.bak' -o	\
		-name '.*.orig' -o -name '.*.rej' -o -name .SUMS -o	\
		-name TAGS -o -name core \) -exec rm -f {} \;

binary-indep:	checkroot build
	rm -rf debian/misc
	install -d -m 0755 debian/misc/{DEBIAN,usr/{bin,doc}}
	install -m 0755 $(SHBINS) debian/misc/usr/bin/
	ln -s ucspi-tcp debian/misc/usr/doc/ucspi-tcp-misc

	dpkg-gencontrol -pucspi-tcp-misc -Pdebian/misc -cdebian/control.real
	chown -R root.root debian/misc
	dpkg --build debian/misc ..

binary-arch:    checkroot build
	rm -rf debian/tmp
	install -d -m 0755 debian/tmp/{DEBIAN,usr/{bin,man/man{1,5},doc/ucspi-tcp}}
	install -s -m 0755 $(BINS) debian/tmp/usr/bin/
	install -m 0644 $(MAN1) debian/tmp/usr/man/man1/
	install -m 0644 $(MAN5) debian/tmp/usr/man/man5/
	install -m 0644 CHANGES debian/tmp/usr/doc/ucspi-tcp/changelog
	install -m 0644 debian/changelog debian/tmp/usr/doc/ucspi-tcp/changelog.Debian
	install -m 0644 $(DOCS) debian/tmp/usr/doc/ucspi-tcp/
	gzip -9fr debian/tmp/usr/doc/ debian/tmp/usr/man/
	install -m 0644 debian/copyright debian/tmp/usr/doc/ucspi-tcp/copyright
	install -p -m 0755 debian/postrm debian/preinst debian/tmp/DEBIAN

	dpkg-shlibdeps $(BINS)
	dpkg-gencontrol -pucspi-tcp -cdebian/control.real
	chown -R root.root debian/tmp
	dpkg --build debian/tmp ..

binary-src: checkroot checkdir debian/control ../$(PACKAGE)_$(PKG_UPVER).orig.tar.gz \
../$(PACKAGE)_$(PKG_VER).dsc ../$(PACKAGE)_$(PKG_VER).diff.gz
	-rm -rf $(TMPSRC) debian/files
	
	install -d $(TMPSRC)/DEBIAN \
		$(TMPSRC)/usr/bin \
		$(TMPSRC)/usr/src/$(PACKAGE)-src \
		$(TMPSRC)/usr/doc/$(PACKAGE)-src
	install -m 755 debian/build-PACKAGE $(TMPSRC)/usr/bin/build-$(PACKAGE)
	install -m 0644 ../$(PACKAGE)_$(PKG_UPVER).orig.tar.gz \
			../$(PACKAGE)_$(PKG_VER).dsc \
			../$(PACKAGE)_$(PKG_VER).diff.gz \
			$(TMPSRC)/usr/src/$(PACKAGE)-src/
	sed -e "s/#PACKAGE#/$(PACKAGE)/" debian/src.postinst > $(TMPSRC)/DEBIAN/postinst
	chmod 755 $(TMPSRC)/DEBIAN/postinst
	sed -e "s/#PACKAGE#/$(PACKAGE)/" debian/README-src > $(TMPSRC)/usr/doc/$(PACKAGE)-src/README.Debian
	install -m 0644 debian/changelog $(TMPSRC)/usr/doc/$(PACKAGE)-src/changelog.Debian
	chmod 644 $(TMPSRC)/usr/doc/$(PACKAGE)-src/changelog.Debian
	gzip -9fr $(TMPSRC)/usr/doc/
	install -m 0644 debian/copyright $(TMPSRC)/usr/doc/$(PACKAGE)-src/

	dpkg-gencontrol -p$(PACKAGE)-src -P$(TMPSRC)
	chown -R root.root $(TMPSRC)
	dpkg --build $(TMPSRC) ..

debian/control: debian/control.real
	test -f debian/control.real && sed -e "/^Package: $(PACKAGE)-src$$/b" -e "/^Package: /,/^$$/d" debian/control.real > debian/control

../$(PACKAGE)_$(PKG_UPVER).orig.tar.gz:
		@{ echo "Error: $@ missing"; exit 1; }

../$(PACKAGE)_$(PKG_VER).dsc ../$(PACKAGE)_$(PKG_VER).diff.gz: debian/rules
	debian/rules clean
	cd ..; dpkg-source -b $(PACKAGE)-$(PKG_UPVER)

binary:	binary-indep binary-arch binary-src

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

checkdir:
	@test -f tcpserver.c -a -f debian/rules

checkroot:	checkdir
	@test 0 = `id -u` || { echo "Error: not super-user"; exit 1; }

.PHONY: binary binary-arch binary-indep clean checkroot checkdir