chiark / gitweb /
start 6.0.1~
[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 fishdescriptor
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/fishdescriptor/* debian/tmp/scripts/.
56         cp -a debian/tmp/sync-accounts/* debian/tmp/scripts/.
57         rm -r debian/tmp/sync-accounts
58         mv debian/tmp/scripts debian/tmp/chiark-scripts
59         mv debian/tmp/backup debian/tmp/chiark-backup
60         #
61         set -e; for p in $(packages); do \
62                 install -d $t/$$p/DEBIAN $t/$$p/usr/share/doc/$$p; \
63                 cp debian/copyright debian/changelog \
64                         $t/$$p/usr/share/doc/$$p/; \
65                 ln -s changelog.gz \
66                         $t/$$p/usr/share/doc/$$p/changelog.Debian.gz; \
67                 gzip -9vn $t/$$p/usr/share/doc/$$p/changelog; \
68                 done
69         #
70         install -d $t/chiark-rwbuffer/usr/bin
71         install -d $t/chiark-rwbuffer/usr/share/man/man1
72         cd $t/chiark-utils-bin/usr/bin && \
73                 mv readbuffer writebuffer $t/chiark-rwbuffer/usr/bin/
74         cd $t/chiark-utils-bin/usr/share/man/man1 && \
75                 mv readbuffer.1 writebuffer.1 $t/chiark-rwbuffer/usr/share/man/man1/
76         #
77         install -d $t/chiark-backup/usr/share/man/man1
78         cp backup/man/*.1 $t/chiark-backup/usr/share/man/man1/
79         cd $t/chiark-backup/usr/share/man/man1 && \
80                 for m in *.1; do \
81                         mv "$$m" backup-"$$m"; \
82                 done
83         cp \
84  $t/chiark-backup/usr/share/doc/chiark-backup/examples/chiark/settings.sh \
85  $t/chiark-backup/etc/chiark-backup/settings.sh
86         #
87         install -d $t/chiark-really/usr/sbin
88         install -d $t/chiark-really/usr/share/man/man8
89         cd $t/chiark-utils-bin/usr/sbin && \
90                 mv really $t/chiark-really/usr/sbin/
91         cd $t/chiark-utils-bin/usr/share/man/man8 && \
92                 mv really.8 $t/chiark-really/usr/share/man/man8/
93         rm      $t/chiark-utils-bin/usr/sbin/trivsoundd \
94                 $t/chiark-utils-bin/usr/share/man/man8/trivsoundd.8
95         rmdir   $t/chiark-utils-bin/usr/sbin
96         #
97         gzip -9fn $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 -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|*/cgi-fcgi-interp) \
136                                         d=Recommends    ;; \
137                 *)                      d=Depends       ;; \
138                 esac; \
139                 a="$$a -d$$d $$f"; \
140             done; set -x; \
141             dpkg-shlibdeps -Tdebian/sv-chiark-utils-bin $$a
142         set -e; for p in $(packages_arch); \
143                 do debian/rules binary-one p=$$p; done
144
145 define checkdir
146         test -f cprogs/writebuffer.c
147 endef
148
149 # Below here is fairly generic really
150
151 binary:         binary-indep binary-arch
152
153 source diff:
154         @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
155
156 checkroot:
157         $(checkdir)
158         test root = "`whoami`"
159
160 .PHONY: binary binary-arch binary-indep clean checkroot