summaryrefslogtreecommitdiff
path: root/debian/rules
blob: d3dcacb44214b88e0d814e07af8e4021b1bdff6c (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
173
174
175
176
177
178
179
180
181
182
183
184
#!/usr/bin/make -f
# debian/rules file - for GNUPG (1.4.6)
# Based on sample debian/rules file - for GNU Hello (1.3).
# Copyright 1994,1995 by Ian Jackson.
# Copyright 1998-2006 by James Troup.
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself.  (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)
# This file may have to be extensively modified

DISTRIBUTION := SLP
STRIP=strip --remove-section=.comment --remove-section=.note

DEB_BUILD_GNU_TYPE = $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
HOSTARG = --host=$(DEB_HOST_GNU_TYPE)
endif

CONFARGS = --prefix=/usr --libexecdir=/usr/lib/ --enable-mailto --with-mailprog=/usr/sbin/sendmail

install_dir=install -d -m 755
install_file=install -m 644
install_script=install -m 755
install_binary=install -m 755 -s

VERSION := $(shell dpkg-parsechangelog | grep ^Version: | cut -d' ' -f2)
DEB_BUILD_ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)

include /usr/share/dpatch/dpatch.make

build-deb-stamp: patch-stamp
	$(checkdir)
	mkdir -p build-deb
	cd build-deb && ../configure $(CONFARGS) $(HOSTARG) --with-libcurl=no --with-libusb=no
	$(MAKE) -C build-deb
	touch $@

build-udeb-stamp: patch-stamp
	$(checkdir)
	mkdir -p build-udeb
	cd build-udeb && CFLAGS='-g -Os' ../configure $(CONFARGS) $(HOSTARG) --without-bzip2 --without-readline --with-libcurl=no --with-libusb=no
	$(MAKE) -C build-udeb
	touch $@

build: build-deb-stamp build-udeb-stamp

test: build
	$(checkdir)
	make -C build-deb/checks check || exit 127
	touch test

