File: rules

package info (click to toggle)
fonty 1.0-12
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,864 kB
  • ctags: 120
  • sloc: cpp: 1,114; perl: 767; makefile: 133; sh: 80
file content (461 lines) | stat: -rwxr-xr-x 21,388 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
#! /usr/bin/make -f
# Generated automatically from debian/packages
# by yada v0.9.9, of Tue, 07 Dec 1999
# Modified by Piotr Roszatycki <dexter@debian.org>, Mon,  1 Oct 2001 13:14:11 +0200

DEB_HOST_GNU_CPU    := $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
DEB_HOST_GNU_TYPE   := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_HOST_GNU_SYSTEM := $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)

DEB_BUILD_GNU_CPU    := $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
DEB_BUILD_GNU_TYPE   := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_BUILD_GNU_SYSTEM := $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)

VERSION:=$(shell LC_ALL=C dpkg-parsechangelog | sed -ne 's/^Version: *\([^2]*\)/\1/p')

SHELL=/bin/bash

.PHONY: default
default:
	@echo "Specify a target:"; \
	echo " build              compile the package"; \
	echo " binary             make all binary packages"; \
	echo " binary-arch        make all architecture-dependent binary packages"; \
	echo " binary-indep       make all architecture-independent binary packages"; \
	echo " clean              clean up the source package"; \
	echo; \
	echo " depends            check build-time dependencies"; \
	echo " patch              apply patches from debian/*.diff"; \
	echo " unpatch            unapply patches from debian/*.diff{,disabled}"; \
	echo " install-tree       compile the package and create the install trees"; \
	echo " clean-install-tree clean up only under debian/"; \
	echo

# Check build dependencies and conflicts

.PHONY: depends
depends: chmod-yada debian/depends-stamp
debian/depends-stamp:
	@echo 'Checking build conflicts and dependencies; just a minute...'
	@echo -n 'grep-dctrl...'; v=$$(grep-status -X -F Package 'grep-dctrl' | grep Version | head -1 | sed -e 's/^Version: //'); \
	if test ! "$$v"; then echo -n 'grep-dctrl (virtual package)...'; v=$$(grep-status -e -F Provides '(^grep-dctrl, |, grep-dctrl$$|^grep-dctrl$$)' | grep Version | head -1 | sed -e 's/^Version: //'); fi; \
	if test "$$v"; then \
	    exit 0; \
	fi; \
	echo 'Build depends on `grep-dctrl'\'' (any version), which is not satisfied' | fmt; exit 1
	@echo -n 'console-tools...'; v=$$(grep-status -X -F Package 'console-tools' | grep Version | head -1 | sed -e 's/^Version: //'); \
	if test ! "$$v"; then echo -n 'console-tools (virtual package)...'; v=$$(grep-status -e -F Provides '(^console-tools, |, console-tools$$|^console-tools$$)' | grep Version | head -1 | sed -e 's/^Version: //'); fi; \
	if test "$$v"; then \
	    exit 0; \
	fi; \
	echo 'Build depends on `console-tools'\'' (any version), which is not satisfied' | fmt; exit 1
	@echo -n 'console-data...'; v=$$(grep-status -X -F Package 'console-data' | grep Version | head -1 | sed -e 's/^Version: //'); \
	if test ! "$$v"; then echo -n 'console-data (virtual package)...'; v=$$(grep-status -e -F Provides '(^console-data, |, console-data$$|^console-data$$)' | grep Version | head -1 | sed -e 's/^Version: //'); fi; \
	if test "$$v"; then \
	    exit 0; \
	fi; \
	echo 'Build depends on `console-data'\'' (any version), which is not satisfied' | fmt; exit 1
	@echo -n 'yada...'; v=$$(grep-status -X -F Package 'yada' | grep Version | head -1 | sed -e 's/^Version: //'); \
	if test ! "$$v"; then echo -n 'yada (virtual package)...'; v=$$(grep-status -e -F Provides '(^yada, |, yada$$|^yada$$)' | grep Version | head -1 | sed -e 's/^Version: //'); fi; \
	if test "$$v"; then \
	  if dpkg --compare-versions "$$v" '>=' '0.9.9'; then \
	    exit 0; \
	  fi; \
	fi; \
	echo 'Build depends on `yada'\'' (version >= 0.9.9), which is not satisfied' | fmt; exit 1
	@echo -n 'grep-dctrl...'; v=$$(grep-status -X -F Package 'grep-dctrl' | grep Version | head -1 | sed -e 's/^Version: //'); \
	if test ! "$$v"; then echo -n 'grep-dctrl (virtual package)...'; v=$$(grep-status -e -F Provides '(^grep-dctrl, |, grep-dctrl$$|^grep-dctrl$$)' | grep Version | head -1 | sed -e 's/^Version: //'); fi; \
	if test "$$v"; then \
	    exit 0; \
	fi; \
	echo 'Build depends on `grep-dctrl'\'' (any version), which is not satisfied' | fmt; exit 1
	@echo -n 'yada...'; v=$$(grep-status -X -F Package 'yada' | grep Version | head -1 | sed -e 's/^Version: //'); \
	if test ! "$$v"; then echo -n 'yada (virtual package)...'; v=$$(grep-status -e -F Provides '(^yada, |, yada$$|^yada$$)' | grep Version | head -1 | sed -e 's/^Version: //'); fi; \
	if test "$$v"; then \
	  if dpkg --compare-versions "$$v" '>=' '0.9.9'; then \
	    exit 0; \
	  fi; \
	fi; \
	echo 'Build depends on `yada'\'' (version >= 0.9.9), which is not satisfied' | fmt; exit 1
	@echo
	@echo 'Conflicts and dependencies all satisfied!'
	touch debian/depends-stamp

