File: rules

package info (click to toggle)
python2.4 2.4.1-2sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 47,012 kB
  • ctags: 86,497
  • sloc: ansic: 304,593; python: 268,756; makefile: 3,843; perl: 3,736; lisp: 3,678; sh: 2,206; xml: 894; objc: 747; cpp: 7; sed: 2
file content (649 lines) | stat: -rwxr-xr-x 19,226 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
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.

export SHELL = /bin/bash

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

DEB_BUILD_ARCH		?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
DEB_BUILD_GNU_CPU	?= $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
DEB_BUILD_GNU_SYSTEM	?= $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)

export VER=2.4
export NVER=2.5
export PVER=python2.4
export PRIORITY=$(shell echo $(VER) | tr -d '.')0

PREVVER	:= $(shell awk '/^python/ && NR > 1 {print substr($$2,2,length($$2)-2); exit}' debian/changelog)

# default versions are built from the python-defaults source package
# keep the definition to adjust package priorities.
DEFAULT_VERSION = no
STATIC_PYTHON=yes

# set this (in the environment), when regenerating the docs. requires
# latex2html as a build dependency.
USE_L2H ?= no

PY_INTERPRETER = /usr/bin/python$(VER)

ifeq ($(DEFAULT_VERSION),yes)
  PY_PRIO = standard
  #PYSTDDEP = , python (>= $(VER))
else
  PY_PRIO = optional
endif

CC = gcc

# on alpha, use -O2 only, use -mieee
ifeq ($(DEB_BUILD_GNU_CPU),alpha)
    OPTSETTINGS = OPT="-DNDEBUG -g -O2 -mieee -Wall -Wstrict-prototypes"
endif
#OPTSETTINGS = OPT="-DNDEBUG -g -O0 -Wall -Wstrict-prototypes"

PWD		:= $(shell pwd)
buildd_static	:= $(PWD)/build-static
buildd_shared	:= $(PWD)/build-shared
buildd_debug	:= $(PWD)/build-debug

d		:= debian/tmp
scriptdir	=  usr/share/lib/python$(VER)
scriptdir	=  usr/share/python$(VER)
scriptdir	=  usr/lib/python$(VER)

# package names and directories
p_base	:= $(PVER)
p_tk	:= $(PVER)-tk
p_gdbm	:= $(PVER)-gdbm
p_dev	:= $(PVER)-dev
p_exam	:= $(PVER)-examples
#p_xml	:= $(PVER)-xmlbase
p_idle	:= idle-$(PVER)
p_doc	:= $(PVER)-doc
p_dbg	:= $(PVER)-dbg

d_base	:= debian/$(p_base)
d_tk	:= debian/$(p_tk)
d_gdbm	:= debian/$(p_gdbm)
d_dev	:= debian/$(p_dev)
d_exam	:= debian/$(p_exam)
#d_xml	:= debian/$(p_xml)
d_idle	:= debian/$(p_idle)
d_doc	:= debian/$(p_doc)
d_dbg	:= debian/$(p_dbg)

build: stamp-build
stamp-build: stamp-build-static stamp-build-shared stamp-build-debug stamp-check
	touch stamp-build

stamp-build-static: stamp-configure-static
	dh_testdir
	$(MAKE) -C $(buildd_static)
	touch stamp-build-static

stamp-build-shared: stamp-configure-shared
	dh_testdir
	$(MAKE) -C $(buildd_shared)
#	: # build the shared library
#	$(MAKE) -C $(buildd_shared) \
#		libpython$(VER).so
	: # build a static library with PIC objects
	$(MAKE) -C $(buildd_shared) \
		LIBRARY=libpython$(VER)-pic.a libpython$(VER)-pic.a
	touch stamp-build-shared

stamp-build-debug: stamp-configure-debug
	dh_testdir
	$(MAKE) -C $(buildd_debug)
	touch stamp-build-debug