clean: unpatch
	$(checkdir)
	-rm -f build
	-$(MAKE) -C build-deb -i distclean || $(MAKE) -C build-deb -f Makefile.in distclean
	-$(MAKE) -C build-udeb -i distclean || $(MAKE) -C build-udeb -f Makefile.in distclean
	-rm -rf build-deb build-udeb debian/gpgv-udeb debian/gnupg-udeb debian/gpgv
	-rm -rf debian/tmp debian/patched debian/files* debian/*substvars
	find . -name \*~ | xargs rm -vf

binary-indep:

binary-arch:	checkroot build # test
	$(checkdir)

	: # gnupg
	-rm -rf debian/tmp
	$(install_dir) debian/tmp/DEBIAN/
	$(install_script) debian/preinst debian/tmp/DEBIAN/
	$(MAKE) -C build-deb prefix=`pwd`/debian/tmp/usr mandir=`pwd`/debian/tmp/usr/share/man libexecdir=`pwd`/debian/tmp/usr/lib/ mkinstalldirs=`pwd`/scripts/mkinstalldirs install
	: # copies of the manpage which can't be grokked by install-info
	rm debian/tmp/usr/share/info/*
	find debian/tmp/ -type f | xargs file | grep ELF | cut -d: -f 1 | xargs $(STRIP)
	chmod 755 debian/tmp/usr/bin/gpg
	sed -e "s#../g10/gpg#gpg#" < tools/lspgpot > debian/tmp/usr/bin/lspgpot
	sed -e "s#../g10/gpg#gpg#" < tools/convert-from-106 > debian/tmp/usr/bin/gpg-convert-from-106
	chmod 755 debian/tmp/usr/bin/lspgpot debian/tmp/usr/bin/gpg-convert-from-106
	sed -e "s#/usr/local/#/usr/#" < debian/tmp/usr/share/man/man1/gpg.1 \
	    > debian/tmp/usr/share/man/man1/gpg.1.new
	mv debian/tmp/usr/share/man/man1/gpg.1.new debian/tmp/usr/share/man/man1/gpg.1
	$(install_file) debian/gpg-convert-from-106.1 debian/gpgsplit.1 \
			debian/lspgpot.1 debian/tmp/usr/share/man/man1/
	gzip -9v debian/tmp/usr/share/man/man*/*
	: # Move localized manpages to FHS compliant locations
	$(install_dir) debian/tmp/usr/share/man/ru/man1/
	mv debian/tmp/usr/share/man/man1/gpg.ru.1.gz debian/tmp/usr/share/man/ru/man1/gpg.1.gz
	: # Remove from /usr/share/gnupg what we install into /usr/share/doc/gnupg/
	rm debian/tmp/usr/share/gnupg/FAQ debian/tmp/usr/share/gnupg/faq.html
	$(install_dir) debian/tmp/usr/share/doc/gnupg/
	$(install_file) debian/changelog debian/tmp/usr/share/doc/gnupg/changelog.Debian
	$(install_file) debian/README.Debian README NEWS THANKS TODO doc/DETAILS \
		doc/FAQ doc/faq.html doc/OpenPGP debian/Upgrading_From_PGP.txt \
		doc/highlights-1.4.txt debian/tmp/usr/share/doc/gnupg/
	for i in po util mpi cipher tools g10 checks include; do \
		$(install_file) $$i/ChangeLog debian/tmp/usr/share/doc/gnupg/changelog.$$i; done
	$(install_file) ChangeLog debian/tmp/usr/share/doc/gnupg/changelog.toplevel
	gzip -9v debian/tmp/usr/share/doc/gnupg/*
	ln -s changelog.g10.gz debian/tmp/usr/share/doc/gnupg/changelog.gz
	$(install_file) debian/copyright debian/tmp/usr/share/doc/gnupg/

	: # in the gpgv package instead
	rm debian/tmp/usr/bin/gpgv
	rm debian/tmp/usr/share/man/man1/gpgv.1.gz

	find debian/tmp/ -type d -empty | xargs rmdir

	find debian/tmp/ -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps
	dpkg-gencontrol -pgnupg -isp
	chown -R root.root debian/tmp
	chmod -R go=rX debian/tmp
	dpkg --build debian/tmp ..

	: # gpgv
	-rm -rf debian/gpgv
	$(install_dir) debian/gpgv/DEBIAN/ 

	$(install_dir) debian/gpgv/usr/bin/
	$(install_binary) build-udeb/g10/gpgv debian/gpgv/usr/bin/
	$(STRIP) debian/gpgv/usr/bin/gpgv

	$(install_dir) debian/gpgv/usr/share/man/man1/
	$(install_file) build-deb/doc/gpgv.1 debian/gpgv/usr/share/man/man1/
	gzip -9v debian/gpgv/usr/share/man/man*/*

	$(install_dir) debian/gpgv/usr/share/doc/gpgv
	$(install_file) debian/changelog debian/gpgv/usr/share/doc/gpgv/changelog.Debian
	gzip -9v debian/gpgv/usr/share/doc/gpgv/*
	$(install_file) debian/copyright debian/gpgv/usr/share/doc/gpgv/

	find debian/gpgv/ -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps
	dpkg-gencontrol -pgpgv -Pdebian/gpgv -isp
	chown -R root.root debian/gpgv
	chmod -R go=rX debian/gpgv
	dpkg --build debian/gpgv ..

ifneq ($(DISTRIBUTION),SLP)
	: ### Udebs

	: # gpgv-udeb
	rm -rf debian/gpgv-udeb
	$(install_dir) debian/gpgv-udeb/DEBIAN/ debian/gpgv-udeb/usr/bin/
	$(install_binary) build-udeb/g10/gpgv debian/gpgv-udeb/usr/bin/
	find debian/gpgv-udeb/ -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps -Tdebian/gpgv-udeb.substvars -tudeb

	: # Don't let dpkg-gencontrol write incorrect guesses to debian/files.
	: # Instead, register the udeb manually.
	dpkg-gencontrol -pgpgv-udeb -Tdebian/gpgv-udeb.substvars -Pdebian/gpgv-udeb -isp -fdebian/files~
	dpkg-distaddfile gpgv-udeb_$(VERSION)_$(DEB_BUILD_ARCH).udeb debian-installer extra

	chown -R root.root debian/gpgv-udeb
	chmod -R go=rX debian/gpgv-udeb
	dpkg --build debian/gpgv-udeb ../gpgv-udeb_$(VERSION)_$(DEB_BUILD_ARCH).udeb

	: # gnupg-udeb
	rm -rf debian/gnupg-udeb
	$(install_dir) debian/gnupg-udeb/DEBIAN/ debian/gnupg-udeb/usr/bin/
	$(install_binary) build-udeb/g10/gpg debian/gnupg-udeb/usr/bin/
	find debian/gnupg-udeb/ -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps -Tdebian/gnupg-udeb.substvars -tudeb

	: # Don't let dpkg-gencontrol write incorrect guesses to debian/files.
	: # Instead, register the udeb manually.
	dpkg-gencontrol -pgnupg-udeb -Tdebian/gnupg-udeb.substvars -Pdebian/gnupg-udeb -isp -fdebian/files~
	dpkg-distaddfile gnupg-udeb_$(VERSION)_$(DEB_BUILD_ARCH).udeb debian-installer extra

	chown -R root.root debian/gnupg-udeb
	chmod -R go=rX debian/gnupg-udeb
	dpkg --build debian/gnupg-udeb ../gnupg-udeb_$(VERSION)_$(DEB_BUILD_ARCH).udeb
endif

define checkdir
	test -f g10/gpg.c && test -f debian/rules
endef

# Below here is fairly generic really

binary: 	binary-indep binary-arch

checkroot:
	$(checkdir)
	test root = "`whoami`"

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