.PHONY: patch unpatch
# Apply patches matching `debian/*.diff' to the source tree,
# and unapply any applied patches `debian/*.diff.disabled'
patch: chmod-yada debian/patch-stamp
debian/patch-stamp:
	@set -e; backupdirs=$$(ls -d debian/backup-* 2>/dev/null | wc -l); \
	if test $$backupdirs -gt 1; then \
	  echo "*** Yada error: There are multiple debian/backup-* directories."; \
	  echo "***             I can't cope.  Please clean up for me."; \
	  exit 1; \
	fi; \
	if test $$backupdirs = 1; then \
	  patchname="$$(echo debian/backup-* | sed 's=^debian/backup-==')"; \
	  echo "*** Cleaning up after interrupted patching run for $$patchname"; \
	  if test -f "debian/patch-$$patchname-applied"; then \
	    rm -rf "debian/backup-$$patchname"; \
	  else \
	    (cd "debian/backup-$$patchname"; find . -type f -print0) | xargs -0ri mv -f -- debian/backup-$$patchname/{} {}; \
	    find "debian/backup-$$patchname" -depth -type d -exec rmdir '{}' \;; \
	    if test -e "debian/backup-$$patchname"; then \
	      echo "*** Yada error: I could not recover cleanly from an interrupted patch."; \
	      echo "***             I can't cope.  Please clean up for me."; \
	      exit 1; \
	    fi; \
	  fi; \
	fi

	@set -e; backdowndirs=$$(ls -d debian/backdown-* 2>/dev/null | wc -l); \
	if test $$backdowndirs -gt 1; then \
	  echo "*** Yada error: There are multiple debian/backdown-* directories."; \
	  echo "***             I can't cope.  Please clean up for me."; \
	  exit 1; \
	fi; \
	if test $$backdowndirs = 1; then \
	  patchname="$$(echo debian/backdown-* | sed 's=^debian/backdown-==')"; \
	  echo "*** Cleaning up after interrupted unpatching run for $$patchname"; \
	  if test ! -f "debian/patch-$$patchname-applied"; then \
	    rm -rf "debian/backdown-$$patchname"; \
	  else \
	    (cd "debian/backdown-$$patchname"; find . -type f -print0) | xargs -0ri mv -f -- debian/backdown-$$patchname/{} {}; \
	    find "debian/backdown-$$patchname" -depth -type d -exec rmdir '{}' \;; \
	    if test -e "debian/backdown-$$patchname"; then \
	      echo "*** Yada error: I could not recover cleanly from an interrupted patch."; \
	      echo "***             I can't cope.  Please clean up for me."; \
	      exit 1; \
	    fi; \
	  fi; \
	fi

	@set -e; for stampfile in debian/patch-*-applied; do \
	  if test -f "$$stampfile"; then \
	    patchname="$$(echo "$$stampfile" | sed 's=^debian/patch-\(.*\)-applied$$=\1=')"; \
	    patchfile="debian/$$patchname.disabled"; \
	    if test -f "$$patchfile"; then \
	      echo "*** $$patchfile is now disabled; patching it out"; \
	      patchoptions="$$(sed -n '/^#PATCHOPTIONS:/{;s/^[^:]*://;p;q;}' <"$$patchfile")"; \
	      patch -R -f -i "$$patchfile" -b -V simple -B "debian/backdown-$$patchname/" $$patchoptions; \
	      rm -f "$$stampfile"; \
	      rm -rf "debian/backdown-$$patchname"; \
	    fi; \
	  fi; \
	done

	@set -e; for patchfile in debian/*.diff; do \
	  if test -f "$$patchfile"; then \
	    patchname="$$(echo "$$patchfile" | sed 's=^debian/==')"; \
	    stampfile="debian/patch-$$patchname-applied"; \
	    if test ! -f "$$stampfile"; then \
	      echo "*** Applying patch from $$patchname"; \
	      patchoptions="$$(sed -n '/^#PATCHOPTIONS:/{;s/^[^:]*://;p;q;}' <"$$patchfile")"; \
	      patch -N -f -i "$$patchfile" -b -V simple -B "debian/backup-$$patchname/" $$patchoptions; \
	      touch "$$stampfile"; \
	      rm -rf "debian/backup-$$patchname"; \
	    fi; \
	  fi; \
	done

	touch debian/patch-stamp

# Remove all managed patches from the source tree
unpatch: chmod-yada
	@set -e; backupdirs=$$(ls -d debian/backup-* 2>/dev/null | wc -l); \
	if test $$backupdirs -gt 1; then \
	  echo "*** Yada error: There are multiple debian/backup-* directories."; \
	  echo "***             I can't cope.  Please clean up for me."; \
	  exit 1; \
	fi; \
	if test $$backupdirs = 1; then \
	  patchname="$$(echo debian/backup-* | sed 's=^debian/backup-==')"; \
	  echo "*** Cleaning up after interrupted patching run for $$patchname"; \
	  if test -f "debian/patch-$$patchname-applied"; then \
	    rm -rf "debian/backup-$$patchname"; \
	  else \
	    (cd "debian/backup-$$patchname"; find . -type f -print0) | xargs -0ri mv -f -- debian/backup-$$patchname/{} {}; \
	    find "debian/backup-$$patchname" -depth -type d -exec rmdir '{}' \;; \
	    if test -e "debian/backup-$$patchname"; then \
	      echo "*** Yada error: I could not recover cleanly from an interrupted patch."; \
	      echo "***             I can't cope.  Please clean up for me."; \
	      exit 1; \
	    fi; \
	  fi; \
	fi

	@set -e; backdowndirs=$$(ls -d debian/backdown-* 2>/dev/null | wc -l); \
	if test $$backdowndirs -gt 1; then \
	  echo "*** Yada error: There are multiple debian/backdown-* directories."; \
	  echo "***             I can't cope.  Please clean up for me."; \
	  exit 1; \
	fi; \
	if test $$backdowndirs = 1; then \
	  patchname="$$(echo debian/backdown-* | sed 's=^debian/backdown-==')"; \
	  echo "*** Cleaning up after interrupted unpatching run for $$patchname"; \
	  if test ! -f "debian/patch-$$patchname-applied"; then \
	    rm -rf "debian/backdown-$$patchname"; \
	  else \
	    (cd "debian/backdown-$$patchname"; find . -type f -print0) | xargs -0ri mv -f -- debian/backdown-$$patchname/{} {}; \
	    find "debian/backdown-$$patchname" -depth -type d -exec rmdir '{}' \;; \
	    if test -e "debian/backdown-$$patchname"; then \
	      echo "*** Yada error: I could not recover cleanly from an interrupted patch."; \
	      echo "***             I can't cope.  Please clean up for me."; \
	      exit 1; \
	    fi; \
	  fi; \
	fi

	@set -e; for stampfile in debian/patch-*-applied; do \
	  if test -f "$$stampfile"; then \
	    patchname="$$(echo "$$stampfile" | sed 's=^debian/patch-\(.*\)-applied$$=\1=')"; \
	    patchfile="debian/$$patchname"; \
	    if test ! -f "$$patchfile"; then \
	      patchfile="$$patchfile.disabled"; \
	    fi; \
	    if test -f "$$patchfile"; then \
	      echo "*** Removing patch from $$patchname"; \
	      patchoptions="$$(sed -n '/^#PATCHOPTIONS:/{;s/^[^:]*://;p;q;}' <"$$patchfile")"; \
	      patch -R -f -i "$$patchfile" -b -V simple -B "debian/backdown-$$patchname/" $$patchoptions; \
	      rm -f "$$stampfile"; \
	      rm -rf "debian/backdown-$$patchname"; \
	    else \
	      echo "*** Yada warning: Cannot find a patchfile named \`$$patchname' to unapply"; \
	    fi; \
	  fi; \
	done

	rm -f debian/patch-stamp

# Build the package and prepare the install tree

.PHONY: build-only build
build-only: debian/build-stamp
build: chmod-yada build-only

# Make sure these rules and the control file are up-to-date

.PHONY: rules control
rules: debian/rules
debian/rules: $(shell which yada) debian/packages
	$(shell which yada) rebuild rules

control: debian/control
debian/control: $(shell which yada) debian/packages
	$(shell which yada) rebuild control

debian/build-stamp: debian/depends-stamp debian/patch-stamp
	@[ -f $(shell which yada) -a -f debian/rules ]
	@umask 022 \
	    && export PACKAGE="fonty" \
	    && export VERSION="$(VERSION)" \
	    && export DEB_HOST_GNU_CPU="$(DEB_HOST_GNU_CPU)" \
	    && export DEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
	    && export DEB_HOST_GNU_SYSTEM="$(DEB_HOST_GNU_SYSTEM)" \
	    && export DEB_BUILD_GNU_CPU="$(DEB_BUILD_GNU_CPU)" \
	    && export DEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
	    && export DEB_BUILD_GNU_SYSTEM="$(DEB_BUILD_GNU_SYSTEM)" \
 && (\
	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
	echo -E 'CXXFLAGS="-O2 -Wall"';\
	echo -E 'if [ "$${DEB_BUILD_OPTIONS#*debug}" != "$$DEB_BUILD_OPTIONS" ]; then';\
	echo -E '    CXXFLAGS="$$CXXFLAGS -g"';\
	echo -E 'fi';\
	echo -E 'make CXXFLAGS="$$CXXFLAGS"') | /bin/sh
	touch debian/build-stamp

.PHONY: install-tree
install-tree: chmod-yada install-tree-any
install-tree-any: \
	debian/tmp-dynafont/DEBIAN/control \
	debian/tmp-fonty-dev/DEBIAN/control \
	debian/tmp-fonty/DEBIAN/control

debian/tmp-dynafont/DEBIAN/control: debian/build-stamp debian/control
	rm -rf debian/tmp-dynafont
	umask 022 && install -d debian/tmp-dynafont/DEBIAN
	install -d debian/tmp-dynafont/usr/share/doc/dynafont
	umask 022; $(shell which yada) generate copyright \
	                       >debian/tmp-dynafont/usr/share/doc/dynafont/copyright
	install -m 644 -p debian/changelog \
	                  debian/tmp-dynafont/usr/share/doc/dynafont/changelog.Debian
	@umask 022 \
	    && export PACKAGE="dynafont" \
	    && export ROOT="$$(pwd)/debian/tmp-dynafont" \
	    && export CONTROL="$$(pwd)/debian/tmp-dynafont/DEBIAN" \
	    && export VERSION="$(VERSION)" \
	    && export DEB_HOST_GNU_CPU="$(DEB_HOST_GNU_CPU)" \
	    && export DEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
	    && export DEB_HOST_GNU_SYSTEM="$(DEB_HOST_GNU_SYSTEM)" \
	    && export DEB_BUILD_GNU_CPU="$(DEB_BUILD_GNU_CPU)" \
	    && export DEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
	    && export DEB_BUILD_GNU_SYSTEM="$(DEB_BUILD_GNU_SYSTEM)" \
 && (\
	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
	echo -E 'yada install -bin -into /usr/lib/konwert/aux dynafont/dynafont';\
	echo -E 'yada install -script -into /usr/share/konwert/filters -as dynafont dynafont/wrapper';\
	echo -E 'yada install -data -into /usr/share/consolefonts unicode/uni-compact-16.sbf';\
	echo -E 'gzip -n -9 $$ROOT/usr/share/consolefonts/*';\
	echo -E 'yada install -doc -as README.Debian debian/README.dynafont';\
	echo -E 'yada install -doc doc/en/dynafont';\
	echo -E 'yada install -doc -subdir pl doc/pl/dynafont';\
	echo -E 'yada dpkg-shlibdeps') | /bin/sh
	$(shell which yada) compress dynafont
	$(shell which yada) generate maintscripts dynafont
	find debian/tmp-dynafont -type f -print \
	  | sed -n 's/^debian\/tmp-dynafont\(\/etc\/.*\)$$/\1/p' \
	    > debian/tmp-dynafont/DEBIAN/conffiles
	if test ! -s debian/tmp-dynafont/DEBIAN/conffiles; then rm -f debian/tmp-dynafont/DEBIAN/conffiles; fi
	$(shell which yada) rebuild control
	$(shell which yada) generate substvars dynafont
	umask 022 && dpkg-gencontrol -isp -pdynafont -Pdebian/tmp-dynafont

debian/tmp-fonty-dev/DEBIAN/control: debian/build-stamp debian/control
	rm -rf debian/tmp-fonty-dev
	umask 022 && install -d debian/tmp-fonty-dev/DEBIAN
	install -d debian/tmp-fonty-dev/usr/share/doc/fonty-dev
	umask 022; $(shell which yada) generate copyright \
	                       >debian/tmp-fonty-dev/usr/share/doc/fonty-dev/copyright
	install -m 644 -p debian/changelog \
	                  debian/tmp-fonty-dev/usr/share/doc/fonty-dev/changelog.Debian
	@umask 022 \
	    && export PACKAGE="fonty-dev" \
	    && export ROOT="$$(pwd)/debian/tmp-fonty-dev" \
	    && export CONTROL="$$(pwd)/debian/tmp-fonty-dev/DEBIAN" \
	    && export VERSION="$(VERSION)" \
	    && export DEB_HOST_GNU_CPU="$(DEB_HOST_GNU_CPU)" \
	    && export DEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
	    && export DEB_HOST_GNU_SYSTEM="$(DEB_HOST_GNU_SYSTEM)" \
	    && export DEB_BUILD_GNU_CPU="$(DEB_BUILD_GNU_CPU)" \
	    && export DEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
	    && export DEB_BUILD_GNU_SYSTEM="$(DEB_BUILD_GNU_SYSTEM)" \
 && (\
	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
	echo -E 'yada install -script tools/psf2sbf tools/sbf2psf';\
	echo -E 'yada install -doc -as changelog doc/en/CHANGES';\
	echo -E 'yada install -doc doc/en/README doc/en/TODO doc/en/thanks';\
	echo -E 'yada install -doc -subdir pl doc/pl/CZYTAJTO doc/pl/podziekowania \';\
	echo -E '   doc/pl/format_sbf doc/pl/teoria doc/pl/unikod';\
	echo -E 'yada install -doc -subdir examples unicode/uni-16.sbf';\
	echo -E 'yada undocumented psf2sbf.1';\
	echo -E 'yada undocumented sbf2psf.1';\
	echo -E 'yada perl') | /bin/sh
	$(shell which yada) compress fonty-dev
	$(shell which yada) generate maintscripts fonty-dev
	find debian/tmp-fonty-dev -type f -print \
	  | sed -n 's/^debian\/tmp-fonty-dev\(\/etc\/.*\)$$/\1/p' \
	    > debian/tmp-fonty-dev/DEBIAN/conffiles
	if test ! -s debian/tmp-fonty-dev/DEBIAN/conffiles; then rm -f debian/tmp-fonty-dev/DEBIAN/conffiles; fi
	$(shell which yada) rebuild control
	$(shell which yada) generate substvars fonty-dev
	umask 022 && dpkg-gencontrol -isp -pfonty-dev -Pdebian/tmp-fonty-dev

debian/tmp-fonty/DEBIAN/control: debian/build-stamp debian/control
	rm -rf debian/tmp-fonty
	umask 022 && install -d debian/tmp-fonty/DEBIAN
	install -d debian/tmp-fonty/usr/share/doc/fonty
	umask 022; $(shell which yada) generate copyright \
	                       >debian/tmp-fonty/usr/share/doc/fonty/copyright
	install -m 644 -p debian/changelog \
	                  debian/tmp-fonty/usr/share/doc/fonty/changelog.Debian
	@umask 022 \
	    && export PACKAGE="fonty" \
	    && export ROOT="$$(pwd)/debian/tmp-fonty" \
	    && export CONTROL="$$(pwd)/debian/tmp-fonty/DEBIAN" \
	    && export VERSION="$(VERSION)" \
	    && export DEB_HOST_GNU_CPU="$(DEB_HOST_GNU_CPU)" \
	    && export DEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
	    && export DEB_HOST_GNU_SYSTEM="$(DEB_HOST_GNU_SYSTEM)" \
	    && export DEB_BUILD_GNU_CPU="$(DEB_BUILD_GNU_CPU)" \
	    && export DEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
	    && export DEB_BUILD_GNU_SYSTEM="$(DEB_BUILD_GNU_SYSTEM)" \
 && (\
	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
	echo -E 'yada install -data -into /usr/share/consolefonts psf/*';\
	echo -E 'gzip -n -9 $$ROOT/usr/share/consolefonts/*';\
	echo -E 'yada install -data -into /usr/share/consoletrans -as fonty.fallback qrczak.fallback';\
	echo -E 'gzip -n -9 $$ROOT/usr/share/consoletrans/*';\
	echo -E 'yada install -doc -as changelog doc/en/CHANGES';\
	echo -E 'yada install -doc -as README.Debian debian/README.fonty';\
	echo -E 'yada install -doc doc/en/README doc/en/BUGS doc/en/TODO doc/en/fonts doc/en/thanks';\
	echo -E 'yada install -doc -subdir pl doc/pl/BLEDY doc/pl/CZYTAJTO doc/pl/fonty doc/pl/podziekowania';\
	echo -E 'yada install -data -into /usr/share/lintian/overrides -as fonty debian/override') | /bin/sh
	$(shell which yada) compress fonty
	$(shell which yada) generate maintscripts fonty
	find debian/tmp-fonty -type f -print \
	  | sed -n 's/^debian\/tmp-fonty\(\/etc\/.*\)$$/\1/p' \
	    > debian/tmp-fonty/DEBIAN/conffiles
	if test ! -s debian/tmp-fonty/DEBIAN/conffiles; then rm -f debian/tmp-fonty/DEBIAN/conffiles; fi
	$(shell which yada) rebuild control
	$(shell which yada) generate substvars fonty
	umask 022 && dpkg-gencontrol -isp -pfonty -Pdebian/tmp-fonty

# Build package files

.PHONY: binary binary-arch binary-indep
binary: binary-arch binary-indep
binary-arch: chmod-yada binary-arch-any

.PHONY: binary-arch-any
binary-arch-any: \
	binary-package-dynafont
binary-indep: chmod-yada \
	binary-package-fonty-dev \
	binary-package-fonty

.PHONY: binary-package-dynafont
binary-package-dynafont: check-root debian/tmp-dynafont/DEBIAN/control
	@[ -f $(shell which yada) -a -f debian/rules ]
	chown -R 0.0 debian/tmp-dynafont
	chmod -R u=rwX,go=rX debian/tmp-dynafont
	@if [ -d debian/tmp-dynafont/usr/doc/dynafont ]; then \
	  echo "*** Yada warning: /usr/doc/dynafont should be /usr/share/doc/dynafont";\
	fi
	dpkg-deb --build debian/tmp-dynafont ..

.PHONY: binary-package-fonty-dev
binary-package-fonty-dev: check-root debian/tmp-fonty-dev/DEBIAN/control
	@[ -f $(shell which yada) -a -f debian/rules ]
	chown -R 0.0 debian/tmp-fonty-dev
	chmod -R u=rwX,go=rX debian/tmp-fonty-dev
	@if [ -d debian/tmp-fonty-dev/usr/doc/fonty-dev ]; then \
	  echo "*** Yada warning: /usr/doc/fonty-dev should be /usr/share/doc/fonty-dev";\
	fi
	dpkg-deb --build debian/tmp-fonty-dev ..

.PHONY: binary-package-fonty
binary-package-fonty: check-root debian/tmp-fonty/DEBIAN/control
	@[ -f $(shell which yada) -a -f debian/rules ]
	chown -R 0.0 debian/tmp-fonty
	chmod -R u=rwX,go=rX debian/tmp-fonty
	@if [ -d debian/tmp-fonty/usr/doc/fonty ]; then \
	  echo "*** Yada warning: /usr/doc/fonty should be /usr/share/doc/fonty";\
	fi
	dpkg-deb --build debian/tmp-fonty ..

.PHONY: check-root
check-root:
	@[ `id -u` = 0 ] || (echo "You must be root to do this!"; false)

.PHONY: chmod-yada
chmod-yada:
	@if [ -f debian/yada -a ! -x debian/yada ]; then \
	  chmod +x debian/yada; \
	fi

# Clean up afterwards

.PHONY: clean clean-install-tree clean-build
clean: chmod-yada clean-install-tree clean-build unpatch debian/control debian/rules

clean-build:
	@[ -f $(shell which yada) -a -f debian/rules ]
	rm -f debian/build-stamp debian/depends-stamp
	@umask 022 && (\
	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
	echo -E 'make clean || true') | /bin/sh

clean-install-tree: chmod-yada debian/rules
	@[ -f $(shell which yada) -a -f debian/rules ]
	rm -f debian/install-tree-stamp
	rm -rf debian/tmp* debian/files* debian/substvars