summaryrefslogtreecommitdiff
path: root/python2.7/Makefile
blob: c17222131827e2bfa79f24846c4d2db287460392 (plain)
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
include /usr/share/cibs/rules/ips.mk
include /usr/share/cibs/rules/autotools.mk
include /usr/share/cibs/rules/archive.mk
include /usr/share/cibs/rules/patch.mk

movefiles := /usr/share/cibs/scripts/movefiles
payload := /usr/share/cibs/scripts/make-payload

$(eval $(call add-variant,default))
%-default-stamp: bits = 64

summary := an interpreted, interactive, object-oriented, extensible programming language
license := Python License
license-file := LICENSE

name     := Python
pyver    := 2.7
version  := 2.7.3
home     := http://www.python.org/
archive  := $(name)-$(version).tar.bz2
download := http://www.python.org/ftp/python/$(version)/$(archive)

PVER := python$(pyver)

checksum-Python-2.7.3.tar.bz2 := \
     md5:c57477edd6d18bd9eeca2f21add73919 \
    sha1:842c4e2aff3f016feea3c6e992c7fa96e49c9aa0 \
  sha256:726457e11cb153adc3f428aaf1901fc561a374c30e5e7da6742c0742a338663c \
    size:11793433

build-depends += \
	compress/bzip2 \
	developer/build/autoconf \
	file/symlinks \
	library/libbz2 \
	library/libdb-5.1 \
	library/libexpat \
	library/libffi \
	library/libgdbm \
	library/libsqlite3 \
	library/ncursesw \
	library/readline \
	library/tinfo \
	library/zlib \
	text/gawk \
	text/help2man \

define __post_configure
	egrep \
	  "^#($$(gawk -v ORS='|' '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in)XX)" \
	  $(sourcedir)/Modules/Setup.dist \
	    | sed -e 's/^#//' -e 's/-Wl,-Bdynamic//;s/-Wl,-Bstatic//' \
	    >> $(1)/Modules/Setup.local

	: # unconditionally run makesetup
	cd $(1) && \
	  $(topdir)/$(sourcedir)/Modules/makesetup -c $(topdir)/$(sourcedir)/Modules/config.c.in -s Modules \
	    Modules/Setup.config Modules/Setup.local Modules/Setup
	mv $(1)/config.c $(1)/Modules/

	: # and fix the timestamps
	$(MAKE) -C $(1) Makefile Modules/config.c

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

pre-configure-stamp: autoconf-stamp
autoconf-stamp: patch-stamp
	cd $(sourcedir) && autoconf
	touch $@

build-default-stamp: post-configure-stamp
post-configure-stamp: configure-default-stamp
	$(call __post_configure,$(builddir))
	touch $@

