~pythoneers/ubuntu/lucid/python2.6/ltsppa

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
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.

unexport LANG LC_ALL LC_CTYPE LC_COLLATE LC_TIME LC_NUMERIC LC_MESSAGES

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_ARCH_OS	?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)

changelog_values := $(shell dpkg-parsechangelog \
			| awk '/^(Version|Source):/ {print $$2}')
PKGSOURCE  := $(word 1, $(changelog_values))
PKGVERSION := $(word 2, $(changelog_values))

on_buildd := $(shell [ -f /CurrentlyBuilding -o "$$LOGNAME" = buildd ] && echo yes)

ifneq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
  WITHOUT_CHECK := yes
endif
WITHOUT_BENCH :=
ifneq (,$(findstring nobench, $(DEB_BUILD_OPTIONS)))
  WITHOUT_BENCH := yes
endif
ifeq ($(on_buildd),yes)
  ifneq (,$(findstring $(DEB_BUILD_ARCH), hppa mips mipsel s390))
    WITHOUT_CHECK := yes
  endif
endif

COMMA = ,
ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
  NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
endif

distribution := $(shell lsb_release -is)
#distribution := Ubuntu

export VER=2.6
export NVER=2.7
export PVER=python2.6
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

MIN_MODS := $(shell awk '/^  / && $$2 == "module" { print $$1 }' \
		debian/PVER-minimal.README.Debian.in)
MIN_EXTS := $(shell awk '/^  / && $$2 == "extension" { print $$1 }' \
		debian/PVER-minimal.README.Debian.in)
MIN_BUILTINS := $(shell awk '/^  / && $$2 == "builtin" { print $$1 }' \
		debian/PVER-minimal.README.Debian.in)
MIN_ENCODINGS := $(foreach i, \
			$(filter-out \
			  big5% bz2% cp932.py cp949.py cp950.py euc_% \
			  gb% iso2022% johab.py shift_jis% , \
			  $(shell cd Lib/encodings && echo *.py)), \
			encodings/$(i)) \
		 codecs.py stringprep.py

with_tk := no
with_gdbm := no
with_interp := static
#with_interp := shared

build_target := build-all
install_target := install

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

ifeq ($(DEFAULT_VERSION),yes)
  PY_PRIO = standard
  #PYSTDDEP = , python (>= $(VER))
else
  PY_PRIO = optional
endif
ifeq ($(distribution),Ubuntu)
  PY_MINPRIO = required
else
  PY_MINPRIO = $(PY_PRIO)
endif
with_fpectl = yes

CC = gcc

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

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

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_min	:= $(PVER)-minimal
p_lib	:= lib$(PVER)
p_tk	:= $(PVER)-tk
p_gdbm	:= $(PVER)-gdbm
p_dev	:= $(PVER)-dev
p_exam	:= $(PVER)-examples
p_idle	:= idle-$(PVER)
p_doc	:= $(PVER)-doc
p_dbg	:= $(PVER)-dbg

d_base	:= debian/$(p_base)
d_min	:= debian/$(p_min)
d_lib	:= debian/$(p_lib)
d_tk	:= debian/$(p_tk)
d_gdbm	:= debian/$(p_gdbm)
d_dev	:= debian/$(p_dev)
d_exam	:= debian/$(p_exam)
d_idle	:= debian/$(p_idle)
d_doc	:= debian/$(p_doc)
d_dbg	:= debian/$(p_dbg)

# profiled build fails on amd64, lpia, sparc
ifneq (,$(filter $(DEB_BUILD_ARCH), amd64 armel i386 ia64 lpia mips mipsel powerpc s390 sparc sparc64 hurd-i386))
  make_build_target =
else
  make_build_target = profile-opt
endif

build: $(build_target)
build-all: stamp-build
stamp-build: stamp-build-static stamp-build-shared stamp-build-debug stamp-build-shared-debug stamp-mincheck stamp-check stamp-pystone stamp-pybench
	touch stamp-build

PROFILE_EXCLUDES = test_compiler test_distutils test_platform test_subprocess \
	test_pstats test_profile test_multiprocessing test_cprofile \
	test_thread test_threaded_import test_threadedtempfile \
	test_threading test_threading_local test_threadsignals \
	test_dbm_dumb test_dbm_ndbm test_pydoc test_sundry test_gdb \

ifneq (,$(filter $(DEB_BUILD_ARCH), arm armel))
  PROFILE_EXCLUDES += test_float
endif
PROFILE_EXCLUDES += test_zipfile
PROFILE_EXCLUDES += test_xmlrpc

