chiark / gitweb /
rename xacpi-simple
[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         dh_link -p$p -Pdebian/tmp/$p
106         dpkg-gencontrol -isp -p$p -P$t/$p -Tdebian/sv-$p
107         chown -R root.root debian/tmp
108         chmod -R g-ws debian/tmp
109         debian/rules binary-hook-$p
110         dpkg --build $t/$p ..
111
112 binary-indep:   checkroot build binary-prep
113         set -e; for p in $(packages_indep); do \
114                 debian/rules binary-one p=$$p; done
115
116 binary-arch:    checkroot build binary-prep
117         $(checkdir)
118         set -ex; for p in chiark-really chiark-utils-bin chiark-rwbuffer; do \
119                 dh_strip -p$$p -Pdebian/tmp/$$p; done
120         dpkg-shlibdeps -Tdebian/sv-chiark-rwbuffer \
121                 $t/chiark-rwbuffer/usr/bin/*
122         dpkg-shlibdeps -Tdebian/sv-chiark-really \
123                 $t/chiark-really/usr/sbin/*
124         set -e; for f in $t/chiark-utils-bin/usr/bin/*; do \
125                 case "$$f" in \
126                 */xbatmon-simple)       d=Suggests      ;; \
127                 */watershed|*/summer)   d=Recommends    ;; \
128                 *)                      d=Depends       ;; \
129                 esac; \
130                 a="$$a -d$$d $$f"; \
131             done; set -x; \
132             dpkg-shlibdeps -Tdebian/sv-chiark-utils-bin $$a
133         perl -i~ -pe '                                          '\
134          -e'    next unless m/^shlibs:/;                        '\
135          -e'    s/$$/,/; s/=/=, /;                              '\
136          -e'    s/, libgmp3(?:c2)?,/, libgmp3 | libgmp3c2,/;    '\
137          -e'    s/=, /=/; s/,$$//;                              '\
138                         debian/sv-*[!~]
139         set -e; for p in $(packages_arch); \
140                 do debian/rules binary-one p=$$p; done
141
142 define checkdir
143         test -f cprogs/writebuffer.c
144 endef
145
146 # Below here is fairly generic really
147
148 binary:         binary-indep binary-arch
149
150 source diff:
151         @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
152
153 checkroot:
154         $(checkdir)
155         test root = "`whoami`"
156
157 .PHONY: binary binary-arch binary-indep clean checkroot