#! /bin/zsh # encoding: utf-8 setopt extendedglob function die() { echo "\n\n>>> Failed during ${1}, aborting." exit 1 } function translate() { echo -n "Translating from Python to C: " first=1 for item in ${@} do if [ $first -eq 1 ]; then echo -n "${item}" first=0 else echo -n ", ${item}" fi cython -3 ${item}.pyx -o ${item}.c || die "translating" done echo "." } function combobulate() { name="$1" echo -n > "$name.pyx" for part in src/$name.*.pyx do # echo "Combobulating $part..." echo "###############################################################################" >> "$name.pyx" echo "# Combobulated from file $part" >> "$name.pyx" echo "###############################################################################\n" >> "$name.pyx" cat "$part" >> "$name.pyx" echo >> "$name.pyx" done } CFLAGS=(-Wall -pedantic -std=c99 -fPIC) LFLAGS=(-shared) combobulate core ln -s src/interface/* . # call Cython translate core echo -n "Compiling and linking: core" gcc $CFLAGS -I/usr/include/python3.3 -pthread -c core.c || die "compilation" gcc $LFLAGS -L/usr/lib -lpython3.3 core.o -o core.so || die "linking" rm -f core.{c,o} echo "." # remove temporary sources rm -f *.pyx *.pxd