PROFILE_TASK = ../Lib/test/regrtest.py \
	-x $(sort $(TEST_EXCLUDES) $(PROFILE_EXCLUDES))

stamp-build-static: stamp-configure-static
	dh_testdir
	$(MAKE) $(NJOBS) -C $(buildd_static) \
		PROFILE_TASK='$(PROFILE_TASK)' $(make_build_target)
	touch stamp-build-static

stamp-build-shared: stamp-configure-shared
	dh_testdir
	$(MAKE) $(NJOBS) -C $(buildd_shared)
#	: # build the shared library
#	$(MAKE) $(NJOBS) -C $(buildd_shared) \
#		libpython$(VER).so
	: # build a static library with PIC objects
	$(MAKE) $(NJOBS) -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) $(NJOBS) -C $(buildd_debug)
	touch stamp-build-debug

stamp-build-shared-debug: stamp-configure-shared-debug
	dh_testdir
	: # build the shared debug library
	$(MAKE) $(NJOBS) -C $(buildd_shdebug) \
		libpython$(VER)_d.so
	touch stamp-build-shared-debug

common_configure_args = \
		--prefix=/usr \
		--enable-ipv6 \
		--enable-unicode=ucs4

ifeq ($(DEB_BUILD_ARCH), avr32)
  common_configure_args += --without-ffi
else
  common_configure_args += --with-system-ffi
endif

ifeq ($(with_fpectl),yes)
  common_configure_args += \
		--with-fpectl
endif

stamp-configure-shared: patch-stamp
	rm -rf $(buildd_shared)
	mkdir -p $(buildd_shared)
	cd $(buildd_shared) && \
	  CC="$(CC)" $(OPTSETTINGS) \
	    ../configure \
		--enable-shared \
		$(common_configure_args)
	egrep \
	  "^#($$(awk '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in | tr '\012' '|')XX)" \
	    Modules/Setup.dist \
	  | sed -e 's/^#//' -e 's/-Wl,-Bdynamic//;s/-Wl,-Bstatic//' \
	    >> $(buildd_shared)/Modules/Setup.local
	cd $(buildd_shared) && \
	  ../Modules/makesetup -c ../Modules/config.c.in -s Modules \
	    Modules/Setup.config Modules/Setup.local Modules/Setup
	mv $(buildd_shared)/config.c $(buildd_shared)/Modules/

	touch stamp-configure-shared

stamp-configure-static: patch-stamp
	rm -rf $(buildd_static)
	mkdir -p $(buildd_static)
	cd $(buildd_static) && \
	  CC="$(CC)" $(OPTSETTINGS) \
	    ../configure \
		$(common_configure_args)
	egrep \
	  "^#($$(awk '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in | tr '\012' '|')XX)" \
	  Modules/Setup.dist | sed 's/^#//' \
	    >> $(buildd_static)/Modules/Setup.local
	cd $(buildd_static) && \
	  ../Modules/makesetup -c ../Modules/config.c.in -s Modules \
	    Modules/Setup.config Modules/Setup.local Modules/Setup

	: # 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
	mv $(buildd_static)/config.c $(buildd_static)/Modules/

	touch stamp-configure-static

stamp-configure-debug: patch-stamp
	rm -rf $(buildd_debug)
	mkdir -p $(buildd_debug)
	cd $(buildd_debug) && \
	  CC="$(CC)" $(OPTDEBUGSETTINGS) \
	    ../configure \
		$(common_configure_args) \
		--with-pydebug
	egrep \
	  "^#($$(awk '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in | tr '\012' '|')XX)" \
	  Modules/Setup.dist | sed 's/^#//' \
	    >> $(buildd_debug)/Modules/Setup.local
	cd $(buildd_debug) && \
	  ../Modules/makesetup -c ../Modules/config.c.in -s Modules \
	    Modules/Setup.config Modules/Setup.local Modules/Setup
	mv $(buildd_debug)/config.c $(buildd_debug)/Modules/

	: # 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

stamp-configure-shared-debug: patch-stamp
	rm -rf $(buildd_shdebug)
	mkdir -p $(buildd_shdebug)
	cd $(buildd_shdebug) && \
	  CC="$(CC)" $(OPTDEBUGSETTINGS) \
	    ../configure \
		$(common_configure_args) \
		--enable-shared \
		--with-pydebug
	egrep \
	  "^#($$(awk '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in | tr '\012' '|')XX)" \
	  Modules/Setup.dist \
	    | sed -e 's/^#//' -e 's/-Wl,-Bdynamic//;s/-Wl,-Bstatic//' \
	    >> $(buildd_shdebug)/Modules/Setup.local
	cd $(buildd_shdebug) && \
	  ../Modules/makesetup -c ../Modules/config.c.in -s Modules \
	    Modules/Setup.config Modules/Setup.local Modules/Setup
	mv $(buildd_shdebug)/config.c $(buildd_shdebug)/Modules/

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

	touch stamp-configure-shared-debug

stamp-mincheck: stamp-build-static debian/PVER-minimal.README.Debian.in
	for m in $(MIN_MODS) $(MIN_EXTS) $(MIN_BUILTINS); do \
	  echo "import $$m"; \
	done > $(buildd_static)/minmods.py
	cd $(buildd_static) && ./python ../debian/pymindeps.py minmods.py \
	  > $(buildd_static)/mindeps.txt
	if [ -x /usr/bin/dot ]; then \
	  python debian/depgraph.py < $(buildd_static)/mindeps.txt \
	    > $(buildd_static)/mindeps.dot; \
	  dot -Tpng -o $(buildd_static)/mindeps.png \
	    $(buildd_static)/mindeps.dot; \
	else true; fi
	cd $(buildd_static) && ./python ../debian/mincheck.py \
		minmods.py mindeps.txt
	touch stamp-mincheck

TEST_RESOURCES = all
ifeq ($(on_buildd),yes)
  TEST_RESOURCES := $(TEST_RESOURCES),-network,-urlfetch
endif
TESTOPTS = -w -l -u$(TEST_RESOURCES)
TEST_EXCLUDES =
# not built from this source
TEST_EXCLUDES += test_bsddb3
ifeq ($(on_buildd),yes)
  TEST_EXCLUDES += test_tcl test_codecmaps_cn test_codecmaps_hk \
        test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw \
        test_normalization test_ossaudiodev
endif
ifneq (,$(filter $(DEB_BUILD_ARCH), hppa))
  TEST_EXCLUDES += test_fork1 test_wait3
endif
ifneq (,$(filter $(DEB_BUILD_ARCH), arm avr))
  TEST_EXCLUDES += test_ctypes
endif
ifneq (,$(filter $(DEB_BUILD_ARCH), m68k avr ))
  TEST_EXCLUDES += test_bsddb3
endif
ifneq (,$(filter $(DEB_BUILD_ARCH), arm armel avr m68k))
  ifeq ($(on_buildd),yes)
    TEST_EXCLUDES += test_compiler
  endif
endif
ifneq (,$(filter $(DEB_BUILD_ARCH), hurd-i386))
  TEST_EXCLUDES += test_random test_signal test_ssl test_threading
endif
ifneq (,$(TEST_EXCLUDES))
  TESTOPTS += -x $(sort $(TEST_EXCLUDES))
endif

stamp-check:
ifeq ($(WITHOUT_CHECK),yes)
	echo "check run disabled for this build" > $(buildd_static)/test_results
else
	: # build locales needed by the testsuite
	rm -rf locales
	mkdir locales
	chmod +x debian/locale-gen
	debian/locale-gen

	@echo ========== test environment ============
	@env
	@echo ========================================

	@echo "BEGIN test static"
	-time \
	  LOCPATH=$(CURDIR)/locales \
	  $(MAKE) -C $(buildd_static) test \
	    TESTOPTS="$(TESTOPTS)" 2>&1 \
	    | tee $(buildd_static)/test_results
	@echo "END test static"
	@echo "BEGIN test shared"
	-time \
	  LOCPATH=$(CURDIR)/locales \
	  $(MAKE) -C $(buildd_shared) test \
	    TESTOPTS="$(TESTOPTS)" 2>&1 \
	    | tee $(buildd_shared)/test_results
	@echo "END test shared"
  ifeq (0,1)
  ifeq (,$(findstring $(DEB_BUILD_ARCH), alpha))
	@echo "BEGIN test debug"
	-time \
	  LOCPATH=$(CURDIR)/locales \
	  $(MAKE) -C $(buildd_debug) test \
	    TESTOPTS="$(TESTOPTS)" 2>&1 \
	    | tee $(buildd_debug)/test_results
	@echo "END test debug"
  endif
  endif
endif
	cp -p $(buildd_static)/test_results debian/
	touch stamp-check

stamp-pystone:
	@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=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. ./python ../Lib/test/pystone.py
	cd $(buildd_shared) \
		&& LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. ./python ../Lib/test/pystone.py
	@echo "END pystone shared"
	@echo "BEGIN pystone debug"
	cd $(buildd_debug) && ./python ../Lib/test/pystone.py
	cd $(buildd_debug) && ./python ../Lib/test/pystone.py
	@echo "END pystone debug"
	touch stamp-pystone

#ifeq (,$(filter $(DEB_BUILD_ARCH), arm armel avr hppa mips mipsel m68k))
  pybench_options = -C 2 -n 5 -w 4
#endif

stamp-pybench:
ifeq ($(WITHOUT_BENCH),yes)
	echo "pybench run disabled for this build" > $(buildd_static)/pybench.log
else
	@echo "BEGIN pybench static"
	cd $(buildd_static) \
	  && time ./python ../Tools/pybench/pybench.py -f run1.pybench $(pybench_options)
	cd $(buildd_static) \
	  && ./python ../Tools/pybench/pybench.py -f run2.pybench -c run1.pybench $(pybench_options)
	@echo "END pybench static"
	@echo "BEGIN pybench shared"
	cd $(buildd_shared) \
	  && LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. \
		./python ../Tools/pybench/pybench.py -f run1.pybench $(pybench_options)
	cd $(buildd_shared) \
	  && LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. \
		./python ../Tools/pybench/pybench.py -f run2.pybench -c run1.pybench $(pybench_options)
	@echo "END pybench shared"
	@echo "BEGIN shared/static comparision"
	$(buildd_static)/python Tools/pybench/pybench.py \
	  -s $(buildd_static)/run2.pybench -c $(buildd_shared)/run2.pybench \
	  | tee $(buildd_static)/pybench.log
	@echo "END shared/static comparision"
endif
	touch stamp-pybench

minimal-test:
	rm -rf mintest
	mkdir -p mintest/lib mintest/dynlib mintest/testlib mintest/all-lib
	cp -p $(buildd_static)/python mintest/
	cp -p $(foreach i,$(MIN_MODS),Lib/$(i).py) \
		mintest/lib/
