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