File: rules

package info (click to toggle)
konfont 0.1-7
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 168 kB
  • ctags: 48
  • sloc: makefile: 317
file content (590 lines) | stat: -rwxr-xr-x 25,945 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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Colin's Build System
# Copyright © 2002,2003 Colin Walters <walters@debian.org>
# $Id: rules,v 1.58 2003/05/02 16:34:31 walters Exp $

####################################
# DO NOT MODIFY THIS FILE DIRECTLY #
####################################

### Introduction to Colin's Build System #############################
# This file is shared between all the packages which use Colin's Build
# System.  The idea is that this file contains sane defaults, and
# stuff specific to a package should go into the debian/rocks Makefile
# fragment.  There generic hooks where you can override and add
# functionality for a specific package.

# The big motivating factor for CBS was originally that more and more
# programs today are created using GNU configure scripts and GNU
# automake, and as such they are all very similar to configure and
# build.  CBS takes advantage of this by doing stuff like looking for
# an executable file named "configure"; if it exists, CBS tries
# treating it like a GNU configure script, and passes it sane
# arguments (like --prefix=/usr).  This will work for like 90% of the
# cases out there (including at least all my packages).  But if it
# doesn't work, no problem; you can customize or just completely
# override it the debian/rocks file.  For example, suppose that you
# need to pass "--enable-foo" to the configure script.  In that case,
# all you need to do is create a file named debian/rocks, which
# contains:

# DEB_CONFIGURE_EXTRA_FLAGS := --enable-foo

# And that's it!  Everything else happens automagically.  However,
# suppose that your "configure" script isn't made by autoconf, and
# instead expects the user to interactively configure the program
# (e.g. Perl).  In that case, you can just override the
# "deb-common-configure" rule, by putting something like the following
# in your debian/rocks:

# deb-common-configure:
#	./configure --blah --blargh < debian/answers

# All of the rules which are overridable are listed below, up to the
# line "-include debian/rocks".  There are also a large group of
# variables you may customize to affect a default rule, instead of of
# just overriding the rule completely.

# CBS also helps you keep up-to-date with the latest policy; when
# there is a new DEB_BUILD_OPTIONS entry, or they change semantics (as
# in the latest "debug" => "noopt" change), you shouldn't have to
# change anything in your packages (besides rebuilding them with the
# latest CBS version); CBS will just handle it.

### CBS and Debhelper ################################################
# Colin's Build System currently relies heavily on debhelper version
# 4, so you must have a Build-Depends: debhelper (>= 4.0.0).

### Single vs. Multi Binary packages #################################
# If you have a single binary package, CBS tries to use the upstream
# Makefile to install everything into debian/packagename, so it will
# all appear in the binary package.  To remove files, move them
# around, just override the deb-binary-hook-<packagename> target in
# the debian/rocks file, like:

# deb-binary-hook-mypackage:
#	mv debian/mypackage/usr/sbin/myprogram debian/mypackage/usr/bin/myprogram
#	rm debian/mypackage/usr/share/doc/mypackage/INSTALL

# If you have a multi-binary package, CBS (by default) uses the
# upstream Makefile to install everything in debian/tmp.  After this,
# the recommended method is to use dh_install to copy these files into
# the appropriate package.  To do this, just create
# "packagename.install" files; see the dh_install man page.

### Common Problems ##################################################

# Are you having problems with your package not building with the
# default deb-common-build rule?  This could be because of CFLAGS
# issues.  If it doesn't work, then your upstream's build system is
# broken.  You should be able to set CFLAGS to contain the
# optimization and debugging settings you want, and this shouldn't
# frob any -I or other internal arguments the upstream build system
# needs.  One way to fix this is to have upstream fix their Makefile
# to do something like:

# # This is the default set of optimization and debugging flags, which
# # can be overridden with a CFLAGS passed to the make invocation.
# CFLAGS = -g -O2
# # Now add specific stuff we need.
# override CFLAGS += -I. -I.. -ffrob-stuff

