blob: f7e2f272f43ca03ab60058cdca2a8ae0dfb5fc63 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001require python.inc
2DEPENDS = "python-native libffi bzip2 db gdbm openssl readline sqlite3 zlib"
3PR = "${INC_PR}"
4
5DISTRO_SRC_URI ?= "file://sitecustomize.py"
6DISTRO_SRC_URI_linuxstdbase = ""
7SRC_URI += "\
8 file://01-use-proper-tools-for-cross-build.patch \
9 file://03-fix-tkinter-detection.patch \
10 file://06-avoid_usr_lib_termcap_path_in_linking.patch \
11 ${DISTRO_SRC_URI} \
12 file://multilib.patch \
13 file://cgi_py.patch \
14 file://setup_py_skip_cross_import_check.patch \
15 file://add-md5module-support.patch \
16 file://host_include_contamination.patch \
17 file://fix_for_using_different_libdir.patch \
18 file://setuptweaks.patch \
19 file://check-if-target-is-64b-not-host.patch \
20 file://search_db_h_in_inc_dirs_and_avoid_warning.patch \
21 file://avoid_warning_about_tkinter.patch \
22 file://avoid_warning_for_sunos_specific_module.patch \
23 file://python-2.7.3-remove-bsdb-rpath.patch \
24 file://fix-makefile-for-ptest.patch \
25 file://run-ptest \
26 file://parallel-makeinst-create-bindir.patch \
27 file://use_sysroot_ncurses_instead_of_host.patch \
28 file://avoid_parallel_make_races_on_pgen.patch \
29"
30
31S = "${WORKDIR}/Python-${PV}"
32
33inherit autotools multilib_header python-dir pythonnative
34
35CONFIGUREOPTS += " --with-system-ffi "
36
37# The 3 lines below are copied from the libffi recipe, ctypes ships its own copy of the libffi sources
38#Somehow gcc doesn't set __SOFTFP__ when passing -mfloatabi=softp :(
39TARGET_CC_ARCH_append_armv6 = " -D__SOFTFP__"
40TARGET_CC_ARCH_append_armv7a = " -D__SOFTFP__"
41
42# The following is a hack until we drop ac_cv_sizeof_off_t from site files
43EXTRA_OECONF += "${@bb.utils.contains('DISTRO_FEATURES', 'largefile', 'ac_cv_sizeof_off_t=8', '', d)} ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no"
44
45do_configure_append() {
46 rm -f ${S}/Makefile.orig
47 autoreconf -Wcross --verbose --install --force --exclude=autopoint ../Python-${PV}/Modules/_ctypes/libffi
48}
49
50do_compile() {
51 # regenerate platform specific files, because they depend on system headers
52 cd ${S}/Lib/plat-linux2
53 include=${STAGING_INCDIR} ${STAGING_BINDIR_NATIVE}/python-native/python \
54 ${S}/Tools/scripts/h2py.py -i '(u_long)' \
55 ${STAGING_INCDIR}/dlfcn.h \
56 ${STAGING_INCDIR}/linux/cdrom.h \
57 ${STAGING_INCDIR}/netinet/in.h \
58 ${STAGING_INCDIR}/sys/types.h
59 sed -e 's,${STAGING_DIR_HOST},,g' -i *.py
60 cd -
61
62 # remove any bogus LD_LIBRARY_PATH
63 sed -i -e s,RUNSHARED=.*,RUNSHARED=, Makefile
64
65 if [ ! -f Makefile.orig ]; then
66 install -m 0644 Makefile Makefile.orig
67 fi
68 sed -i -e 's#^LDFLAGS=.*#LDFLAGS=${LDFLAGS} -L. -L${STAGING_LIBDIR}#g' \
69 -e 's,libdir=${libdir},libdir=${STAGING_LIBDIR},g' \
70 -e 's,libexecdir=${libexecdir},libexecdir=${STAGING_DIR_HOST}${libexecdir},g' \
71 -e 's,^LIBDIR=.*,LIBDIR=${STAGING_LIBDIR},g' \
72 -e 's,includedir=${includedir},includedir=${STAGING_INCDIR},g' \
73 -e 's,^INCLUDEDIR=.*,INCLUDE=${STAGING_INCDIR},g' \
74 -e 's,^CONFINCLUDEDIR=.*,CONFINCLUDE=${STAGING_INCDIR},g' \
75 Makefile
76 # save copy of it now, because if we do it in do_install and
77 # then call do_install twice we get Makefile.orig == Makefile.sysroot
78 install -m 0644 Makefile Makefile.sysroot
79
80 export CROSS_COMPILE="${TARGET_PREFIX}"
81 export PYTHONBUILDDIR="${B}"
82
83 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python-native/pgen \
84 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python-native/python \
85 STAGING_LIBDIR=${STAGING_LIBDIR} \
86 STAGING_INCDIR=${STAGING_INCDIR} \
87 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
88 BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
89 OPT="${CFLAGS}"
90}
91
92do_install() {
93 # make install needs the original Makefile, or otherwise the inclues would
94 # go to ${D}${STAGING...}/...
95 install -m 0644 Makefile.orig Makefile
96
97 export CROSS_COMPILE="${TARGET_PREFIX}"
98 export PYTHONBUILDDIR="${B}"
99
100 # After swizzling the makefile, we need to run the build again.
101 # install can race with the build so we have to run this first, then install
102 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python-native/pgen \
103 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python-native/python \
104 CROSSPYTHONPATH=${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/ \
105 STAGING_LIBDIR=${STAGING_LIBDIR} \
106 STAGING_INCDIR=${STAGING_INCDIR} \
107 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
108 BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
109 DESTDIR=${D} LIBDIR=${libdir}
110
111 oe_runmake HOSTPGEN=${STAGING_BINDIR_NATIVE}/python-native/pgen \
112 HOSTPYTHON=${STAGING_BINDIR_NATIVE}/python-native/python \
113 CROSSPYTHONPATH=${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/ \
114 STAGING_LIBDIR=${STAGING_LIBDIR} \
115 STAGING_INCDIR=${STAGING_INCDIR} \
116 STAGING_BASELIBDIR=${STAGING_BASELIBDIR} \
117 BUILD_SYS=${BUILD_SYS} HOST_SYS=${HOST_SYS} \
118 DESTDIR=${D} LIBDIR=${libdir} install
119
120 install -m 0644 Makefile.sysroot ${D}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile
121
122 if [ -e ${WORKDIR}/sitecustomize.py ]; then
123 install -m 0644 ${WORKDIR}/sitecustomize.py ${D}/${libdir}/python${PYTHON_MAJMIN}
124 fi
125
126 oe_multilib_header python${PYTHON_MAJMIN}/pyconfig.h
127}
128
129do_install_append_class-nativesdk () {
130 create_wrapper ${D}${bindir}/python2.7 TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo'
131}
132
133SSTATE_SCAN_FILES += "Makefile"
134PACKAGE_PREPROCESS_FUNCS += "py_package_preprocess"
135
136py_package_preprocess () {
137 # copy back the old Makefile to fix target package
138 install -m 0644 ${B}/Makefile.orig ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile
139
140 # Remove references to buildmachine paths in target Makefile and _sysconfigdata
141 sed -i -e 's:--sysroot=${STAGING_DIR_TARGET}::g' -e s:'--with-libtool-sysroot=${STAGING_DIR_TARGET}'::g \
142 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/config/Makefile \
143 ${PKGD}/${libdir}/python${PYTHON_MAJMIN}/_sysconfigdata.py
144}
145
146require python-${PYTHON_MAJMIN}-manifest.inc
147
148# manual dependency additions
149RPROVIDES_${PN}-core = "${PN}"
150RRECOMMENDS_${PN}-core = "${PN}-readline"
151RRECOMMENDS_${PN}-core_append_class-nativesdk = " nativesdk-python-modules"
152RRECOMMENDS_${PN}-crypt = "openssl"
153
154# package libpython2
155PACKAGES =+ "lib${BPN}2"
156FILES_lib${BPN}2 = "${libdir}/libpython*.so.*"
157
158# catch debug extensions (isn't that already in python-core-dbg?)
159FILES_${PN}-dbg += "${libdir}/python${PYTHON_MAJMIN}/lib-dynload/.debug"
160
161# catch all the rest (unsorted)
162PACKAGES += "${PN}-misc"
163FILES_${PN}-misc = "${libdir}/python${PYTHON_MAJMIN}"
Patrick Williamsd7e96312015-09-22 08:09:05 -0500164RDEPENDS_${PN}-modules += "${PN}-misc"
165RDEPENDS_${PN}-ptest = "${PN}-modules"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500166#inherit ptest after "require python-${PYTHON_MAJMIN}-manifest.inc" so PACKAGES doesn't get overwritten
167inherit ptest
168
169# This must come after inherit ptest for the override to take effect
170do_install_ptest() {
171 cp ${B}/Makefile ${D}${PTEST_PATH}
172 sed -e s:LIBDIR/python/ptest:${PTEST_PATH}:g \
173 -e s:LIBDIR:${libdir}:g \
174 -i ${D}${PTEST_PATH}/run-ptest
175}
176
177# catch manpage
178PACKAGES += "${PN}-man"
179FILES_${PN}-man = "${datadir}/man"
180
181BBCLASSEXTEND = "nativesdk"