configure-options += \
	--without-gcc \
	--enable-ipv6 \
	--enable-unicode=ucs4 \
	--with-dbmliborder=bdb:gdbm \
	--with-system-expat \
	--with-system-ffi \
	--enable-shared \

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_PACKAGES := $(shell awk '/^  / && $$2 == "package" { 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 $(sourcedir)/Lib/encodings && echo *.py)), \
			encodings/$(i)) \
		 codecs.py stringprep.py

# We install libpython.X.Y.so.* in usual place (libdir),
# but runtime libraries go into the place where python
# looks them for:
install-default-stamp: make-vars += \
	LIBPL=$(prefix)/lib/python$(pyver)/config \
	DESTSHARED=$(prefix)/lib/python$(pyver)/lib-dynload

# Shorter name:
d         := $(protodir.default)
b         := $(builddir.default)
VER       := $(pyver)
scriptdir := usr/lib/python$(VER)
d_min     := work/proto/python-minimal
d_lib     := work/proto/libpython
d_dev     := work/proto/dev-python
libdir    := usr/lib$(lib-suffix.$(bits))

python-minimal.p5m: env += proto=$(d_min)


install-stamp: postinst-stamp
postinst-stamp: install-default-stamp
	mv $(d)/$(scriptdir)/_sysconfigdata.py \
		$(d)/$(scriptdir)/_sysconfigdata_nd.py
	cp $(b)/libpython$(pyver).a \
		$(d)/$(libdir)/
	rm $(d)/$(scriptdir)/config/*.a
	ln -sf $(topdir)/$(d)/$(libdir)/libpython$(pyver).a \
		$(d)/$(scriptdir)/config/libpython$(pyver).a
	symlinks -c $(d)/$(scriptdir)/config/

	cp -p debian/_sysconfigdata.py $(d)/$(scriptdir)/
	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
	rm -f $(d)/usr/lib/pkgconfig/python.pc
	rm -f $(d)/usr/bin/python2{,-config}
	rm -f $(d)/usr/share/man/man1/python2{,-config}.1
	gfind $(d) -name 'wininst*.exe' | gxargs -r rm -f

	: # Symlinks to /usr/bin for some tools
	ln -sf ../lib/python$(VER)/pdb.py $(d)/usr/bin/pdb$(VER)
	: # versioned install only
	rm -f $(d)/usr/bin/python-config
	mv $(d)/usr/bin/pydoc $(d)/usr/bin/pydoc$(VER)
	: # Remove version information from the egg-info file
	mv $(d)/$(scriptdir)/lib-dynload/Python-$(VER)*.egg-info \
		$(d)/$(scriptdir)/lib-dynload/Python-$(VER).egg-info
	cp -p $(sourcedir)/Tools/i18n/pygettext.py $(d)/usr/bin/pygettext$(VER)

	mv $(d)/usr/bin/2to3 $(d)/usr/bin/2to3-$(VER)
	PYTHONPATH=$(d)/$(scriptdir) \
	help2man --no-info --version-string=$(VER) --no-discard-stderr \
	  --name 'Python2 to Python3 converter' \
	$(d)/usr/bin/2to3-$(VER) \
	> $(d)/usr/share/man/man1/2to3-$(VER).1

	: # install minimal set:
	mkdir -p $(d_min)
	cd $(d_min) && mkdir -p \
		etc/$(PVER) \
		usr/bin \
		usr/include/$(PVER) \
		usr/share/man/man1 \
		$(scriptdir)/lib-dynload \
		$(scriptdir)/config
	$(movefiles) -s $(d) -d$(d_min) \
		usr/bin/python$(VER) \
		usr/share/man/man1/python$(VER).1 \
		$(foreach i,$(MIN_MODS),$(scriptdir)/$(i).py) \
		$(foreach i,$(MIN_PACKAGES),$(scriptdir)/$(i)) \
		$(foreach i,$(MIN_ENCODINGS),$(scriptdir)/$(i)) \
		$(scriptdir)/config/Makefile \
		usr/include/$(PVER)/pyconfig.h \
		$(scriptdir)/site.py \
		$(shell cd $(d); for i in $(MIN_EXTS); do \
			test -e $(scriptdir)/lib-dynload/$$i.so \
			  && echo $(scriptdir)/lib-dynload/$$i.so; \
		  done; true)

	# install libpython:
	mkdir -p $(d_lib)
	$(movefiles) -s $(d) -d $(d_lib) \
		$(libdir)/libpython$(pyver).so.1.0
	ln -sf libpython$(pyver).so.1.0 \
		$(d_lib)/$(libdir)/libpython$(pyver).so.1

	# install developer/python:
	mkdir -p $(d_dev)
	mkdir -p $(d_dev)/usr/share/man/man1
	$(movefiles) -s $(d) -d $(d_dev) \
		usr/lib/python$(VER)/config \
		usr/include/python$(VER) \
		$(libdir)/libpython$(VER).so \
		$(libdir)/libpython$(VER).a \
		$(libdir)/pkgconfig/python-$(VER).pc \
		usr/bin/python$(VER)-config
	cp -p debian/python-config.1 \
		$(d_dev)/usr/share/man/man1/python$(VER)-config.1


	touch $@