# On a related note, if you want to have a nice, easy-to-maintain,
# working build system, try to convince your upstream to switch to
# automake, autoconf, and libtool.

### The latest version of CBS ########################################
# The canonical source for Colin's Build System is:
# http://cvs.verbum.org/debian/rules

# Note that you can easily update your current version by running:
# debian/rules update

# Are you keeping your Debian packages in CVS?  In that case, it would
# probably be a good idea to disable keyword expansion for this file,
# so debian/rules update won't get confused.  Run:
# cvs admin -ko debian/rules

### Hooks which are overridable ######################################

## This target is called before almost anything else; in particular,
## it is called even before patches are applied.  This is a good place
## to do stuff like generate a debian/control from debian/control.xml,
## etc.
deb-pre-build:
	 # Nothing to do by default.

## This target is called after patches are applied, but before
## configure scripts or anything else are run.  This is a good place
## to do wacky stuff like:
## 'find . -name 'Makefile.in' -exec touch {} \;'.
deb-post-patches:
	 # Nothing to do by default.

## This target is called after patches are applied (i.e. after
## deb-post-patches).  It is, as its name implies, a good place to run
## GNU configure scripts or the like.
deb-common-configure:
	if [ -x ./configure ]; then $(DEB_CONFIGURE_INVOKE) --prefix=$(DEB_CONFIGURE_PREFIX) --mandir=$(DEB_CONFIGURE_MANDIR) --infodir=$(DEB_CONFIGURE_INFODIR) --sysconfdir=$(DEB_CONFIGURE_SYSCONFDIR) --localstatedir=$(DEB_CONFIGURE_LOCALSTATEDIR) --libexecdir=$(DEB_CONFIGURE_LIBEXECDIR) --disable-maintainer-mode $(DEB_CONFIGURE_EXTRA_FLAGS) $(DEB_USER_CONFIGURE_FLAGS); fi

## This target is for configuring a specific package.  It is called
## once for each package.
deb-configure-%:
	 # Nothing to do by default.

## This is an "extra" rule, where you may prefix arbitrary commands to
## the general build, but not override the default.  It is called
## before deb-common-build.
deb-extra-pre-common-build::
	 # Nothing to do by default.

## This target is called after common configuration (but not
## necessarily after package-specific configuration).  Generally, this
## is a good place to invoke make and the like.  Note that if you do
## package-specific configuration, you should likely override this
## rule to do nothing, and then do package-specific building in
## deb-build-<package>.
deb-common-build:
	if [ -f Makefile ]; then \
	  $(DEB_MAKE_ENVVARS) $(MAKE) CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" $(DEB_BUILD_MAKE_TARGET); \
	fi

## This is an "extra" rule, where you may add arbitrary commands to
## the general build, but not override the default.  It is called
## after deb-common-build.
deb-extra-common-build:: deb-common-build
	 # Nothing to do by default.

## This target is called once for each package, after package-specific
## configuration; it is for doing any building to a specific package.
deb-build-%:
	 # Nothing to do by default.

## This is an "extra" rule, where you may add arbitrary commands to
## the package-specific build, but not override the default.  It is
## called after deb-build-<package>.
deb-extra-build-%: deb-build-%
	 # Nothing to do by default.

