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