common_configure_args = \
		--prefix=/usr \
		--with-fpectl \
		--enable-ipv6 \
		--enable-unicode=ucs4 \
		--without-cxx

stamp-configure-shared: patch-stamp
	mkdir -p $(buildd_shared)
	cd $(buildd_shared) && \
	  CC="$(CC)" $(OPTSETTINGS) \
	    ../configure \
		--enable-shared \
		$(common_configure_args)

	touch stamp-configure-shared

stamp-configure-static: patch-stamp
	mkdir -p $(buildd_static)
	cd $(buildd_static) && \
	  CC="$(CC)" $(OPTSETTINGS) \
	    ../configure \
		$(common_configure_args)

	: # apply workaround for missing os.fsync
	sed 's/HAVE_SYNC/HAVE_FSYNC/g' $(buildd_static)/pyconfig.h \
		> $(buildd_static)/pyconfig.h.new
	touch -r $(buildd_static)/pyconfig.h $(buildd_static)/pyconfig.h.new
	mv -f $(buildd_static)/pyconfig.h.new $(buildd_static)/pyconfig.h

	touch stamp-configure-static

stamp-configure-debug: patch-stamp
	mkdir -p $(buildd_debug)
	cd $(buildd_debug) && \
	  CC="$(CC)" \
	  OPT='-g -Wall -Wstrict-prototypes -DPy_USING_MEMORY_DEBUGGER' \
	    ../configure \
		$(common_configure_args) \
		--with-pydebug

	: # apply workaround for missing os.fsync
	sed 's/HAVE_SYNC/HAVE_FSYNC/g' $(buildd_debug)/pyconfig.h \
		> $(buildd_debug)/pyconfig.h.new
	touch -r $(buildd_debug)/pyconfig.h $(buildd_debug)/pyconfig.h.new
	mv -f $(buildd_debug)/pyconfig.h.new $(buildd_debug)/pyconfig.h

	touch stamp-configure-debug

TESTOPTS = -l -unetwork,bsddb -x test_tcl
TESTOPTS = -x test_tcl
stamp-check:
ifeq ($(WITHOUT_CHECK),yes)
	echo "check run disabled for this build" > $(buildd_static)/test_results
else
	@echo "BEGIN test static"
	-time \
	  $(MAKE) -C $(buildd_static) test \
	    TESTOPTS="$(TESTOPTS)" 2>&1 \
	    | tee $(buildd_static)/test_results
	@echo "END test static"
	@echo "BEGIN test shared"
	-time \
	  $(MAKE) -C $(buildd_shared) test \
	    TESTOPTS="$(TESTOPTS)" 2>&1 \
	    | tee $(buildd_shared)/test_results
	@echo "END test shared"
endif
	cp -p $(buildd_static)/test_results debian/

	@echo "BEGIN pystone static"
	cd $(buildd_static) && ./python ../Lib/test/pystone.py
	cd $(buildd_static) && ./python ../Lib/test/pystone.py
	@echo "END pystone static"
	@echo "BEGIN pystone shared"
	cd $(buildd_shared) \
		&& LD_LIBRARY_PATH=. ./python ../Lib/test/pystone.py
	cd $(buildd_shared) \
		&& LD_LIBRARY_PATH=. ./python ../Lib/test/pystone.py
	@echo "END pystone shared"
	touch stamp-check

stamp-doc-html:
	dh_testdir
	LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}$(buildd_static) \
	    $(MAKE) -C Doc tarhtml \
		PYTHON=$(buildd_static)/python \
		MKHOWTO='TEXINPUTS=$$(TEXINPUTS) $$(PYTHON) $$(PWD)/tools/mkhowto'
	touch stamp-doc-html

stamp-doc-info:
	dh_testdir
	patch -p0 < debian/patches/libre.diff
	$(MAKE) -C Doc/info VERSION=$(VER)
	patch -R -p0 < debian/patches/libre.diff
	touch stamp-doc-info

ifeq ($(USE_L2H),yes)
stamp-doc: stamp-doc-html stamp-doc-info update-doc
#stamp-doc: stamp-doc-html update-doc
	touch stamp-doc
else
stamp-doc: stamp-unpack-doc
	touch stamp-doc
endif

update-doc:
	: # copy just build docs to debian/patches
	tar cfj - Doc/html-*.tar Doc/info/*.info* \
	    | uuencode -m docs.tar.bz2 > debian/patches/docs.uue
#	tar cfj - Doc/html-*.tar \
#	    | uuencode -m docs.tar.bz2 > debian/patches/docs.uue

stamp-unpack-doc:
	uudecode debian/patches/docs.uue
	tar xfj docs.tar.bz2
	rm -f docs.tar.bz2
	touch stamp-unpack-doc

control-file:
	sed -e "s/@PVER@/$(PVER)/g" \
	    -e "s/@VER@/$(VER)/g" \
	    -e "s/@PYSTDDEP@/$(PYSTDDEP)/g" \
	    -e "s/@GCCDEP@/$(GCCDEP)/g" \
	    -e "s/@GCCBDEP@/$(GCCBDEP)/g" \
	    -e "s/@PRIO@/$(PY_PRIO)/g" \
		debian/control.in > debian/control.tmp
	[ -e debian/control ] \
	  && cmp -s debian/control debian/control.tmp \
	  && rm -f debian/control.tmp && exit 0; \
	  mv debian/control.tmp debian/control



clean: control-file
	dh_testdir
	dh_testroot
	$(MAKE) -f debian/rules unpatch
	rm -f stamp-*
	rm -f patch-stamp* pxxx
	rm -f debian/test_results

	-$(MAKE) -C Doc PYTHON=$(buildd_static)/python realclean
	-$(MAKE) -C Doc/info clobber
	rm -f Doc/html-*.t??
	rm -f Doc/commontex/patchlevel.tex
	-$(MAKE) -f Makefile.pre.in srcdir=. distclean
	rm -rf Lib/test/db_home
	rm -rf $(buildd_static) $(buildd_shared) $(buildd_debug)
	-find -name '*.py[co]' | xargs -n 50 rm -f

	for f in debian/*.in; do \
	    f2=`echo $$f | sed "s,PVER,$(PVER),g;s/@VER@/$(VER)/g;s,\.in$$,,"`; \
	    if [ $$f2 != debian/control ]; then \
	        rm -f $$f2; \
	    fi; \
	done

	dh_clean

stamp-control:
	: # We have to prepare the various control files

	for f in debian/*.in; do \
	    f2=`echo $$f | sed "s,PVER,$(PVER),g;s/@VER@/$(VER)/g;s,\.in$$,,"`; \
	    if [ $$f2 != debian/control ]; then \
		sed -e "s/@PVER@/$(PVER)/g;s/@VER@/$(VER)/g" \
		    -e "s/@PRIORITY@/$(PRIORITY)/g" \
		    -e "s,@SCRIPTDIR@,/$(scriptdir),g" \
		  <$$f >$$f2; \
	    fi; \
	done

install: build stamp-install
stamp-install: stamp-build control-file stamp-control
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	: # make install into tmp and subsequently move the files into
	: # their packages' directories.
	install -d $(d)/usr
	$(MAKE) -C $(buildd_static) install \
		prefix=$(PWD)/$(d)/usr

	: # remove files, which are not packaged
	rm -f $(d)/usr/bin/smtpd.py

	: # move manpages to new names
	mkdir -p $(d)/usr/share/man/man1
	mv $(d)/usr/man/man1/python.1 \
		$(d)/usr/share/man/man1/python$(VER).1
	cp -p debian/pydoc.1 $(d)/usr/share/man/man1/pydoc$(VER).1

	: # Symlinks to /usr/bin for some tools
	ln -sf ../lib/python$(VER)/pdb.py $(d)/usr/bin/pdb$(VER)
	cp -p debian/pdb.1 $(d)/usr/share/man/man1/pdb$(VER).1

	: # install the shared library
	cp -p $(buildd_shared)/libpython$(VER).so.1.0 $(d)/usr/lib/
	ln -sf libpython$(VER).so.1.0 $(d)/usr/lib/libpython$(VER).so.1
	ln -sf libpython$(VER).so.1 $(d)/usr/lib/libpython$(VER).so
	ln -sf ../../libpython$(VER).so \
		$(d)/usr/lib/python$(VER)/config/libpython$(VER).so

	mv $(d)/usr/bin/pydoc $(d)/usr/bin/pydoc$(VER)
	cp -p Tools/i18n/pygettext.py $(d)/usr/bin/pygettext$(VER)
	cp -p debian/pygettext.1 $(d)/usr/share/man/man1/pygettext$(VER).1

	: # install the Makefile of the shared python build
	sed -e 's,^CXX *=,CXX=		g++ -pthread,' \
	    -e 's,^RUNSHARED *=.*,RUNSHARED=,' \
		build-shared/Makefile > $(d)/$(scriptdir)/config/Makefile

	: # Move the static library and the header files into $(p_dev).
#	mv $(d)/usr/share/include/python$(VER)/* $(d)/usr/include/python$(VER)/.
#	rm -rf $(d)/usr/share/include
	dh_installdirs -p$(p_dev) \
		$(scriptdir) \
		$(scriptdir)/doc \
		usr/include \
		usr/lib
	dh_movefiles -p$(p_dev) --sourcedir=$(d) \
		usr/lib/python$(VER)/config \
		usr/include/python$(VER) \
		usr/lib/libpython$(VER).so
	cp -p $(buildd_shared)/libpython$(VER)-pic.a \
		$(d_dev)/usr/lib/python$(VER)/config/

	: # copy the templates, scripts and tools from the Doc subdir
	cp -a Doc/{commontex,perl,templates,texinputs,tools} \
		$(d_dev)/usr/lib/python$(VER)/doc/.
	mkdir $(d_dev)/usr/lib/python$(VER)/doc/api
	cp -a Doc/api/refcounts.dat $(d_dev)/usr/lib/python$(VER)/doc/api/.

	: # Move the Tkinter files into $(p_tk).
	dh_installdirs -p$(p_tk) \
		$(scriptdir) \
		usr/lib/python$(VER)/lib-dynload
	dh_movefiles -p$(p_tk) --sourcedir=$(d) \
		$(scriptdir)/lib-tk \
		usr/lib/python$(VER)/lib-dynload/_tkinter.so

	: # gdbm and dbm modules into $(p_gdbm).
	dh_installdirs -p$(p_gdbm) \
		usr/lib/python$(VER)/lib-dynload
	dh_movefiles -p$(p_gdbm) --sourcedir=$(d) \
		usr/lib/python$(VER)/lib-dynload/gdbm.so

#	: # xml module into $(p_xml).
#	dh_installdirs -p$(p_xml) \
#		$(scriptdir) \
#		usr/lib/python$(VER)/lib-dynload
#	dh_movefiles -p$(p_xml) --sourcedir=$(d) \
#		usr/lib/python$(VER)/lib-dynload/pyexpat.so \
#		$(scriptdir)/xml

#	: # The test framework into $(p_base), regression tests dropped
	dh_movefiles -p$(p_base) --sourcedir=$(d) \
		$(scriptdir)/test/{regrtest.py,test_support.py,__init__.py,README,pystone.py}
	rm -rf $(d)/$(scriptdir)/test
	rm -rf $(d)/$(scriptdir)/email/test
	rm -rf $(d)/$(scriptdir)/bsddb/test

	: # IDLE
	mv $(d)/usr/bin/idle $(d)/usr/bin/idle-python$(VER)
	rm -f $(d)/usr/lib/python$(VER)/idlelib/idle.bat
	dh_installdirs -p$(p_idle) \
		usr/bin \
		usr/share/man/man1
	dh_movefiles -p$(p_idle) \
		usr/bin/idle-python$(VER) \
		usr/lib/python$(VER)/idlelib
	cp -p debian/idle-$(PVER).1 $(d_idle)/usr/share/man/man1/

	: # Move the demos and tools into $(p_exam)'s doc directory
	dh_installdirs -p$(p_exam) \
		usr/share/doc/python$(VER)/examples

	cp -rp Demo Tools $(d_exam)/usr/share/doc/python$(VER)/examples/
	rm -rf $(d_exam)/usr/share/doc/python$(VER)/examples/Demo/sgi
	: # IDLE is in its own package:
	rm -rf $(d_exam)/usr/share/doc/python$(VER)/examples/Tools/idle
	: # XXX: We don't need rgb.txt, we'll use our own:
	rm -rf $(d_exam)/usr/share/doc/python$(VER)/examples/Tools/pynche/X

	: # XXX: Some files in upstream Demo and Tools have strange
	: # exec permissions, make lintian glad:
	chmod 644 $(d_tk)/$(scriptdir)/lib-tk/Tix.py

	cd $(d_exam)/usr/share/doc/python$(VER)/examples && chmod 644 \
	  Demo/{classes/*.py*,comparisons/patterns} \
	  Demo/{rpc/test,threads/*.py*,md5test/*} \
	  Demo/pdist/{client.py,cmdfw.py,cmptree.py,cvslib.py,cvslock.py,FSProxy.py,mac.py,rcsclient.py,rcslib.py,security.py,server.py,sumtree.py} \
	  Demo/scripts/{morse.py,newslist.doc,wh.py} \
	  Demo/sockets/{broadcast.py,ftp.py,mcast.py,radio.py} \
	  Demo/tix/{bitmaps/{tix.gif,*x[pb]m*},samples/*.py} \
	  Demo/tkinter/guido/{AttrDialog.py,hanoi.py,hello.py,imagedraw.py,imageview.py,listtree.py,ManPage.py,ShellWindow.py,wish.py} \
	  Tools/scripts/pydocgui.pyw \
	  Tools/{scripts/mailerdaemon.py,modulator/genmodule.py}

	: # Replace all '#!' calls to python with $(PY_INTERPRETER)
	: # and make them executable
	for i in `find debian -mindepth 3 -type f`; do \
	  sed '1s,#!.*python[^ ]*\(.*\),#! $(PY_INTERPRETER)\1,' \
		$$i > $$i.temp; \
	  if cmp --quiet $$i $$i.temp; then \
	    rm -f $$i.temp; \
	  else \
	    mv -f $$i.temp $$i; \
	    chmod 755 $$i; \
	    echo "fixed interpreter: $$i"; \
	  fi; \
	done

	: # Move the docs into $(p_base)'s /usr/share/doc/$(PVER) directory,
	: # all other packages only have a copyright file.
	dh_installdocs -p$(p_base) \
		README Misc/NEWS Misc/ACKS Misc/HISTORY \
		Misc/README.valgrind \
		Misc/gdbinit \
		debian/sample.postinst debian/sample.prerm \
		debian/README.maintainers \
		debian/test_results
	dh_installdocs --all -N$(p_base) -N$(p_dbg) debian/README.Debian

	: # IDLE has its own changelogs, docs...
	dh_installchangelogs -p$(p_idle) Lib/idlelib/ChangeLog
	dh_installdocs -p$(p_idle) Lib/idlelib/{NEWS,README,TODO,extend}.txt

	: # those packages have own README.Debian's
	install -m 644 -p debian/README.$(p_base) \
		$(d_base)/usr/share/doc/$(PVER)/README.Debian
	install -m 644 -p debian/README.$(p_idle) \
		$(d_idle)/usr/share/doc/$(p_idle)/README.Debian
	cp -p debian/README.Tk $(d_tk)/usr/share/doc/$(p_tk)/

	: # The rest goes into $(p_base)
	mkdir -p $(d)/usr/lib/python$(VER)/site-packages
	(cd $(d) && tar cf - .) | (cd $(d_base) && tar xpf -)
	sh debian/dh_rmemptydirs -p$(p_base)
	rm -f $(d_base)/usr/bin/python

	: # Mark site.py as config file
	dh_installdirs -p$(p_base) etc/$(PVER) usr/share/pixmaps

	: # Install menu icon
	cp -p debian/python16.xpm $(d_base)/usr/share/pixmaps/$(PVER)-16.xpm
	cp -p debian/python32.xpm $(d_base)/usr/share/pixmaps/$(PVER)-32.xpm

	mv $(d_base)/$(scriptdir)/site.py $(d_base)/etc/$(PVER)/
	dh_link -p$(p_base) /etc/$(PVER)/site.py /$(scriptdir)/site.py

	: # generate binfmt file
	mkdir -p $(d_base)/usr/share/binfmts
	$(buildd_static)/python debian/mkbinfmt.py $(PVER) \
		> $(d_base)/usr/share/binfmts/$(PVER)

	: # remove some things
	-find debian -name CVS | xargs rm -rf
	-find debian -name .cvsignore | xargs rm -f
	-find debian -name '*.py[co]' | xargs rm -f

	: # remove empty directories, when all components are in place
	for d in `find debian -depth -type d -empty 2> /dev/null`; do \
	    while rmdir $$d 2> /dev/null; do d=`dirname $$d`; done; \
	done

	: # install debug package
	dh_installdocs -p$(p_dbg)
	dh_installdirs -p$(p_dbg) \
		usr/bin \
		usr/share/man/man1 \
		$(scriptdir)/lib-dynload/debug \
		$(scriptdir)/site-packages/debug
	cp -p $(buildd_debug)/python $(d_dbg)/usr/bin/$(PVER)-dbg
	cp -p $(buildd_debug)/build/lib*/*.so \
		$(d_dbg)/$(scriptdir)/lib-dynload/debug/
	ln -sf $(PVER).1.gz $(d_dbg)/usr/share/man/man1/$(PVER)-dbg.1.gz

	touch stamp-install


