root/trunk/make/python27.mk @ 11455

Revision 11455, 10.4 KB (checked in by bzhou, 6 months ago)

python27: 2.7a1 -> 2.7a3

Line 
1###########################################################
2#
3# python27
4#
5###########################################################
6
7#
8# PYTHON27_VERSION, PYTHON27_SITE and PYTHON27_SOURCE define
9# the upstream location of the source code for the package.
10# PYTHON27_DIR is the directory which is created when the source
11# archive is unpacked.
12# PYTHON27_UNZIP is the command used to unzip the source.
13# It is usually "zcat" (for .gz) or "bzcat" (for .bz2)
14#
15# You should change all these variables to suit your package.
16# Please make sure that you add a description, and that you
17# list all your packages' dependencies, seperated by commas.
18#
19# If you list yourself as MAINTAINER, please give a valid email
20# address, and indicate your irc nick if it cannot be easily deduced
21# from your name or email address.  If you leave MAINTAINER set to
22# "NSLU2 Linux" other developers will feel free to edit.
23#
24PYTHON27_VERSION=2.7a3
25PYTHON27_VERSION_MAJOR=2.7
26PYTHON27_SITE=http://python.org/ftp/python/$(PYTHON27_VERSION_MAJOR)
27PYTHON27_SOURCE=Python-$(PYTHON27_VERSION).tar.bz2
28PYTHON27_DIR=Python-$(PYTHON27_VERSION)
29PYTHON27_UNZIP=bzcat
30
31PYTHON27_MAINTAINER=Brian Zhou<bzhou@users.sf.net>
32PYTHON27_DESCRIPTION=Python is an interpreted, interactive, object-oriented programming language.
33PYTHON27_SECTION=misc
34PYTHON27_PRIORITY=optional
35PYTHON27_DEPENDS=readline, bzip2, openssl, libdb, zlib, sqlite
36ifeq (libstdc++, $(filter libstdc++, $(PACKAGES)))
37PYTHON27_DEPENDS+=, libstdc++
38endif
39PYTHON27_DEPENDS+=, $(NCURSES_FOR_OPTWARE_TARGET)
40PYTHON27_SUGGESTS=
41
42#
43# PYTHON27_IPK_VERSION should be incremented when the ipk changes.
44#
45PYTHON27_IPK_VERSION=1
46
47#
48# PYTHON27_CONFFILES should be a list of user-editable files
49#PYTHON27_CONFFILES=/opt/etc/python.conf /opt/etc/init.d/SXXpython
50
51#
52# If the compilation of the package requires additional
53# compilation or linking flags, then list them here.
54#
55PYTHON27_CPPFLAGS=
56# workaround for uclibc bug, see http://www.geocities.com/robm351/uclibc/index-8.html?20063#sec:ldso-python
57ifeq ($(LIBC_STYLE),uclibc)
58PYTHON27_LDFLAGS=-lbz2 -lcrypt -ldb-$(LIBDB_LIB_VERSION) -lncurses -lreadline -lssl -lz
59else
60PYTHON27_LDFLAGS=
61endif
62
63#
64# PYTHON27_BUILD_DIR is the directory in which the build is done.
65# PYTHON27_SOURCE_DIR is the directory which holds all the
66# patches and ipkg control files.
67# PYTHON27_IPK_DIR is the directory in which the ipk is built.
68# PYTHON27_IPK is the name of the resulting ipk files.
69#
70# You should not change any of these variables.
71#
72PYTHON27_BUILD_DIR=$(BUILD_DIR)/python27
73PYTHON27_SOURCE_DIR=$(SOURCE_DIR)/python27
74PYTHON27_IPK_DIR=$(BUILD_DIR)/python27-$(PYTHON27_VERSION)-ipk
75PYTHON27_IPK=$(BUILD_DIR)/python27_$(PYTHON27_VERSION)-$(PYTHON27_IPK_VERSION)_$(TARGET_ARCH).ipk
76
77#
78# PYTHON27_PATCHES should list any patches, in the the order in
79# which they should be applied to the source code.
80#
81# http://mail.python.org/pipermail/patches/2004-October/016312.html
82PYTHON27_PATCHES=\
83        $(PYTHON27_SOURCE_DIR)/Makefile.pre.in.patch \
84        $(PYTHON27_SOURCE_DIR)/README.patch \
85        $(PYTHON27_SOURCE_DIR)/config.guess.patch \
86        $(PYTHON27_SOURCE_DIR)/config.sub.patch \
87        $(PYTHON27_SOURCE_DIR)/configure.in.patch \
88        $(PYTHON27_SOURCE_DIR)/setup.py.patch \
89        $(PYTHON27_SOURCE_DIR)/Lib-site.py.patch \
90        $(PYTHON27_SOURCE_DIR)/Lib-distutils-distutils.cfg.patch \
91
92ifeq ($(NCURSES_FOR_OPTWARE_TARGET), ncurses)
93PYTHON27_PATCHES+= $(PYTHON27_SOURCE_DIR)/disable-ncursesw.patch
94endif
95
96.PHONY: python27-source python27-unpack python27 python27-stage python27-ipk python27-clean python27-dirclean python27-check python27-host-stage
97
98#
99# This is the dependency on the source code.  If the source is missing,
100# then it will be fetched from the site using wget.
101#
102$(DL_DIR)/$(PYTHON27_SOURCE):
103        $(WGET) -P $(@D) $(PYTHON27_SITE)/$(@F) || \
104        $(WGET) -P $(@D) $(SOURCES_NLO_SITE)/$(@F)
105
106#
107# The source code depends on it existing within the download directory.
108# This target will be called by the top level Makefile to download the
109# source code's archive (.tar.gz, .bz2, etc.)
110#
111python27-source: $(DL_DIR)/$(PYTHON27_SOURCE) $(PYTHON27_PATCHES)
112
113#
114# This target unpacks the source code in the build directory.
115# If the source archive is not .tar.gz or .tar.bz2, then you will need
116# to change the commands here.  Patches to the source code are also
117# applied in this target as required.
118#
119# This target also configures the build within the build directory.
120# Flags such as LDFLAGS and CPPFLAGS should be passed into configure
121# and NOT $(MAKE) below.  Passing it to configure causes configure to
122# correctly BUILD the Makefile with the right paths, where passing it
123# to Make causes it to override the default search paths of the compiler.
124#
125# If the compilation of the package requires other packages to be staged
126# first, then do that first (e.g. "$(MAKE) <bar>-stage <baz>-stage").
127#
128$(PYTHON27_BUILD_DIR)/.configured: $(DL_DIR)/$(PYTHON27_SOURCE) $(PYTHON27_PATCHES) make/python27.mk
129ifeq (libstdc++, $(filter libstdc++, $(PACKAGES)))
130        $(MAKE) libstdc++-stage
131endif
132        $(MAKE) bzip2-stage readline-stage openssl-stage libdb-stage sqlite-stage zlib-stage
133        $(MAKE) $(NCURSES_FOR_OPTWARE_TARGET)-stage
134        rm -rf $(BUILD_DIR)/$(PYTHON27_DIR) $(@D)
135        $(PYTHON27_UNZIP) $(DL_DIR)/$(PYTHON27_SOURCE) | tar -C $(BUILD_DIR) -xf -
136        cat $(PYTHON27_PATCHES) | patch -bd $(BUILD_DIR)/$(PYTHON27_DIR) -p1
137        autoreconf -vif $(BUILD_DIR)/$(PYTHON27_DIR)
138        mkdir -p $(@D)
139        cd $(@D); (\
140        echo "[build_ext]"; \
141        echo "include-dirs=$(STAGING_INCLUDE_DIR):$(STAGING_INCLUDE_DIR)/ncurses"; \
142        echo "library-dirs=$(STAGING_LIB_DIR)"; \
143        echo "rpath=/opt/lib") > setup.cfg
144        (cd $(@D); \
145         $(TARGET_CONFIGURE_OPTS) \
146                CPPFLAGS="$(STAGING_CPPFLAGS) $(PYTHON27_CPPFLAGS)" \
147                LDFLAGS="$(STAGING_LDFLAGS) $(PYTHON27_LDFLAGS)" \
148                ac_cv_sizeof_off_t=8 \
149                ac_cv_file__dev_ptmx=yes \
150                ac_cv_file__dev_ptc=no \
151                ac_cv_header_bluetooth_bluetooth_h=no \
152                ac_cv_header_bluetooth_h=no \
153                ac_cv_have_long_long_format=yes \
154                ../$(PYTHON27_DIR)/configure \
155                --build=$(GNU_HOST_NAME) \
156                --host=$(GNU_TARGET_NAME) \
157                --target=$(GNU_TARGET_NAME) \
158                --prefix=/opt \
159                --mandir=/opt/man \
160                --enable-shared \
161                --enable-unicode=ucs4 \
162        )
163        touch $@
164
165python27-unpack: $(PYTHON27_BUILD_DIR)/.configured
166
167#
168# This builds the actual binary.
169#
170$(PYTHON27_BUILD_DIR)/.built: $(PYTHON27_BUILD_DIR)/.configured
171        rm -f $@
172        GNU_TARGET_NAME=$(GNU_TARGET_NAME) $(MAKE) -C $(@D)
173        touch $@
174
175#
176# This is the build convenience target.
177#
178python27: $(PYTHON27_BUILD_DIR)/.built
179
180#
181# If you are building a library, then you need to stage it too.
182#
183$(PYTHON27_BUILD_DIR)/.staged: $(PYTHON27_BUILD_DIR)/.built
184        rm -f $@
185        $(MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) install
186        touch $@
187
188python27-stage: $(PYTHON27_BUILD_DIR)/.staged
189
190$(HOST_STAGING_PREFIX)/bin/python2.7: host/.configured make/python27.mk
191        $(MAKE) $(PYTHON27_BUILD_DIR)/.built
192        $(MAKE) -C $(PYTHON27_BUILD_DIR)/buildpython27 DESTDIR=$(HOST_STAGING_DIR) install
193        patch -b -p0 < $(PYTHON27_SOURCE_DIR)/disable-host-py_include.patch
194        rm -f $(@D)/python
195
196python27-host-stage: $(HOST_STAGING_PREFIX)/bin/python2.7
197
198#
199# This rule creates a control file for ipkg.  It is no longer
200# necessary to create a seperate control file under sources/python
201#
202$(PYTHON27_IPK_DIR)/CONTROL/control:
203        @install -d $(@D)
204        @rm -f $@
205        @echo "Package: python27" >>$@
206        @echo "Architecture: $(TARGET_ARCH)" >>$@
207        @echo "Priority: $(PYTHON27_PRIORITY)" >>$@
208        @echo "Section: $(PYTHON27_SECTION)" >>$@
209        @echo "Version: $(PYTHON27_VERSION)-$(PYTHON27_IPK_VERSION)" >>$@
210        @echo "Maintainer: $(PYTHON27_MAINTAINER)" >>$@
211        @echo "Source: $(PYTHON27_SITE)/$(PYTHON27_SOURCE)" >>$@
212        @echo "Description: $(PYTHON27_DESCRIPTION)" >>$@
213        @echo "Depends: $(PYTHON27_DEPENDS)" >>$@
214
215#
216# This builds the IPK file.
217#
218# Binaries should be installed into $(PYTHON27_IPK_DIR)/opt/sbin or $(PYTHON27_IPK_DIR)/opt/bin
219# (use the location in a well-known Linux distro as a guide for choosing sbin or bin).
220# Libraries and include files should be installed into $(PYTHON27_IPK_DIR)/opt/{lib,include}
221# Configuration files should be installed in $(PYTHON27_IPK_DIR)/opt/etc/python/...
222# Documentation files should be installed in $(PYTHON27_IPK_DIR)/opt/doc/python/...
223# Daemon startup scripts should be installed in $(PYTHON27_IPK_DIR)/opt/etc/init.d/S??python
224#
225# You may need to patch your application to make it use these locations.
226#
227$(PYTHON27_IPK): $(PYTHON27_BUILD_DIR)/.built
228        rm -rf $(PYTHON27_IPK_DIR) $(BUILD_DIR)/python27_*_$(TARGET_ARCH).ipk
229        $(MAKE) -C $(PYTHON27_BUILD_DIR) DESTDIR=$(PYTHON27_IPK_DIR) install
230        $(STRIP_COMMAND) $(PYTHON27_IPK_DIR)/opt/bin/python$(PYTHON27_VERSION_MAJOR)
231        $(STRIP_COMMAND) $(PYTHON27_IPK_DIR)/opt/lib/python$(PYTHON27_VERSION_MAJOR)/lib-dynload/*.so
232        chmod 755 $(PYTHON27_IPK_DIR)/opt/lib/libpython$(PYTHON27_VERSION_MAJOR).so.1.0
233        $(STRIP_COMMAND) $(PYTHON27_IPK_DIR)/opt/lib/libpython$(PYTHON27_VERSION_MAJOR).so.1.0
234        chmod 555 $(PYTHON27_IPK_DIR)/opt/lib/libpython$(PYTHON27_VERSION_MAJOR).so.1.0
235        rm $(PYTHON27_IPK_DIR)/opt/bin/python $(PYTHON27_IPK_DIR)/opt/bin/python-config
236#       cd $(PYTHON27_IPK_DIR)/opt/bin; ln -s python$(PYTHON27_VERSION_MAJOR) python
237        for f in bin/pydoc bin/idle bin/smtpd.py; \
238            do mv $(PYTHON27_IPK_DIR)/opt/$$f $(PYTHON27_IPK_DIR)/opt/`echo $$f | sed -e 's/\(\.\|$$\)/-2.7\1/'`; done
239        install -d $(PYTHON27_IPK_DIR)/opt/local/bin
240        install -d $(PYTHON27_IPK_DIR)/opt/local/lib/python$(PYTHON27_VERSION_MAJOR)/site-packages
241        sed -i -e 's|$(TARGET_CROSS)|/opt/bin/|g' \
242               -e 's|$(STAGING_INCLUDE_DIR)|/opt/include|g' \
243               -e 's|$(STAGING_LIB_DIR)|/opt/lib|g' \
244               -e '/^RUNSHARED=/s|=.*|=|' \
245               $(PYTHON27_IPK_DIR)/opt/lib/python2.7/config/Makefile
246#ifeq ($(OPTWARE_WRITE_OUTSIDE_OPT_ALLOWED),true)
247#       install -d $(PYTHON27_IPK_DIR)/usr/bin
248#       ln -s /opt/bin/python $(PYTHON27_IPK_DIR)/usr/bin/python
249#endif
250        $(MAKE) $(PYTHON27_IPK_DIR)/CONTROL/control
251#       install -m 755 $(PYTHON27_SOURCE_DIR)/postinst $(PYTHON27_IPK_DIR)/CONTROL/postinst
252#       install -m 755 $(PYTHON27_SOURCE_DIR)/prerm $(PYTHON27_IPK_DIR)/CONTROL/prerm
253        cd $(BUILD_DIR); $(IPKG_BUILD) $(PYTHON27_IPK_DIR)
254
255#
256# This is called from the top level makefile to create the IPK file.
257#
258python27-ipk: $(PYTHON27_IPK)
259
260#
261# This is called from the top level makefile to clean all of the built files.
262#
263python27-clean:
264        -$(MAKE) -C $(PYTHON27_BUILD_DIR) clean
265
266#
267# This is called from the top level makefile to clean all dynamically created
268# directories.
269#
270python27-dirclean:
271        rm -rf $(BUILD_DIR)/$(PYTHON27_DIR) $(PYTHON27_BUILD_DIR) $(PYTHON27_IPK_DIR) $(PYTHON27_IPK)
272
273#
274# Some sanity check for the package.
275#
276python27-check: $(PYTHON27_IPK)
277        perl scripts/optware-check-package.pl --target=$(OPTWARE_TARGET) $^
Note: See TracBrowser for help on using the browser.