## This target is called after pre-build, and before any configuration
## takes place.  It is designed to automatically update
## config.{sub,guess} files which are used by packages which use GNU
## autoconf.  You should not generally need to override this target.
## You may need to set DEB_AC_AUX_DIR if upstream used the autoconf
## macro AC_CONFIG_AUX_DIR.
deb-autotools-setup:
	if [ -r /usr/share/misc/config.sub ]; then \
	   if [ -r $(DEB_AC_AUX_DIR)/config.sub ] && [ ! -f $(DEB_AC_AUX_DIR)/config.sub.orig-cbs ]; then \
	       mv $(DEB_AC_AUX_DIR)/config.sub $(DEB_AC_AUX_DIR)/config.sub.orig-cbs; \
	       cp -f /usr/share/misc/config.sub $(DEB_AC_AUX_DIR)/config.sub; \
	   fi; \
	fi
	if [ -r /usr/share/misc/config.guess ]; then \
	   if [ -r $(DEB_AC_AUX_DIR)/config.guess ] && [ ! -f $(DEB_AC_AUX_DIR)/config.guess.orig-cbs ]; then \
	       mv $(DEB_AC_AUX_DIR)/config.guess $(DEB_AC_AUX_DIR)/config.guess.orig-cbs; \
	       cp -f /usr/share/misc/config.guess $(DEB_AC_AUX_DIR)/config.guess; \
	   fi; \
	fi

## This target is called during the clean process; it is designed to
## undo the effects of deb-autotools-setup, so that you won't get
## spurious bits in your Debian diff.  You should not generally need
## to override this target.
deb-autotools-clean:
	if [ -r $(DEB_AC_AUX_DIR)/config.sub.orig-cbs ]; then \
	  mv $(DEB_AC_AUX_DIR)/config.sub.orig-cbs $(DEB_AC_AUX_DIR)/config.sub; \
	fi
	if [ -r $(DEB_AC_AUX_DIR)/config.guess.orig-cbs ]; then \
	  mv $(DEB_AC_AUX_DIR)/config.guess.orig-cbs $(DEB_AC_AUX_DIR)/config.guess; \
	fi

## This target is called during the cleaning process.
deb-clean:
	if [ -f Makefile ]; then $(MAKE) distclean || $(MAKE) clean || true; fi
	if test -f config.log; then \
	  if grep -i -q 'generated by GNU Autoconf' config.log || grep -i -q 'to aid debugging if configure ' config.log; then \
	    rm -f config.log; \
	  fi; \
	fi
	if test -f config.status && grep -i -q 'Generated.*by configure.' config.status; then rm -f config.status; fi
	if test -f config.cache && grep -i -q 'shell.*script.*caches.*results.*configure' config.cache; then rm -f config.cache; fi

## This is an "extra" rule, where you may add arbitrary commands to
## the cleaning process, but not override the default.
deb-extra-clean:: deb-clean
	 # Nothing to do by default.

## This target is called after the common installation step.  It
## should install your package into its destination, e.g. debian/tmp
## (for single-binary packages, into debian/<packagename>).
deb-common-install:
	if [ -f Makefile ]; then \
	  if grep -q DESTDIR Makefile || grep -q -i 'generated.*by.*automake' Makefile; then \
	    $(DEB_MAKE_ENVVARS) $(MAKE) install DESTDIR=$(DEB_DESTDIR); \
	  else \
	    echo "This Makefile doesn't appear to support DESTDIR; you must override $@ in debian/rocks"; \
	    exit 1; \
	  fi; \
	else \
	  echo "No default install action, you must override $@ in debian/rocks"; \
	  exit 1; \
	fi

## This is an "extra" rule, where you may add arbitrary commands to
## the common installation process, but not override the default.
deb-extra-common-install:: deb-common-install
	 # Nothing to do by default.

## This target is called once for each package, after that package's
## specific build step.
deb-install-%:
	 # Nothing to do by default.

## This is an "extra" rule, where you may add arbitrary commands to
## the installation process for a specific package, but not override
## the default.
deb-extra-install-%: deb-install-%
	 # Nothing to do by default.

## This is a sort of "catchall" rule to do post-installation cleanup.
## It is called by deb-binary-<packagename> after everything should be
## installed in debian/tmp or debian/<packagename>.  This is a good
## place to do things like move binaries from debian/tmp/usr/bin to
## debian/tmp/usr/sbin, convert HTML documentation into plain text,
## etc.
deb-binary-hook-%:
	 # Nothing to do by default.

## This rule is called after the installation for a package.  It does
## all the work of installing things like changelogs, README.Debian
## files, etc., and also actually builds the .deb files.  It relies
## heavily on Debhelper, so please see the docs for those commands to
## understand how it works and to customize things more.  You may
## override this target if you have special needs, but it is not
## recommended.  It is better instead to use one of the provided
## hooks, or add a hook where necessary and send in a patch for CBS.
deb-binary-%: 
	dh_installdocs $(DEB_ALL_DOCS) $(DEB_INSTALL_DOCS_$(DEB_CURPACKAGE)) -p$(DEB_CURPACKAGE)
	dh_installexamples $(DEB_INSTALL_EXAMPLES_$(DEB_CURPACKAGE)) -p$(DEB_CURPACKAGE)
	dh_installman $(DEB_INSTALL_MANPAGES_$(DEB_CURPACKAGE)) -p$(DEB_CURPACKAGE)
	dh_installinfo $(DEB_INSTALL_INFO_$(DEB_CURPACKAGE)) -p$(DEB_CURPACKAGE)
	dh_installmenu -p$(DEB_CURPACKAGE)
	dh_installcron -p$(DEB_CURPACKAGE)
	dh_installdebconf -p$(DEB_CURPACKAGE)
	dh_installpam -p$(DEB_CURPACKAGE)
	dh_installchangelogs $(DEB_ALL_CHANGELOG) -p$(DEB_CURPACKAGE)
	dh_installinit -p$(DEB_CURPACKAGE)
	dh_install -p$(DEB_CURPACKAGE)
	$(internal_invoke) deb-binary-hook-$(DEB_CURPACKAGE)
	$(internal_invoke) deb-strip-$(DEB_CURPACKAGE)
	dh_link -p$(DEB_CURPACKAGE)
	dh_compress -p$(DEB_CURPACKAGE) $(foreach entry,$(DEB_COMPRESS_EXCLUDE),$(patsubst %,-X %,$(entry))) \
	 $(foreach entry,$(DEB_COMPRESS_EXCLUDE_$(DEB_CURPACKAGE)),$(patsubst %,-X %,$(entry)))
	dh_fixperms -p$(DEB_CURPACKAGE) $(foreach entry,$(DEB_FIXPERMS_EXCLUDE),$(patsubst %,-X %,$(entry))) \
	 $(foreach entry,$(DEB_FIXPERMS_EXCLUDE_$(DEB_CURPACKAGE)),$(patsubst %,-X %,$(entry)))
	$(internal_invoke) deb-makeshlibs-$(DEB_CURPACKAGE)
	$(internal_invoke) deb-post-fixperms-binary-$(DEB_CURPACKAGE)
	dh_installdeb -p$(DEB_CURPACKAGE)
	$(internal_invoke) deb-shlibdeps-$(DEB_CURPACKAGE)
	dh_gencontrol -p$(DEB_CURPACKAGE)
	dh_md5sums -p$(DEB_CURPACKAGE)
	dh_builddeb -p$(DEB_CURPACKAGE)

## This rule is called after the installation for a udeb package.  It
## is otherwise similar to deb-binary-%.
deb-udeb-binary-%: 
	dh_install -p$(DEB_CURPACKAGE)
	$(internal_invoke) deb-binary-hook-$(DEB_CURPACKAGE)
	$(internal_invoke) deb-strip-$(DEB_CURPACKAGE)
	dh_compress -p$(DEB_CURPACKAGE) $(foreach entry,$(DEB_COMPRESS_EXCLUDE),$(patsubst %,-X %,$(entry))) \
		$(foreach entry,$(DEB_COMPRESS_EXCLUDE_$(DEB_CURPACKAGE)),$(patsubst %,-X %,$(entry)))
	dh_fixperms -p$(DEB_CURPACKAGE) $(foreach entry,$(DEB_FIXPERMS_EXCLUDE),$(patsubst %,-X %,$(entry))) \
		$(foreach entry,$(DEB_FIXPERMS_EXCLUDE_$(DEB_CURPACKAGE)),$(patsubst %,-X %,$(entry)))
	$(internal_invoke) deb-post-fixperms-binary-$(DEB_CURPACKAGE)
	dh_installdeb -p$(DEB_CURPACKAGE)
	$(internal_invoke) deb-shlibdeps-$(DEB_CURPACKAGE)
	dh_gencontrol -p$(DEB_CURPACKAGE) -- -fdebian/files~
	dpkg-distaddfile $(DEB_CURPACKAGE)_$(DEB_VERSION)_$(DEB_ARCH).udeb debian-installer optional
	dh_builddeb -p$(DEB_CURPACKAGE) --filename=$(DEB_CURPACKAGE)_$(DEB_VERSION)_$(DEB_ARCH).udeb

## This rule is called by the default deb-binary-<package>
## implementation, after all package data has been installed, and
## after the deb-binary-hook-<packagename> has been called.  As its
## name implies, it is where you should strip binaries.
deb-strip-%:
	dh_strip -p$(DEB_CURPACKAGE)

## This rule is called by the default deb-binary-<package>
## implementation, *after* permissions have been sanitized.  This is
## an excellent place to make binaries setuid where necessary, for
## example.
deb-post-fixperms-binary-%:
	 # Nothing to do by default.

## This rule is called by the default deb-binary-<package>
## implementation, right before the final Debian package building
## process.  This is where you should generate a "shlibs" file for
## your package, if necessary.
deb-makeshlibs-%:
	dh_makeshlibs -p$(DEB_CURPACKAGE)

## This rule is called by the default deb-binary-<package>
## implementation, during the final Debian package building
## process.  This is where you should determine 
deb-shlibdeps-%:
	dh_shlibdeps -p$(DEB_CURPACKAGE) $(if $(DEB_SHLIBDEPS_LIBRARY_$(DEB_CURPACKAGE)),-L $(DEB_SHLIBDEPS_LIBRARY_$(DEB_CURPACKAGE))) $(if $(DEB_SHLIBDEPS_INCLUDE_$(DEB_CURPACKAGE))$(DEB_SHLIBDEPS_INCLUDE),-l $(DEB_SHLIBDEPS_INCLUDE_$(DEB_CURPACKAGE)):$(DEB_SHLIBDEPS_INCLUDE))

-include debian/rocks

### Overridable variables #######################################

# Some common variables; usually you shouldn't have to set these.
export DEB_ARCH_PACKAGES ?= $(shell dh_listpackages -a 2>/dev/null || true)
export DEB_INDEP_PACKAGES ?= $(shell dh_listpackages -i 2>/dev/null || true)
export DEB_UPACKAGES=$(shell dh_listpackages 2>/dev/null | grep -- -udeb$$)
export DEB_ALL_PACKAGES ?= $(DEB_ARCH_PACKAGES) $(DEB_INDEP_PACKAGES)
export DEB_SOURCE_PACKAGE ?= $(strip $(shell egrep '^Source: ' debian/control | cut -f 2 -d ':'))

export DH_COMPAT=4

export DEB_VERSION ?= $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')

export DEB_ARCH ?= $(shell dpkg --print-architecture)
export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
export DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)

DEB_C_DEFAULT_OPT ?= -O2
DEB_CXX_DEFAULT_OPT ?= $(DEB_C_DEFAULT_OPT)
CFLAGS ?= -Wall -g
CXXFLAGS ?= -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
	CXXFLAGS += -O0
else
	CFLAGS += $(DEB_C_DEFAULT_OPT)
	CXXFLAGS += $(DEB_CXX_DEFAULT_OPT)
endif

export DEB_PATCHDIRS ?= debian/patches
export DEB_PATCHES ?= $(foreach dir,$(DEB_PATCHDIRS),$(shell echo $(wildcard $(dir)/*.patch) $(wildcard $(dir)/*.diff)))

DEB_CONFIGURE_INVOKE ?= ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE)
DEB_CONFIGURE_PREFIX ?=/usr
DEB_CONFIGURE_MANDIR ?="\$${prefix}/share/man"
DEB_CONFIGURE_INFODIR ?="\$${prefix}/share/info"
DEB_CONFIGURE_SYSCONFDIR ?=/etc
DEB_CONFIGURE_LOCALSTATEDIR ?=/var
DEB_CONFIGURE_LIBEXECDIR ?="\$${prefix}/lib/$(DEB_SOURCE_PACKAGE)"
DEB_CONFIGURE_EXTRA_FLAGS ?=
DEB_MAKE_ENVVARS ?= 
DEB_BUILD_MAKE_TARGET ?= 
DEB_DIRS ?=
DEB_CLEAN ?=
DEB_CLEAN_EXCLUDE ?=
DEB_ALL_DOCS ?=
DEB_KEEP_CHANGELOG_NAME ?=
DEB_ALL_CHANGELOG ?= $(if $(DEB_ISNATIVE),,$(shell if test -r ChangeLog; then echo ChangeLog; fi))
DEB_FIXPERMS_EXCLUDE ?=
DEB_COMPRESS_EXCLUDE ?=
# This variable should be a colon-separated list of paths
DEB_SHLIBDEPS_INCLUDE ?=
DEB_EXAMPLES ?=
DEB_CHANGELOGS ?=
DEB_AC_AUX_DIR ?=.

DEB_PHONY_RULES ?=

DEB_LISTMISSING ?= yes

ifeq ($(strip $(shell echo $(DEB_ALL_PACKAGES) | wc -w)),1)
	DEB_DESTDIR ?= `pwd`/debian/$(strip $(DEB_ALL_PACKAGES))
else
	DEB_DESTDIR ?= `pwd`/debian/tmp
endif

### Other variables ##################################################

DEB_ISNATIVE := $(shell dpkg-parsechangelog | egrep '^Version:' | perl -ne 'print if not /^Version:\s*.*-/;')

### Internal implementation ##########################################
update:
	@if [ -f debian/rules ]; then \
	  curversion=`head debian/rules | perl -lne 'if (/Id: rules,v (.*?) /) { print $$1; }'`; \
	  echo "Installed version: " $$curversion; \
	  rm -rf debian/cbs-update ; mkdir -p debian/cbs-update && cd debian/cbs-update; \
	  echo -n "Downloading latest version from :pserver:anoncvs@cvs.verbum.org:/cvs..."; \
	  cvs -Q -d :pserver:anoncvs@cvs.verbum.org:/cvs co debian/rules; \
	  echo "done."; \
	  newversion=`head debian/rules | perl -lne 'if (/Id: rules,v (.*?) /) { print $$1; }'`; \
	  if [ "$$newversion" != "$$curversion" ]; then \
	    echo "Retrieving log for revisions $$curversion to $$newversion..."; \
	    cvs -q -d :pserver:anoncvs@cvs.verbum.org:/cvs log "-r$$curversion:$$newversion" debian/rules; \
	  else \
	    echo "No changes."; \
	  fi; \
	  mv debian/rules .. ; cd .. ; rm -rf cbs-update ; chmod a+x rules; \
	else \
	  echo "Couldn't find debian/rules; you must execute this target as debian/rules update"; \
	fi

internal_invoke := debian/rules

pre-build: debian/stamp-pre-build
debian/stamp-pre-build:
	$(internal_invoke) deb-pre-build
	touch $@

# The patch subsystem
apply-patches: pre-build debian/stamp-patched
debian/stamp-patched: $(DEB_PATCHES)
debian/stamp-patched reverse-patches:
	@echo "patches: $(DEB_PATCHES)"
	@set -e ; for patch in $(DEB_PATCHES); do \
	  level=$(head $$patch | egrep '^#DPATCHLEVEL=' | cut -f 2 -d '='); \
	  reverse=""; \
	  if [ "$@" = "reverse-patches" ]; then reverse="-R"; fi; \
	  success=""; \
	  if [ -z "$$level" ]; then \
	    echo -n "Trying "; if test -n "$$reverse"; then echo -n "reversed "; fi; echo -n "patch $$patch at level "; \
	    for level in 0 1 2; do \
	      if test -z "$$success"; then \
	        echo -n "$$level..."; \
	        if cat $$patch | patch $$reverse --dry-run -p$$level 1>$$patch.level-$$level.log 2>&1; then \
	          if cat $$patch | patch $$reverse --no-backup-if-mismatch -V never -p$$level 1>$$patch.level-$$level.log 2>&1; then \
	            success=yes; \
	            touch debian/stamp-patch-$$(basename $$patch); \
	            echo "success."; \
                  fi; \
	        fi; \
	      fi; \
            done; \
	    if test -z "$$success"; then \
	      if test -z "$$reverse"; then \
	        echo "failure."; \
	        exit 1; \
	       else \
	         echo "failure (ignored)."; \
               fi \
	    fi; \
	  else \
	    echo -n "Trying patch $$patch at level $$level..."; \
	    if cat $$patch | patch $$reverse --no-backup-if-mismatch -V never -p$$level 1>$$patch.log 2>&1; then \
              touch debian/stamp-patch-$$(basename $$patch); \
	      echo "success."; \
	    else \
	      echo "failure:"; \
	      cat $$patch.log; \
	      if test -z "$$reverse"; then exit 1; fi; \
            fi; \
	  fi; \
	done
	if [ "$@" = "debian/stamp-patched" ]; then touch debian/stamp-patched; fi

post-patches: debian/stamp-post-patches
debian/stamp-post-patches: apply-patches
	$(internal_invoke) deb-post-patches
	touch $@

# The general targets
common-configure: post-patches debian/stamp-common-configure
debian/stamp-common-configure:
	dh_testdir
	$(internal_invoke) deb-autotools-setup
	$(internal_invoke) deb-common-configure
	touch $@
$(patsubst %,configure-%,$(DEB_ALL_PACKAGES)) : configure-% : common-configure debian/stamp-configure-%
$(patsubst %,debian/stamp-configure-%,$(DEB_ALL_PACKAGES)) : debian/stamp-configure-%: debian/stamp-patched
	dh_testdir
	$(internal_invoke) deb-configure-package-$(patsubst debian/stamp-configure-%,%,$@) DEB_CURPACKAGE=$(patsubst debian/stamp-configure-%,%,$@)
	touch $@

# Required Debian target
build: build-arch build-indep

common-build: debian/stamp-common-build
debian/stamp-common-build: $(patsubst %,configure-%,$(DEB_ALL_PACKAGES))
	dh_testdir
	$(internal_invoke) deb-extra-pre-common-build
	$(internal_invoke) deb-extra-common-build
	touch $@
$(patsubst %,build-%,$(DEB_ALL_PACKAGES)) :: build-% : debian/stamp-build-%
$(patsubst %,debian/stamp-build-%,$(DEB_ALL_PACKAGES)) : debian/stamp-build-% : common-build configure-%
	dh_testdir
	$(internal_invoke) deb-extra-build-$(patsubst debian/stamp-build-%,%,$@) DEB_CURPACKAGE=$(patsubst debian/stamp-build-%,%,$@)
	touch $@

build-arch: $(patsubst %,build-%,$(DEB_ARCH_PACKAGES))
build-indep: $(patsubst %,build-%,$(DEB_INDEP_PACKAGES))

# Required Debian target
clean: clean-dh-tests reverse-patches clean-impl
clean-dh-tests:
	dh_testdir
	dh_testroot
clean-impl:
	$(internal_invoke) deb-autotools-clean
	$(internal_invoke) deb-extra-clean
	for dir in $(DEB_PATCHDIRS); do rm -f $$dir/*.log; done
	rm -f debian/stamp-*
	rm -f debian/cbs-install-list
	rm -f debian/cbs-package-list
	dh_clean $(DEB_CLEAN) $(foreach entry,$(DEB_CLEAN_EXCLUDE),$(patsubst %,-X %,$(entry))) 

common-install: debian/stamp-common-install
debian/stamp-common-install: $(patsubst %,build-%,$(DEB_ALL_PACKAGES))
	dh_testdir
	dh_clean -k
	dh_installdirs -A $(DEB_DIRS)
	$(internal_invoke) deb-extra-common-install DEB_CURPACKAGE=
	touch $@
install-arch: $(patsubst %,install-%,$(DEB_ARCH_PACKAGES))
install-indep: $(patsubst %,install-%,$(DEB_INDEP_PACKAGES))
$(patsubst %,install-%,$(DEB_ALL_PACKAGES)) :: install-% : common-install build-%
	dh_testdir
	dh_testroot
	$(internal_invoke) deb-extra-install-$(patsubst install-%,%,$@) DEB_CURPACKAGE=$(patsubst install-%,%,$@)

common-binary: debian/stamp-common-binary
debian/stamp-common-binary: $(patsubst %,install-%,$(DEB_ALL_PACKAGES)) common-install
	dh_testdir
	dh_testroot
	if echo "$@" | grep -e "-udeb$$" 1>/dev/null; then : else \
	  dh_installchangelogs $(if $(DEB_KEEP_CHANGELOG_NAME),-k) $(DEB_ALL_CHANGELOG); \
	fi
	touch $@

list-missing:
	rm -f debian/cbs-install-list
	rm -f debian/cbs-package-list
	if test "$(DEB_LISTMISSING)" = "yes" && test "$(DEB_DESTDIR)" == `pwd`"/debian/tmp"; then \
	  (cd debian/tmp && find . -type f -o -type l | grep -v '/DEBIAN/' | sort) > debian/cbs-install-list; \
	  (for package in $(DEB_ALL_PACKAGES); do \
	     (cd debian/$$package && find . -type f -o -type l); \
	   done) | sort -u > debian/cbs-package-list; \
	  diff -u debian/cbs-install-list debian/cbs-package-list | egrep '^-' || true; \
	fi

# Required Debian targets
binary-indep: common-binary $(patsubst %,binary-%,$(DEB_INDEP_PACKAGES))
	$(internal_invoke) list-missing

binary-arch: common-binary $(patsubst %,binary-%,$(DEB_ARCH_PACKAGES))
	$(internal_invoke) list-missing

binary-% :: common-binary install-% 
	dh_testdir
	dh_testroot
	DEB_CURPACKAGE=$(patsubst binary-%,%,$@); \
	if echo "$$DEB_CURPACKAGE" | grep -e "-udeb$$" 1>/dev/null; then \
	  $(internal_invoke) deb-udeb-binary-$(patsubst binary-%,%,$@) DEB_CURPACKAGE=$$DEB_CURPACKAGE UDEB_FILENAME=$$DEB_CURPACKAGE_$(DEB_VERSION)_$(DEB_ARCH).udeb; \
        else \
	  $(internal_invoke) deb-binary-$(patsubst binary-%,%,$@) DEB_CURPACKAGE=$$DEB_CURPACKAGE; \
	fi

# Required Debian target
binary: binary-indep binary-arch

.PHONY: pre-build apply-patches reverse-patches post-patches common-configure build common-build build-% build-arch build-indep clean clean-dh-tests clean-impl common-install install-arch install-indep install-% common-binary binary-% binary-indep binary-arch binary deb-common-configure deb-common-build deb-clean deb-common-install deb-strip deb-makeshlibs $(DEB_PHONY_RULES)