# Build architecture-independent files here.
binary-indep: build install stamp-doc
	dh_testdir -i
	dh_testroot -i

	: # $(p_doc) package
	dh_installdirs -p$(p_doc) \
		usr/share/doc/$(p_base)/html \
		usr/share/doc/$(p_doc) \
		usr/share/info
	cat Doc/html*.tar \
		| (cd $(d_doc)/usr/share/doc/$(p_base)/html; tar xf -)
	-find $(d_doc)/usr/share/doc/$(p_base)/html ! -type d ! -perm 644
	-find $(d_doc)/usr/share/doc/$(p_base)/html ! -type d ! -perm 644 \
		| xargs chmod 644
	mv $(d_doc)/usr/share/doc/$(p_base)/html/Python-Docs*/* \
		$(d_doc)/usr/share/doc/$(p_base)/html/.
	rmdir $(d_doc)/usr/share/doc/$(p_base)/html/Python-Docs*

	cp -p Doc/info/*info* \
		$(d_doc)/usr/share/info/
	dh_link -p$(p_doc) \
		/usr/share/doc/$(p_base)/html /usr/share/doc/$(p_doc)/html

	dh_installdebconf -i
	dh_installexamples -i
	dh_installmenu -i
	dh_installinfo -p$(p_doc) --noscripts \
		Doc/info/*info*
	dh_installchangelogs -i
	dh_link -i
	dh_compress -i -X.py -X.cls -X.css -X.txt -Xgdbinit
	dh_fixperms -i

	: # make python scripts starting with '#!' executable
	for i in \
	  `find debian -mindepth 2 -type f ! -perm 755 ! -name 'sample.*'`; \
	do \
	  if head -1 $$i | grep -q '^#!'; then \
	    chmod 755 $$i; \
	    echo "make executable: $$i"; \
	  fi; \
	done
	-find $(d_doc) -name '*.txt' -perm 755 -exec chmod 644 {} \;

	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir -a
	dh_testroot -a
#	dh_installdebconf -a
	dh_installexamples -a
	dh_installmenu -a
#	dh_installmime -a
	dh_installinfo -a
	dh_installchangelogs -a
	dh_strip -a -Xdebug -Xdbg \
		--dbg-package=$(p_base) \
		--dbg-package=$(p_tk) \
		--dbg-package=$(p_gdbm)
	for d in $(d_tk) $(d_gdbm); do \
	  tar -c -C $$d-dbg -f - usr/lib/debug | tar -x -C $(d_base)-dbg -v -f -; \
	  rm -rf $$d-dbg; \
	done
	dh_link -a
	dh_compress -a -X.py
	dh_fixperms -a

	: # make python scripts starting with '#!' executable
	for i in \
	  `find debian -mindepth 2 -type f ! -perm 755 ! -name 'sample.*'`; \
	do \
	  if head -1 $$i | grep -q '^#!'; then \
	    chmod 755 $$i; \
	    echo "make executable: $$i"; \
	  fi; \
	done

#	dh_makeshlibs -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

# rules to patch the unpacked files in the source directory
# ---------------------------------------------------------------------------
# various rules to unpack addons and (un)apply patches.
# 	- patch / apply-patches
#	- unpatch / reverse-patches

patchdir	= debian/patches

# which patches should be applied?
debian_patches = \
	enable-fpectl \
	deb-setup \
	deb-locations \
	doc-faq \
	disable-utimes \
	pydebug-path \
	profile-doc \
	locales \
	locale-module \
	test-sundry \
	sf1541585 \

#	cvs-updates \
#	html-docs \
#	patchlevel \

ifeq ($(DEB_BUILD_GNU_SYSTEM),gnu)
  debian_patches += \
	no-large-file-support
endif

patch: patch-stamp
apply-patches: patch-stamp

patch-stamp: $(foreach p,$(debian_patches),patch-stamp-$(p))
	echo ""; echo "Patches applied in this version:" > pxxx
	for i in $(debian_patches); do \
	  echo "" >> pxxx; echo "$$i:" >> pxxx; \
	  sed -n 's/^# *DP: */  /p' $(patchdir)/$$i.dpatch >> pxxx; \
	done
	mv -f pxxx $@

reverse-patches: unpatch
unpatch:
	for stamp in none `ls -1t patch-stamp-* 2>/dev/null`; do \
	  case "$$stamp" in none|patched-stamp|patched-\*) continue; esac; \
	  patch=`echo $$stamp | sed -e 's,patch-stamp-,,'`; \
	  echo "trying to revert patch $$patch ..."; \
	  if [ -x $(patchdir)/$$patch.dpatch ]; then true; else \
	    chmod +x $(patchdir)/$$patch.dpatch; fi; \
	  if $(patchdir)/$$patch.dpatch -unpatch; then \
	    echo "reverted $$patch patch."; \
	    rm -f $$stamp; \
	  else \
	    echo "error in reverting $$patch patch."; \
	    exit 1; \
	  fi; \
	done
	rm -f patch-stamp

patch-stamp-%: $(patchdir)/%.dpatch
	if [ -x $< ]; then true; else chmod +x $<; fi
	if [ -f $@ ]; then \
	  echo "$* patches already applied."; exit 1; \
	fi
	$< -patch
	echo "$* patches applied." > $@

binary: binary-indep binary-arch

.PHONY: control-file configure build clean binary-indep binary-arch binary install

# Local Variables:
# mode: makefile
# end: