Files
Arch-R/packages/lang/Python/build
2011-09-28 04:59:02 +02:00

127 lines
4.2 KiB
Bash
Executable File

#!/bin/sh
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2011 Stephan Raue (stephan@openelec.tv)
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC.tv; see the file COPYING. If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# http://www.gnu.org/copyleft/gpl.html
################################################################################
. config/options $1
PY_DISABLED_MODULES="readline _curses _curses_panel _tkinter nis gdbm bsddb _codecs_kr _codecs_jp _codecs_cn _codecs_tw _codecs_hk"
cd $PKG_BUILD
mkdir -p .objdir-host && cd .objdir-host
setup_toolchain host
OPT="$HOST_CFLAGS" \
LDFLAGS="$LDFLAGS -lexpat" \
../configure --host=$HOST_NAME \
--build=$HOST_NAME \
--prefix=$ROOT/$TOOLCHAIN \
--cache-file=config.cache \
--enable-shared \
--without-cxx-main \
--with-threads \
--enable-unicode=ucs4 \
make PYTHON_MODULES_INCLUDE="$HOST_INCDIR" \
PYTHON_MODULES_LIB="$HOST_LIBDIR"
make PYTHON_MODULES_INCLUDE="$HOST_INCDIR" \
PYTHON_MODULES_LIB="$HOST_LIBDIR" \
install
# symlink python binary to python2 (needed for Mesa)
ln -sf python $ROOT/$TOOLCHAIN/bin/python2
cp Parser/pgen ./hostpgen
cp python ./hostpython
cd ..
mkdir -p .objdir-target && cd .objdir-target
setup_toolchain target
# dont use some optimizations because of problems
# this fixes problems with expat (maybe)
LDFLAGS=`echo $LDFLAGS | sed -e "s|-Wl,--as-needed||"`
strip_lto
ac_cv_file_dev_ptc=no \
ac_cv_file_dev_ptmx=yes \
ac_cv_func_lchflags_works=no \
ac_cv_func_chflags_works=no \
ac_cv_func_printf_zd=yes \
OPT="$CFLAGS -fno-strict-aliasing" \
LDFLAGS="$LDFLAGS -lexpat -lffi" \
../configure --host=$TARGET_NAME \
--build=$HOST_NAME \
--cache-file=config.cache \
--prefix=/usr \
--sysconfdir=/etc \
--enable-shared \
--with-threads \
--enable-unicode=ucs4 \
--disable-ipv6 \
--disable-profiling \
--without-pydebug \
--without-doc-strings \
--without-tsc \
--without-pymalloc \
--without-fpectl \
--without-wctype-functions \
--without-cxx-main \
--with-system-ffi \
make -j1 CC="$TARGET_CC" \
HOSTPYTHON=../.objdir-host/hostpython \
HOSTPGEN=../.objdir-host/hostpgen \
RUNSHARED="LD_LIBRARY_PATH=../.objdir-host:" \
BLDSHARED="$CC -shared" \
PYTHON_DISABLE_MODULES="$PY_DISABLED_MODULES" \
CROSS_COMPILE="$TARGET_NAME" \
CROSS_COMPILE_TARGET="yes" \
PYTHON_MODULES_INCLUDE="$TARGET_INCDIR" \
PYTHON_MODULES_LIB="$TARGET_LIBDIR" \
make -j1 CC="$TARGET_CC" \
DESTDIR=$SYSROOT_PREFIX \
HOSTPYTHON=../.objdir-host/hostpython \
HOSTPGEN=../.objdir-host/hostpgen \
RUNSHARED="LD_LIBRARY_PATH=../.objdir-host:" \
BLDSHARED="$CC -shared" \
PYTHON_DISABLE_MODULES="$PY_DISABLED_MODULES" \
CROSS_COMPILE="$TARGET_NAME" \
CROSS_COMPILE_TARGET="yes" \
PYTHON_MODULES_INCLUDE="$TARGET_INCDIR" \
PYTHON_MODULES_LIB="$TARGET_LIBDIR" \
install
# replace python-config to make sure python uses $SYSROOT_PREFIX
mkdir -p $ROOT/$TOOLCHAIN/bin
rm -rf $ROOT/$TOOLCHAIN/bin/python*-config
sed -e "s:%PREFIX%:$SYSROOT_PREFIX/usr:g" -e "s:%CFLAGS%:$TARGET_CFLAGS:g" \
$ROOT/$PKG_DIR/scripts/python-config > $ROOT/$TOOLCHAIN/bin/python2.6-config
chmod +x $ROOT/$TOOLCHAIN/bin/python2.6-config
ln -s python2.6-config $ROOT/$TOOLCHAIN/bin/python-config