#	cp -p $(foreach i,$(MIN_EXTS),$(buildd_static)/build/lib*/$(i).so) \
#		mintest/dynlib/
	cp -p Lib/unittest.py mintest/lib/
	cp -pr Lib/test mintest/lib/
	cp -pr Lib mintest/all-lib
	cp -p $(buildd_static)/build/lib*/*.so mintest/all-lib/
	( \
	  echo "import sys"; \
	  echo "sys.path = ["; \
	  echo "    '$(CURDIR)/mintest/lib',"; \
	  echo "    '$(CURDIR)/mintest/dynlib',"; \
	  echo "]"; \
	  cat Lib/test/regrtest.py; \
	) > mintest/lib/test/mintest.py
	cd mintest && ./python -E -S lib/test/mintest.py \
	     -x test_codecencodings_cn test_codecencodings_hk \
		test_codecencodings_jp test_codecencodings_kr \
		test_codecencodings_tw test_codecs test_multibytecodec \

stamp-doc-html:
	dh_testdir
	$(MAKE) -C Doc html
	touch stamp-doc-html

build-doc: patch-stamp stamp-build-doc
stamp-build-doc: stamp-doc-html
	touch stamp-build-doc

control-file:
	sed -e "s/@PVER@/$(PVER)/g" \
	    -e "s/@VER@/$(VER)/g" \
	    -e "s/@PYSTDDEP@/$(PYSTDDEP)/g" \
	    -e "s/@PRIO@/$(PY_PRIO)/g" \
	    -e "s/@MINPRIO@/$(PY_MINPRIO)/g" \
		debian/control.in > debian/control.tmp
ifeq ($(distribution),Ubuntu)
  ifneq (,$(findstring ubuntu, $(PKGVERSION)))
	m='Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>'; \
	sed -i "/^Maintainer:/s/\(.*\)/Maintainer: $$m\nXSBC-Original-\1/" \
	  debian/control.tmp
  endif
endif
	[ -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 clean
	sed 's/^@/#/' Makefile.pre.in | $(MAKE) -f - srcdir=. distclean
	rm -rf Lib/test/db_home
	rm -rf $(buildd_static) $(buildd_shared) $(buildd_debug) $(buildd_shdebug)
	find -name '*.py[co]' | xargs -r rm -f
	rm -f Lib/lib2to3/*.pickle
	rm -rf locales
	rm -rf $(d)-dbg

	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" \
		    -e "s,@INFO@,$(info_docs),g" \
		  <$$f >$$f2; \
	  fi; \
	done
ifneq (,$(filter $(DEB_BUILD_ARCH), alpha amd64 ia64 ppc64 sparc64 kfreebsd-amd64))
	sed -i 's/\(Py_InitModule4[^@]*\)@/\1_64@/' \
		debian/lib$(PVER).symbols debian/$(PVER)-dbg.symbols
endif

install: $(build_target) 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
ifeq ($(with_interp),static)
	$(MAKE) -C $(buildd_static) install prefix=$(CURDIR)/$(d)/usr
else
	$(MAKE) -C $(buildd_shared) install prefix=$(CURDIR)/$(d)/usr
endif
	-find $(d)/usr/lib/python$(VER) -name '*_failed*.so'
	find $(d)/usr/lib/python$(VER) -name '*_failed*.so' | xargs -r rm -f

	mv $(d)/usr/lib/python$(VER)/site-packages \
		$(d)/usr/lib/python$(VER)/dist-packages

	: # remove files, which are not packaged
	rm -f $(d)/usr/bin/smtpd.py
	rm -rf $(d)/usr/lib/python$(VER)/ctypes/macholib

	: # fix some file permissions
	chmod a-x $(d)/$(scriptdir)/{fractions,lib-tk/Tix}.py

	: # move manpages to new names
	if [ -d $(d)/usr/man/man1 ]; then \
	    mkdir -p $(d)/usr/share/man; \
	    mv $(d)/usr/man/man1/* $(d)/usr/share/man/man1/; \
	    rm -rf $(d)/usr/man/; \
	fi
	mv $(d)/usr/share/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

	: # versioned install only
	rm -f $(d)/usr/bin/python-config

	mv $(d)/usr/bin/2to3 $(d)/usr/bin/2to3-$(VER)

#	: # remove the bsddb stuff
#	rm -rf $(d)/$(scriptdir)/bsddb
#	rm -f $(d)/$(scriptdir)/lib-dynload/_bsddb.so

	: # Remove version information from the egg-info file
	mv $(d)/$(scriptdir)/lib-dynload/Python-2.6*.egg-info \
		$(d)/$(scriptdir)/lib-dynload/Python-$(VER).egg-info

	dh_installdirs -p$(p_lib) \
		$(scriptdir)/config \
		usr/share/doc
	: # install the shared library
	cp -p $(buildd_shared)/libpython$(VER).so.1.0 $(d_lib)/usr/lib/
	ln -sf libpython$(VER).so.1.0 $(d_lib)/usr/lib/libpython$(VER).so.1
	ln -sf ../../libpython$(VER).so.1 \
		$(d_lib)/$(scriptdir)/config/libpython$(VER).so
	ln -sf $(p_base) $(d_lib)/usr/share/doc/$(p_lib)

	ln -sf libpython$(VER).so.1 $(d)/usr/lib/libpython$(VER).so

ifeq ($(with_interp),shared)
	: # install the statically linked runtime
	install -m755 $(buildd_static)/python $(d)/usr/bin/python$(VER)-static
endif

	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 '/^OPT/s,-O3,-O2,' \
	    -e 's,^RUNSHARED *=.*,RUNSHARED=,' \
		build-shared/Makefile > $(d)/$(scriptdir)/config/Makefile

	: # Move the binary and the minimal libraries into $(p_min).
	dh_installdirs -p$(p_min) \
		etc/$(PVER) \
		usr/bin \
		usr/share/man/man1 \
		$(scriptdir)/lib-dynload
	DH_COMPAT=2 dh_movefiles -p$(p_min) --sourcedir=$(d) \
		usr/bin/python$(VER) \
		usr/share/man/man1/python$(VER).1 \
		$(foreach i,$(MIN_MODS),$(scriptdir)/$(i).py) \
		$(foreach i,$(MIN_ENCODINGS),$(scriptdir)/$(i)) \
		$(scriptdir)/site.py

#		$(foreach i,$(MIN_EXTS),$(scriptdir)/lib-dynload/$(i).so) \

	: # Install sitecustomize.py.
	cp -p debian/sitecustomize.py $(d_min)/etc/$(PVER)/
	patch --no-backup -d $(d_min)/$(scriptdir) < debian/patches/site-builddir.diff
	dh_link -p$(p_min) /etc/$(PVER)/sitecustomize.py \
		/$(scriptdir)/sitecustomize.py

	: # 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) \
		usr/share/doc/python$(VER) \
		$(scriptdir) \
		$(scriptdir)/doc/html \
		usr/include \
		usr/lib
	cp -p Misc/HISTORY Misc/README.valgrind Misc/gdbinit \
		debian/README.maintainers \
		debian/test_results $(buildd_static)/pybench.log \
	    $(d_dev)/usr/share/doc/python$(VER)/

	DH_COMPAT=2 dh_movefiles -p$(p_dev) --sourcedir=$(d) \
		usr/lib/python$(VER)/config \
		usr/include/python$(VER) \
		usr/lib/libpython$(VER).so \
		usr/lib/libpython$(VER).a \
		usr/bin/python$(VER)-config \
		usr/lib/python$(VER)/distutils/command/wininst-*.exe

	mv $(d_dev)/usr/lib/python$(VER)/config/Makefile \
		$(d)/usr/lib/python$(VER)/config/
	mv $(d_dev)/usr/include/python$(VER)/pyconfig.h \
		$(d)/usr/include/python$(VER)/
	cp -p $(buildd_shared)/libpython$(VER)-pic.a \
		$(d_dev)/usr/lib/python$(VER)/config/

ifeq ($(with_tk),yes)
	: # Move the Tkinter files into $(p_tk).
	dh_installdirs -p$(p_tk) \
		$(scriptdir) \
		usr/lib/python$(VER)/lib-dynload
	DH_COMPAT=2 dh_movefiles -p$(p_tk) --sourcedir=$(d) \
		usr/lib/python$(VER)/lib-dynload/_tkinter.so
endif

ifeq ($(with_gdbm),yes)
	: # gdbm and dbm modules into $(p_gdbm).
	dh_installdirs -p$(p_gdbm) \
		usr/lib/python$(VER)/lib-dynload
	DH_COMPAT=2 dh_movefiles -p$(p_gdbm) --sourcedir=$(d) \
		usr/lib/python$(VER)/lib-dynload/gdbm.so
endif

#	: # The test framework into $(p_base), regression tests dropped
	DH_COMPAT=2 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)/ctypes/test
	rm -rf $(d)/$(scriptdir)/bsddb/test
	rm -rf $(d)/$(scriptdir)/email/test
	rm -rf $(d)/$(scriptdir)/json/tests
	rm -rf $(d)/$(scriptdir)/sqlite3/test
	rm -rf $(d)/$(scriptdir)/distutils/tests
	rm -rf $(d)/$(scriptdir)/lib2to3/tests

	: # 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_COMPAT=2 dh_movefiles -p$(p_idle) \
		usr/lib/python$(VER)/idlelib \
		usr/bin/idle-python$(VER)
	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
	-chmod 644 $(d)/$(scriptdir)/runpy.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 ! -name '*.dpatch'`; 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
	ln -sf NEWS.gz $(d_base)/usr/share/doc/$(p_base)/changelog.gz
	dh_installdocs --all -N$(p_base) -N$(p_dev) -N$(p_dbg) -N$(p_lib) 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

	mkdir -p $(d_idle)/usr/share/applications
	cp -p debian/idle.desktop \
		$(d_idle)/usr/share/applications/idle-$(PVER).desktop

	: # 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
ifeq ($(with_tk),yes)
	cp -p debian/README.Tk $(d_tk)/usr/share/doc/$(p_tk)/
endif

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

	: # Install menu icon
	dh_installdirs -p$(p_base) usr/share/pixmaps
	cp -p debian/pylogo.xpm $(d_base)/usr/share/pixmaps/$(PVER).xpm

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

	: # desktop entry
	mkdir -p $(d_base)/usr/share/applications
	cp -p debian/$(PVER).desktop \
		$(d_base)/usr/share/applications/$(PVER).desktop

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

	: # remove empty directories, when all components are in place
	-find debian ! -name lib-dynload -type d -empty -delete

	: # install debug package
	rm -rf $(d)-dbg
	$(MAKE) -C $(buildd_debug) install DESTDIR=$(CURDIR)/$(d)-dbg
	dh_installdirs -p$(p_dbg) \
		usr/bin \
		usr/share/man/man1 \
		$(scriptdir)/lib-dynload \
		usr/include/$(PVER)_d \
		usr/share/doc/$(p_base)
	cp -p Misc/SpecialBuilds.txt $(d_dbg)/usr/share/doc/$(p_base)/
	cp -p debian/$(PVER)-dbg.README.Debian \
		$(d_dbg)/usr/share/doc/$(p_base)/README.debug
	cp -p $(buildd_debug)/python $(d_dbg)/usr/bin/$(PVER)-dbg
	sed '1s,#!.*python[^ ]*\(.*\),#! $(PY_INTERPRETER)-dbg\1,' \
		$(d)-dbg/usr/bin/$(PVER)-config \
		> $(d_dbg)/usr/bin/$(PVER)-dbg-config
	chmod 755 $(d_dbg)/usr/bin/$(PVER)-dbg-config
	cp -p $(buildd_debug)/build/lib*/*_d.so \
		$(d_dbg)/$(scriptdir)/lib-dynload/
	cp -p $(buildd_shdebug)/libpython$(VER)_d.so.1.0 $(d_dbg)/usr/lib/
	ln -sf libpython$(VER)_d.so.1.0 $(d_dbg)/usr/lib/libpython$(VER)_d.so.1
	ln -sf libpython$(VER)_d.so.1 $(d_dbg)/usr/lib/libpython$(VER)_d.so
