diff options
-rw-r--r-- | configure.ac | 54 | ||||
-rw-r--r-- | m4/cython.m4 | 81 | ||||
-rw-r--r-- | python/setup.py.in (renamed from python/setup.py) | 3 |
3 files changed, 112 insertions, 26 deletions
diff --git a/configure.ac b/configure.ac index eb2f4aaa..10cd8fd9 100644 --- a/configure.ac +++ b/configure.ac @@ -13,6 +13,9 @@ AC_LANG_CPLUSPLUS BOOST_REQUIRE([1.44]) BOOST_PROGRAM_OPTIONS BOOST_TEST +AM_PATH_PYTHON +# TODO detect Cython, generate python/Makefile that calls "python setup.py build" + AC_ARG_ENABLE(mpi, [ --enable-mpi Build MPI binaries, assumes mpi.h is present ], [ mpi=yes @@ -79,13 +82,6 @@ AC_CHECK_HEADER(google/dense_hash_map, AC_PROG_INSTALL -AM_CONDITIONAL([RAND_LM], false) -AC_ARG_WITH(randlm, - [AC_HELP_STRING([--with-randlm=PATH], [(optional) path to RandLM toolkit])], - [with_randlm=$withval], - [with_randlm=no] - ) - AM_CONDITIONAL([GLC], false) AC_ARG_WITH(glc, [AC_HELP_STRING([--with-glc=PATH], [(optional) path to Global Lexical Coherence package (Context CRF)])], @@ -94,24 +90,6 @@ AC_ARG_WITH(glc, ) FF_GLC="" -if test "x$with_randlm" != 'xno' -then - SAVE_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -I${with_randlm}/include" - - AC_CHECK_HEADER(RandLM.h, - [AC_DEFINE([HAVE_RANDLM], [], [flag for RandLM])], - [AC_MSG_ERROR([Cannot find RandLM!])]) - - - LIB_RANDLM="-lrandlm" - LDFLAGS="$LDFLAGS -L${with_randlm}/lib" - LIBS="$LIBS $LIB_RANDLM" - FMTLIBS="$FMTLIBS librandlm.a" - AM_CONDITIONAL([RAND_LM], true) -fi - - if test "x$with_glc" != 'xno' then SAVE_CPPFLAGS="$CPPFLAGS" @@ -132,4 +110,28 @@ fi CPPFLAGS="-DPIC -fPIC $CPPFLAGS -DHAVE_CONFIG_H" -AC_OUTPUT(Makefile rst_parser/Makefile utils/Makefile mteval/Makefile extools/Makefile decoder/Makefile phrasinator/Makefile training/Makefile training/liblbfgs/Makefile dpmert/Makefile pro-train/Makefile rampion/Makefile minrisk/Makefile klm/util/Makefile klm/lm/Makefile mira/Makefile dtrain/Makefile gi/pyp-topics/src/Makefile gi/clda/src/Makefile gi/pf/Makefile gi/markov_al/Makefile) +AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([utils/Makefile]) +AC_CONFIG_FILES([mteval/Makefile]) +AC_CONFIG_FILES([extools/Makefile]) +AC_CONFIG_FILES([decoder/Makefile]) +AC_CONFIG_FILES([phrasinator/Makefile]) +AC_CONFIG_FILES([training/Makefile]) +AC_CONFIG_FILES([training/liblbfgs/Makefile]) +AC_CONFIG_FILES([dpmert/Makefile]) +AC_CONFIG_FILES([pro-train/Makefile]) +AC_CONFIG_FILES([rampion/Makefile]) +AC_CONFIG_FILES([minrisk/Makefile]) +AC_CONFIG_FILES([klm/util/Makefile]) +AC_CONFIG_FILES([klm/lm/Makefile]) +AC_CONFIG_FILES([mira/Makefile]) +AC_CONFIG_FILES([dtrain/Makefile]) +AC_CONFIG_FILES([gi/pyp-topics/src/Makefile]) +AC_CONFIG_FILES([gi/clda/src/Makefile]) +AC_CONFIG_FILES([gi/pf/Makefile]) +AC_CONFIG_FILES([gi/markov_al/Makefile]) + +AC_CONFIG_FILES([python/setup.py],[chmod +x python/setup.py]) + +AC_OUTPUT + diff --git a/m4/cython.m4 b/m4/cython.m4 new file mode 100644 index 00000000..2d98eee7 --- /dev/null +++ b/m4/cython.m4 @@ -0,0 +1,81 @@ +dnl Taken from the python bindings to the Enlightenment foundation libraries, +dnl and was part of a GPL package. I have included this file to fix the build. +dnl +dnl +dnl AM_CHECK_CYTHON([VERSION [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]]) +dnl Check if a Cython version is installed +dnl Defines CYTHON_VERSION and CYTHON_FOUND +AC_DEFUN([AM_CHECK_CYTHON], +[ +AC_REQUIRE([AM_PATH_PYTHON]) +ifelse([$1], [], [_msg=""], [_msg=" >= $1"]) +AC_MSG_CHECKING(for Cython$_msg) +AC_CACHE_VAL(py_cv_cython, [ + +prog="import Cython.Compiler.Version; print Cython.Compiler.Version.version" +CYTHON_VERSION=`$PYTHON -c "$prog" 2>&AC_FD_CC` + +py_cv_cython=no +if test "x$CYTHON_VERSION" != "x"; then + py_cv_cython=yes +fi + +if test "x$py_cv_cython" = "xyes"; then + ifelse([$1], [], [:], + AS_VERSION_COMPARE([$CYTHON_VERSION], [$1], [py_cv_cython=no])) +fi +]) + +AC_MSG_RESULT([$py_cv_cython]) + +if test "x$py_cv_cython" = "xyes"; then + CYTHON_FOUND=yes + ifelse([$2], [], [:], [$2]) +else + CYTHON_FOUND=no + ifelse([$3], [], [AC_MSG_ERROR([Could not find usable Cython$_msg])], [$3]) +fi +]) + +dnl AM_CHECK_CYTHON_PRECOMPILED(FILE-LIST [, ACTION-IF-ALL [, ACTION-IF-NOT-ALL]]) +dnl given a list of files ending in .pyx (FILE-LIST), check if their .c +dnl counterpart exists and is not older than the source. +dnl ACTION-IF-ALL is called only if no files failed the check and thus +dnl all pre-generated files are usable. +dnl ACTION-IF-NOT-ALL is called if some or all failed. If not provided, +dnl an error will be issued. +AC_DEFUN([AM_CHECK_CYTHON_PRECOMPILED], +[ +_to_check_list="$1" +_failed_list="" +_exists_list="" + +for inf in $_to_check_list; do + outf=`echo "$inf" | sed -e 's/^\(.*\)[.]pyx$/\1.c/'` + if test "$outf" = "$inf"; then + AC_MSG_WARN([File to check must end in .pyx, but got: $inf -- Skip]) + continue + fi + + AC_MSG_CHECKING([for pre-generated $outf for $inf]) + if ! test -f "$outf"; then + _res=no + _failed_list="${_failed_list} $outf" + elif ! test "$outf" -nt "$inf"; then + _res="no (older)" + _failed_list="${_failed_list} $outf" + else + _res=yes + _exists_list="${_exists_list} $outf" + fi + AC_MSG_RESULT($_res) +done + +if test -z "$_failed_list" -a -n "$_exists_list"; then + ifelse([$2], [], [:], [$2]) +else + ifelse([$3], [], + [AC_MSG_ERROR([Missing pre-generated files: $_failed_list])], + [$3]) +fi +]) diff --git a/python/setup.py b/python/setup.py.in index 54510024..77c10b07 100644 --- a/python/setup.py +++ b/python/setup.py.in @@ -10,6 +10,9 @@ def fail(msg): INC = ['..', 'src/', '../decoder', '../utils', '../mteval'] LIB = ['../decoder', '../utils', '../mteval', '../training', '../klm/lm', '../klm/util'] +# set automatically by configure +raw_config_libs = '@LIBS@' + try: with open('../config.status') as config: config = config.read() |