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