ifneq ($(with_gdbm),yes)
	rm -f $(d_dbg)/$(scriptdir)/lib-dynload/gdbm_d.so
	rm -f $(d_dbg)/usr/lib/debug/$(scriptdir)/lib-dynload/gdbm.so
endif
ifneq ($(with_tk),yes)
	rm -f $(d_dbg)/$(scriptdir)/lib-dynload/_tkinter_d.so
	rm -f $(d_dbg)/usr/lib/debug/$(scriptdir)/lib-dynload/_tkinter.so
endif
#	rm -f $(d_dbg)/$(scriptdir)/lib-dynload/_bsddb_d.so

	cp -a $(d)-dbg/$(scriptdir)/config_d $(d_dbg)/$(scriptdir)/
	ln -sf ../../libpython$(VER)_d.so \
		$(d_dbg)/$(scriptdir)/config_d/libpython$(VER)_d.so
	ln -sf libpython$(VER)_d.so \
		$(d_dbg)/$(scriptdir)/config_d/libpython$(VER).so
	ln -sf libpython$(VER)_d.a \
		$(d_dbg)/$(scriptdir)/config_d/libpython$(VER).a

	for i in $(d_dev)/usr/include/$(PVER)/*; do \
	  i=$$(basename $$i); \
	  case $$i in pyconfig.h) continue; esac; \
	  ln -sf ../$(PVER)/$$i $(d_dbg)/usr/include/$(PVER)_d/$$i; \
	done
	cp -p $(buildd_debug)/pyconfig.h $(d_dbg)/usr/include/$(PVER)_d/
	ln -sf $(PVER).1.gz $(d_dbg)/usr/share/man/man1/$(PVER)-dbg.1.gz

	for i in debian/*.overrides; do \
	  b=$$(basename $$i .overrides); \
	  install -D -m 644 $$i debian/$$b/usr/share/lintian/overrides/$$b; \
	done

	touch stamp-install

# Build architecture-independent files here.
binary-indep: $(install_target) $(build_target) stamp-build-doc stamp-control
	dh_testdir -i
	dh_testroot -i

	: # $(p_doc) package
	dh_installdirs -p$(p_doc) \
		usr/share/doc/$(p_base) \
		usr/share/doc/$(p_doc)
	dh_installdocs -p$(p_doc)
	cp -a Doc/build/html $(d_doc)/usr/share/doc/$(p_base)/
	rm -f $(d_doc)/usr/share/doc/$(p_base)/html/_static/jquery.js
	dh_link -p$(p_doc) \
		/usr/share/doc/$(p_base)/html /usr/share/doc/$(p_doc)/html \
		/usr/share/javascript/jquery/jquery.js /usr/share/doc/$(p_base)/html/_static/jquery.js

	: # devhelp docs
	python debian/pyhtml2devhelp.py \
		$(d_doc)/usr/share/doc/$(p_base)/html index.html \
		> $(d_doc)/usr/share/doc/$(p_base)/html/$(PVER).devhelp
	gzip -9v $(d_doc)/usr/share/doc/$(p_base)/html/$(PVER).devhelp
	dh_link -p$(p_doc) \
		/usr/share/doc/$(p_base)/html /usr/share/devhelp/books/$(PVER)

	dh_installdebconf -i $(dh_args)
	dh_installexamples -i $(dh_args)
	dh_installmenu -i $(dh_args)
	-dh_icons -i $(dh_args) || dh_iconcache -i $(dh_args)
	dh_installchangelogs -i $(dh_args)
	dh_link -i $(dh_args)
	dh_compress -i $(dh_args) -X.py -X.cls -X.css -X.txt -X.json -X.js -Xobjects.inv -Xgdbinit
	dh_fixperms -i $(dh_args)

	: # make python scripts starting with '#!' executable
	for i in `find debian -mindepth 3 -type f ! -name '*.dpatch' ! -perm 755`; 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_args)
	dh_gencontrol -i $(dh_args)
	dh_md5sums -i $(dh_args)
	dh_builddeb -i $(dh_args)

# 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_icons -a || dh_iconcache -a
#	dh_installmime -a
	dh_installchangelogs -a
	for i in $(p_dev) $(p_dbg) $(p_lib); do \
	  rm -rf debian/$$i/usr/share/doc/$$i; \
	  ln -s $(p_base) debian/$$i/usr/share/doc/$$i; \
	done
	-find debian ! -perm -200 -print -exec chmod +w {} \;
ifneq ($(with_tk),yes)
	rm -f $(d_base)/$(scriptdir)/lib-dynload/_tkinter.so
endif
ifneq ($(with_gdbm),yes)
	rm -f $(d_base)/$(scriptdir)/lib-dynload/gdbm.so
endif
	dh_strip -a -N$(p_dbg) -Xdebug -Xdbg --dbg-package=$(p_dbg)
	cp Tools/gdb/libpython.py $(d_dbg)/usr/lib/debug/usr/bin/$(PVER)-gdb.py
	ln -sf $(PVER)-gdb.py $(d_dbg)/usr/lib/debug/usr/bin/$(PVER)-dbg-gdb.py
	ln -sf ../bin/$(PVER)-gdb.py \
		$(d_dbg)/usr/lib/debug/usr/lib/lib$(PVER).so.1.0-gdb.py
	ln -sf ../bin/$(PVER)-gdb.py \
		$(d_dbg)/usr/lib/lib$(PVER)_d.so.1.0-gdb.py
	dh_link -a
	dh_compress -a -X.py
	dh_fixperms -a

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

	dh_makeshlibs -p$(p_lib) -V '$(p_lib)'
	dh_makeshlibs -p$(p_dbg) -V '$(p_dbg)'
# don't include the following symbols, found in extensions
# which either can be built as builtin or extension.
	sed -ri '/^ (_check_|asdl_|fast_save_|init)/d' \
	  $(d_lib)/DEBIAN/symbols $(d_dbg)/DEBIAN/symbols
	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 = \
	deb-setup \
	deb-locations \
	site-locations \
	distutils-install-layout \
	locale-module \
	distutils-link \
	distutils-sysconfig \
	test-sundry \
	tkinter-import \
	link-opt \
	debug-build \
	hotshot-import \
	profile-doc \
	webbrowser \
	linecache \
	doc-nodownload \
	profiled-build2 \
	no-zip-on-sys.path \
	platform-lsbrelease \
	issue1113244 \
	bdist-wininst-notfound \
	setup-modules-ssl \
	makesetup-bashism \
	hurd-broken-poll \
	hurd-disable-nonworking-constants \
	issue8140 \
	bsddb-version \
	issue4961 \
	issue8154 \
	issue8032 \
	issue8310 \
	issue8329 \

#	setup-modules \
#	profiled-build \
#	subprocess-eintr-safety \
#	pydebug-path \
#	svn-updates \
#	db4.6 \

ifeq ($(with_fpectl),yes)
  debian_patches += \
	enable-fpectl
endif

ifeq ($(DEB_BUILD_ARCH),arm)
  debian_patches += arm-float
endif

#	svn-updates \
#	patchlevel \

glibc_version := $(shell dpkg -s locales | awk '/^Version:/ {print $$2}')
broken_utimes := $(shell dpkg --compare-versions $(glibc_version) lt 2.3.5 && echo yes || echo no)
ifeq ($(broken_utimes),yes)
  debian_patches += \
	disable-utimes
endif

ifeq ($(distribution),Ubuntu)
  debian_patches += \
	langpack-gettext
endif

ifeq ($(DEB_BUILD_ARCH_OS),hurd)
  debian_patches += \
	no-large-file-support \
	cthreads
endif

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

patch-stampx:
	dh_testdir
	QUILT_PATCHES=debian/patches quilt push -a || test $$? = 2
	touch 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
	rm -rf autom4te.cache configure
	autoconf
	mv -f pxxx $@

reverse-patches: unpatch
unpatchx:
	QUILT_PATCHES=debian/patches quilt pop -a -R || test $$? = 2
	rm -f patch-stamp

unpatch:
	for patch in $(debian_patches); do \
	  [ -f patch-stamp-$$patch ] && patches="$$patch $$patches"; \
	done; \
	for patch in $$patches; do \
	  echo "trying to revert patch $$patch ..."; \
	  if sh -e $(patchdir)/$$patch.dpatch -unpatch; then \
	    echo "reverted $$patch patch."; \
	    rm -f patch-stamp-$$patch; \
	  else \
	    echo "error in reverting $$patch patch."; \
	    exit 1; \
	  fi; \
	done
	rm -f patch-stamp

patch-stamp-%: $(patchdir)/%.dpatch
	if [ -f $@ ]; then \
	  echo "$* patch already applied."; exit 1; \
	fi
	sh -e $< -patch
	echo "$* patch applied." > $@

binary: binary-indep binary-arch

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

# Local Variables:
# mode: makefile
# end: