chiark / gitweb /
3cf0afa9387b0364dd1ea999ed07b5f386057a46
[chiark-utils.git] / debian / rules
1 #!/usr/bin/make -f
2
3 SHELL=/bin/bash
4
5 subdirs_build_arch=     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_arch); do $(MAKE) -C $$s all; done
19         touch build
20
21 build-indep: build
22 build-arch: build
23
24 clean:
25         $(checkdir)
26         rm -f build
27         set -e; for s in $(subdirs_build_arch); do \
28                 $(MAKE) -C $$s -i distclean || \
29                 $(MAKE) -C $$s -f Makefile.in distclean; \
30         done
31         rm -rf *~ debian/tmp debian/*~ debian/files* debian/substvars*
32         rm -rf debian/sv-* debian/*.debhelper.log
33
34 binary-prep:
35         $(checkdir)
36         rm -rf debian/tmp*
37         #
38         set -e; for s in $(subdirs_build_arch) $(subdirs_nobuild); do \
39                 $(MAKE) -C $$s install install-docs install-examples \
40                         prefix=$t/$$s/usr \
41                         etcdir=$t/$$s/etc \
42                         varlib=$t/$$s/var/lib \
43                         mandir=$t/$$s/usr/share/man; \
44         done
45         #
46         mv $t/cprogs $t/chiark-utils-bin
47         #
48         cp -a debian/tmp/sync-accounts/* debian/tmp/scripts/.
49         rm -r debian/tmp/sync-accounts
50         mv debian/tmp/scripts debian/tmp/chiark-scripts
51         mv debian/tmp/backup debian/tmp/chiark-backup
52         #
53         set -e; for p in $(packages); do \
54                 install -d $t/$$p/DEBIAN $t/$$p/usr/share/doc/$$p; \
55                 cp debian/copyright debian/changelog \
56                         $t/$$p/usr/share/doc/$$p/; \
57                 ln -s changelog.gz \
58                         $t/$$p/usr/share/doc/$$p/changelog.Debian.gz; \
59                 gzip -9v $t/$$p/usr/share/doc/$$p/changelog; \
60                 done
61         #
62         install -d $t/chiark-rwbuffer/usr/bin
63         install -d $t/chiark-rwbuffer/usr/share/man/man1
64         cd $t/chiark-utils-bin/usr/bin && \
65                 mv readbuffer writebuffer $t/chiark-rwbuffer/usr/bin/
66         cd $t/chiark-utils-bin/usr/share/man/man1 && \
67                 mv readbuffer.1 writebuffer.1 $t/chiark-rwbuffer/usr/share/man/man1/
68         #
69         install -d $t/chiark-backup/usr/share/man/man1
70         cp backup/man/*.1 $t/chiark-backup/usr/share/man/man1/
71         cd $t/chiark-backup/usr/share/man/man1 && \
72                 for m in *.1; do \
73                         mv "$$m" backup-"$$m"; \
74                 done
75         cp \
76  $t/chiark-backup/usr/share/doc/chiark-backup/examples/chiark/settings.sh \
77  $t/chiark-backup/etc/chiark-backup/settings.sh
78         #
79         install -d $t/chiark-really/usr/sbin
80         install -d $t/chiark-really/usr/share/man/man8
81         cd $t/chiark-utils-bin/usr/sbin && \
82                 mv really $t/chiark-really/usr/sbin/
83         cd $t/chiark-utils-bin/usr/share/man/man8 && \
84                 mv really.8 $t/chiark-really/usr/share/man/man8/
85         rm      $t/chiark-utils-bin/usr/sbin/trivsoundd \
86                 $t/chiark-utils-bin/usr/share/man/man8/trivsoundd.8
87         rmdir   $t/chiark-utils-bin/usr/sbin \
88                 $t/chiark-utils-bin/usr/share/man/man8
89         #
90         gzip -9f $t/*/usr/share/man/man*/*
91
92 binary-hook-chiark-backup:
93 binary-hook-chiark-rwbuffer:
94 binary-hook-sync-accounts:
95 binary-hook-chiark-scripts:
96 binary-hook-chiark-really:
97 binary-hook-chiark-utils-bin:
98
99 binary-one:
100         set -e; for f in preinst postinst prerm postrm conffiles; do \
101                 test -f debian/$p/$$f || continue; \
102                 cp debian/$p/$$f $t/$p/DEBIAN/$$f; \
103                 chmod u=rwX,go=rX $t/$p/DEBIAN/$$f; \
104         done
105         dpkg-gencontrol -isp -p$p -P$t/$p -Tdebian/sv-$p
106         chown -R root.root debian/tmp
107         chmod -R g-ws debian/tmp
108         debian/rules binary-hook-$p
109         dpkg --build $t/$p ..
110
111 binary-indep:   checkroot build binary-prep
112         set -e; for p in $(packages_indep); do \
113                 debian/rules binary-one p=$$p; done
114
115 binary-arch:    checkroot build binary-prep
116         $(checkdir)
117         set -ex; for p in chiark-really chiark-utils-bin chiark-rwbuffer; do \
118                 dh_strip -p$$p -Pdebian/tmp/$$p; done
119         dpkg-shlibdeps -Tdebian/sv-chiark-rwbuffer \
120                 $t/chiark-rwbuffer/usr/bin/*
121         dpkg-shlibdeps -Tdebian/sv-chiark-really \
122                 $t/chiark-really/usr/sbin/*
123         set -e; for f in $t/chiark-utils-bin/usr/bin/*; do \
124                 case "$$f" in \
125                 */xacpi-simple)         d=Suggests      ;; \
126                 */watershed|*/summer)   d=Recommends    ;; \
127                 *)                      d=Depends       ;; \
128                 esac; \
129                 a="$$a -d$$d $$f"; \
130             done; set -x; \
131             dpkg-shlibdeps -Tdebian/sv-chiark-utils-bin $$a
132         perl -i~ -pe '                                          '\
133          -e'    next unless m/^shlibs:/;                        '\
134          -e'    s/$$/,/; s/=/=, /;                              '\
135          -e'    s/, libgmp3(?:c2)?,/, libgmp3 | libgmp3c2,/;    '\
136          -e'    s/=, /=/; s/,$$//;                              '\
137                         debian/sv-*[!~]
138         set -e; for p in $(packages_arch); \
139                 do debian/rules binary-one p=$$p; done
140
141 define checkdir
142         test -f cprogs/writebuffer.c
143 endef
144
145 # Below here is fairly generic really
146
147 binary:         binary-indep binary-arch
148
149 source diff:
150         @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
151
152 checkroot:
153         $(checkdir)
154         test root = "`whoami`"
155
156 .PHONY: binary binary-arch binary-indep clean checkroot