Skip to content

Instantly share code, notes, and snippets.

Created August 2, 2016 13:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save thijstriemstra/c21631ca12d2e60f0cace5509663e3cb to your computer and use it in GitHub Desktop.
Compile static C-extension with multiple source files for PyQt
set -e
set -o pipefail
source ../../
export CC="${PLAT}gcc -pthread"
export AR="${PLAT}ar rcsv"
echo `${PLAT}gcc --version`
export CFLAGS="-I${PYTHON_ARM_DIR_HOST}/include/python3.5m -I${SYSROOT}/usr/include"
export LDFLAGS="-L${PYTHON_ARM_DIR_HOST}/lib/python3.5 -L${SYSROOT}/lib -L${SYSROOT}/usr/lib"
export HOSTPYTHON=${PYTHON_ARM_DIR_HOST}/bin/hostpython
export SRC_DIR=build/temp.linux-x86_64-3.5/source
# clean
rm -rf build
echo "Cross-compiling extension..."
$HOSTPYTHON build_ext
# build static library
echo "Creating static library..."
${AR} librpigpio.a ${SRC_DIR}/py_gpio.o ${SRC_DIR}/c_gpio.o ${SRC_DIR}/cpuinfo.o ${SRC_DIR}/event_gpio.o ${SRC_DIR}/soft_pwm.o ${SRC_DIR}/py_pwm.o ${SRC_DIR}/common.o ${SRC_DIR}/constants.o
ranlib librpigpio.a
echo "Ready."
set -e
set -o pipefail
source ../../
# compile host python
make -j4
cp python hostpython
cp Parser/pgen Parser/hostpgen
make distclean
# compile ARM python
# work around: configure: error: set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling
rm -f
echo ac_cv_file__dev_ptmx=no >
echo ac_cv_file__dev_ptc=no >>
# patch Makefile for 3.5.1 (hopefully fixed in 3.5.2, see
cp --verbose ../../python/ .
# configure
CC=${PLAT}gcc CXX=${PLAT}g++ AR=${PLAT}ar RANLIB=${PLAT}ranlib LD=${PLAT}ld READELF=${PLAT}readelf ./configure --host=arm-linux-gnueabihf --build=x86_64-linux-gnu --prefix=${PYTHON_ARM_DIR_HOST} --disable-ipv6
# build
make -j4
# install
make install
cp hostpython ${PYTHON_ARM_DIR_HOST}/bin/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment