From 339afaf5bbb4f0314473d4ac0dd649b4d2c4a09a Mon Sep 17 00:00:00 2001 From: Guillaume Marcais Date: Wed, 17 Dec 2014 18:24:33 -0500 Subject: [PATCH] Only check for SWIG if necessary. Python compilation made more similar to Ruby and Perl. --- Makefile.am | 18 +++++++++++++----- configure.ac | 44 +++++++++++++++++++++----------------------- m4/m4-ax_perl_ext.m4 | 2 +- m4/m4-ax_ruby_ext.m4 | 2 +- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/Makefile.am b/Makefile.am index 707b2c07..090619ff 100644 --- a/Makefile.am +++ b/Makefile.am @@ -226,15 +226,23 @@ if PYTHON_BINDING PYTHON_BUILT = swig/python/swig_wrap.cpp BUILT_SOURCES += $(PYTHON_BUILT) -pkgpython_PYTHON = swig/python/jellyfish.py swig/python/__init__.py -pyexec_LTLIBRARIES = swig/python/_jellyfish.la +pythonextdir = $(PYTHON_SITE_PKG)/jellyfish +dist_pythonext_DATA = swig/python/jellyfish.pyc swig/python/__init__.pyc +pythonext_LTLIBRARIES = swig/python/_jellyfish.la swig_python__jellyfish_la_SOURCES = swig/python/swig_wrap.cpp $(SWIG_SRC) -swig_python__jellyfish_la_CPPFLAGS = $(SWIG_PYTHON_CPPFLAGS) $(PYTHON_CPPFLAGS) -I$(top_srcdir)/include +swig_python__jellyfish_la_CPPFLAGS = $(PYTHON_CPPFLAGS) -I$(top_srcdir)/include swig_python__jellyfish_la_LDFLAGS = -module $(PYTHON_LDFLAGS) swig_python__jellyfish_la_LIBADD = libjellyfish-2.0.la -CLEANFILES += $(PYTHON_BUILT) $(pkgpython_PYTHON) +CLEANFILES += $(PYTHON_BUILT) $(dist_pythonext_DATA) swig/python/jellyfish.py TESTS += tests/swig_python.sh + tests/swig_python.log: tests/generate_sequence.log + +PYTHONC_V_GEN = $(pythonc_v_GEN_$(V)) +pythonc_v_GEN_ = $(pythonc_v_GEN_$(AM_DEFAULT_VERBOSITY)) +pythonc_v_GEN_0 = @echo " PYTHONC " $@; +%.pyc: %.py + $(PYTHONC_V_GEN)$(PYTHON) -c 'import py_compile, sys; py_compile.compile(sys.argv[1], sys.argv[2])' $< $@ endif # Ruby support @@ -263,7 +271,7 @@ swig_perl5_jellyfish_la_SOURCES = swig/perl5/swig_wrap.cpp $(SWIG_SRC) swig_perl5_jellyfish_la_CPPFLAGS = $(PERL_EXT_CPPFLAGS) -I$(PERL_EXT_INC) -I$(top_srcdir)/include swig_perl5_jellyfish_la_LDFLAGS = -module $(PERL5_EXT_LDFLAGS) swig_perl5_jellyfish_la_LIBADD = libjellyfish-2.0.la -CLEANFILES += $(PERL5_BUILT) +CLEANFILES += $(PERL5_BUILT) swig/perl5/jellyfish.pm TESTS += tests/swig_perl.sh tests/swig_perl.log: tests/generate_sequence.log endif diff --git a/configure.ac b/configure.ac index 6ae0666a..27223e9e 100644 --- a/configure.ac +++ b/configure.ac @@ -92,41 +92,39 @@ AS_IF([test x$enable_all_static = xyes], # SWIG and bindings # -#AC_ARG_ENABLE([swig], -# [AC_HELP_STRING([--enable-swig], [enable swig for script bindings])]) -AX_PKG_SWIG(3.0.0) -AS_IF([test -n "$SWIG"], [SWIG_ENABLE_CXX]) -AM_CONDITIONAL([HAVE_SWIG], [test -n "$SWIG"]) - # --enable-python-binding AC_ARG_ENABLE([python-binding], [AC_HELP_STRING([--enable-python-binding@<:@=PATH@:>@], [create SWIG python module and install in PATH])]) -AC_MSG_NOTICE([enable_python x$enable_python_binding]) -AS_IF([test -n "$enable_python_binding"], - [AM_PATH_PYTHON] - [SWIG_PYTHON]) -AM_CONDITIONAL(PYTHON_BINDING, [test -n "$enable_python_binding"]) -AS_IF([test -n "$enable_python_binding" -a x$enable_python_binding != xyes], - [AC_SUBST([pythondir], [$enable_python_binding])] - [AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])] - [AC_SUBST([pyexecdir], [\${pythondir}])] - [AC_SUBST([pkgpyexecdir], [\${pkgpythondir}])] - [AC_SUBST([ENABLE_PYTHON_BINDING], 1)]) - # --enable-ruby-binding AC_ARG_ENABLE([ruby-binding], [AC_HELP_STRING([--enable-ruby-binding@<:@=PATH@:>@], [create SWIG ruby module and install in PATH])]) -AC_MSG_NOTICE([enable_ruby x$enable_ruby_binding]) +# --enable-perl-binding +AC_ARG_ENABLE([perl-binding], + [AC_HELP_STRING([--enable-perl-binding@<:@=PATH@:>@], [create SWIG perl module and install in PATH])]) + +# --enable-swig +AC_ARG_ENABLE([swig], + [AC_HELP_STRING([--enable-swig], [enable development of swig binding])]) +AS_IF([test x$enable_swig = xyes], + [AX_PKG_SWIG([3.0.0], [], [AC_MSG_ERROR([SWIG version 3 is required])])]) +AS_IF([test -n "$SWIG"], [SWIG_ENABLE_CXX]) +AM_CONDITIONAL([HAVE_SWIG], [test -n "$SWIG"]) + +# Python binding setup +AM_CONDITIONAL(PYTHON_BINDING, [test -n "$enable_python_binding"]) +AS_IF([test -n "$enable_python_binding" -a x$enable_python_binding != xyes], + [PYTHON_SITE_PKG=$enable_python_binding]) +AS_IF([test -n "$enable_python_binding"], + [AX_PYTHON_DEVEL]) + +# Ruby binding setup AM_CONDITIONAL([RUBY_BINDING], [test -n "$enable_ruby_binding"]) AS_IF([test -n "$enable_ruby_binding" -a x$enable_ruby_binding != xyes], [RUBY_EXT_LIB=$enable_ruby_binding]) AS_IF([test -n "$enable_ruby_binding"], [AX_RUBY_EXT]) -# --enable-perl-binding -AC_ARG_ENABLE([perl-binding], - [AC_HELP_STRING([--enable-perl-binding@<:@=PATH@:>@], [create SWIG perl module and install in PATH])]) -AC_MSG_NOTICE([enable_perl x$enable_perl_binding]) +# Perl binding setup AM_CONDITIONAL([PERL_BINDING], [test -n "$enable_perl_binding"]) AS_IF([test -n "$enable_perl_binding" -a x$enable_perl_binding != xyes], [PERL_EXT_LIB=$enable_perl_binding]) diff --git a/m4/m4-ax_perl_ext.m4 b/m4/m4-ax_perl_ext.m4 index ea510d84..1316f7c0 100644 --- a/m4/m4-ax_perl_ext.m4 +++ b/m4/m4-ax_perl_ext.m4 @@ -96,7 +96,7 @@ AC_DEFUN([AX_PERL_EXT],[ AC_ARG_VAR(PERL_EXT_LIB, [Directory to install perl files into]) AC_MSG_CHECKING([for Perl extension target directory]) if test -z "$PERL_EXT_LIB" ; then - [PERL_EXT_LIB=\${prefix}`$PERL -MConfig -e 'print $Config{sitearch};'`]; + [PERL_EXT_LIB=`$PERL -MConfig -e 'print $Config{sitearch};'`]; fi AC_MSG_RESULT([$PERL_EXT_LIB]) AC_SUBST(PERL_EXT_LIB) diff --git a/m4/m4-ax_ruby_ext.m4 b/m4/m4-ax_ruby_ext.m4 index 4c56cf07..af668ef3 100644 --- a/m4/m4-ax_ruby_ext.m4 +++ b/m4/m4-ax_ruby_ext.m4 @@ -84,7 +84,7 @@ AC_DEFUN([AX_RUBY_EXT],[ # AC_MSG_CHECKING([for Ruby extensions target directory]) AS_IF([test -z "$RUBY_EXT_LIB"], - [RUBY_EXT_LIB=\${prefix}`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG.values_at("sitearchdir")'`]) + [RUBY_EXT_LIB=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG.values_at("sitearchdir")'`]) AC_MSG_RESULT([$RUBY_EXT_LIB]) AC_SUBST(RUBY_EXT_LIB)