chiark / gitweb /
update licence to GPLv3 or later (was GPLv2 or later).
[chiark-utils.git] / debian / rules
1 #!/usr/bin/make -f
2
3 SHELL=/bin/bash
4
5 subdirs_build=  cprogs
6 subdirs_nobuild=backup sync-accounts scripts
7 package=        chiark-utils
8 packages_indep= chiark-backup chiark-scripts
9 packages_arch=  chiark-rwbuffer chiark-really chiark-utils-bin
10 packages=       $(packages_indep) $(packages_arch)
11
12 cwd=    $(shell pwd)
13 d=      $(cwd)/debian
14 t=      $d/tmp
15
16 build:
17         $(checkdir)
18         set -e; for s in $(subdirs_build); do $(MAKE) -C $$s all; done
19         touch build
20
21 clean:
22         $(checkdir)
23         rm -f build
24         set -e; for s in $(subdirs_build); do \
25                 $(MAKE) -C $$s -i distclean || \
26                 $(MAKE) -C $$s -f Makefile.in distclean; \
27         done
28         rm -rf *~ debian/tmp debian/*~ debian/files* debian/substvars*
29
30 binary-prep:
31         $(checkdir)
32         rm -rf debian/tmp*
33         #
34         set -e; for s in $(subdirs_build) $(subdirs_nobuild); do \
35                 $(MAKE) -C $$s install install-docs install-examples \
36                         prefix=$t/$$s/usr \
37                         etcdir=$t/$$s/etc \
38                         varlib=$t/$$s/var/lib \
39                         mandir=$t/$$s/usr/share/man; \
40         done
41         #
42         mv $t/cprogs $t/chiark-utils-bin
43         #
44         cp -a debian/tmp/sync-accounts/* debian/tmp/scripts/.
45         rm -r debian/tmp/sync-accounts
46         mv debian/tmp/scripts debian/tmp/chiark-scripts
47         mv debian/tmp/backup debian/tmp/chiark-backup
48         #
49         set -e; for p in $(packages); do \
50                 install -d $t/$$p/DEBIAN $t/$$p/usr/share/doc/$$p; \
51                 cp debian/copyright debian/changelog \
52                         $t/$$p/usr/share/doc/$$p/; \
53                 ln -s changelog.gz \
54                         $t/$$p/usr/share/doc/$$p/changelog.Debian.gz; \
55                 gzip -9v $t/$$p/usr/share/doc/$$p/changelog; \
56                 done
57         #
58         install -d $t/chiark-rwbuffer/usr/bin
59         install -d $t/chiark-rwbuffer/usr/share/man/man1
60         cd $t/chiark-utils-bin/usr/bin && \
61                 mv readbuffer writebuffer $t/chiark-rwbuffer/usr/bin/
62         cd $t/chiark-utils-bin/usr/share/man/man1 && \
63                 mv readbuffer.1 writebuffer.1 $t/chiark-rwbuffer/usr/share/man/man1/
64         #
65         install -d $t/chiark-backup/usr/share/man/man1
66         cp backup/man/*.1 $t/chiark-backup/usr/share/man/man1/
67         cd $t/chiark-backup/usr/share/man/man1 && \
68                 for m in *.1; do \
69                         mv "$$m" backup-"$$m"; \
70                 done
71         cp \
72  $t/chiark-backup/usr/share/doc/chiark-backup/examples/chiark/settings.sh \
73  $t/chiark-backup/etc/chiark-backup/settings.sh
74         #
75         install -d $t/chiark-really/usr/sbin
76         install -d $t/chiark-really/usr/share/man/man8
77         cd $t/chiark-utils-bin/usr/sbin && \
78                 mv really $t/chiark-really/usr/sbin/
79         strip --strip-unneeded --remove-section .note --remove-section .comment $t/chiark-really/usr/sbin/really
80         cd $t/chiark-utils-bin/usr/share/man/man8 && \
81                 mv really.8 $t/chiark-really/usr/share/man/man8/
82         rm      $t/chiark-utils-bin/usr/sbin/trivsoundd \
83                 $t/chiark-utils-bin/usr/share/man/man8/trivsoundd.8
84         rmdir   $t/chiark-utils-bin/usr/sbin \
85                 $t/chiark-utils-bin/usr/share/man/man8
86         #
87         gzip -9f $t/*/usr/share/man/man*/*
88
89 binary-hook-chiark-backup:
90 binary-hook-chiark-rwbuffer:
91 binary-hook-sync-accounts:
92 binary-hook-chiark-scripts:
93 binary-hook-chiark-really:
94 binary-hook-chiark-utils-bin:
95
96 binary-one:
97         set -e; for f in preinst postinst prerm postrm conffiles; do \
98                 test -f debian/$p/$$f || continue; \
99                 cp debian/$p/$$f $t/$p/DEBIAN/$$f; \
100                 chmod u=rwX,go=rX $t/$p/DEBIAN/$$f; \
101         done
102         dpkg-gencontrol -isp -p$p -P$t/$p -Tdebian/sv-$p
103         chown -R root.root debian/tmp
104         chmod -R g-ws debian/tmp
105         debian/rules binary-hook-$p
106         dpkg --build $t/$p ..
107
108 binary-indep:   checkroot build binary-prep
109         set -e; for p in $(packages_indep); do \
110                 debian/rules binary-one p=$$p; done
111
112 binary-arch:    checkroot build binary-prep
113         $(checkdir)
114         dpkg-shlibdeps -Tdebian/sv-chiark-rwbuffer \
115                 $t/chiark-rwbuffer/usr/bin/*
116         dpkg-shlibdeps -Tdebian/sv-chiark-really \
117                 $t/chiark-really/usr/sbin/*
118         dpkg-shlibdeps -Tdebian/sv-chiark-utils-bin \
119                 $t/chiark-utils-bin/usr/bin/[^x]* \
120                 -dSuggests $t/chiark-utils-bin/usr/bin/x*
121         set -e; for p in $(packages_arch); \
122                 do debian/rules binary-one p=$$p; done
123
124 define checkdir
125         test -f cprogs/writebuffer.c
126 endef
127
128 # Below here is fairly generic really
129
130 binary:         binary-indep binary-arch
131
132 source diff:
133         @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
134
135 checkroot:
136         $(checkdir)
137         test root = "`whoami`"
138
139 .PHONY: binary binary-arch binary-indep clean checkroot