Skip to content

Commit

Permalink
Merge pull request #4 from RaumZeit/dev_refactor_swig
Browse files Browse the repository at this point in the history
SWIG: Update autoconf build process for swig wrappers
  • Loading branch information
RaumZeit committed Nov 24, 2020
2 parents 72747b8 + 930f343 commit 0153010
Show file tree
Hide file tree
Showing 25 changed files with 803 additions and 620 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
autom4te.cache/
config.status
configure
*/.deps/
*.deps
*nbproject*
*RNAdesign
*.[oa]
Expand All @@ -30,5 +30,5 @@ m4/lt~obsolete.m4
doc*
depcomp
install-sh
interfaces/Perl/*
interfaces/Python/*
src/RNAblueprint
tests/testRNAblueprint
103 changes: 79 additions & 24 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -202,28 +202,62 @@ AS_IF([test "x$enable_swig" != "xno"], [
AM_CONDITIONAL([ENABLE_SWIG], [test x"$enable_swig_status" = x"yes"])

AM_COND_IF([ENABLE_SWIG], [
AX_SWIG_ENABLE_CXX
AX_SWIG_MULTI_MODULE_SUPPORT
# Python2 support
######################################################################
AX_REQUIRE_DEFINED([AX_PYTHON2_DEVEL])
AC_ARG_ENABLE([python2],
[AS_HELP_STRING([--disable-python2],
[Disable the Python 2.x interface.])])
AS_IF([test "x$enable_python2" != "xno"], [
AC_MSG_NOTICE([Building with Python 2.x bindings])
## check for python2 config
AX_PYTHON2_DEVEL
if test "x$python2_enabled_but_failed" != "x"
then
with_python2="no"
else
AC_SUBST(PYTHON2DIR,$python2dir)
AC_SUBST(PKGPYTHON2DIR,$pkgpython2dir)
AC_SUBST(PYEXEC2DIR,$py2execdir)
AC_SUBST(PKGPYEXEC2DIR,$pkgpy2execdir)
AC_DEFINE([WITH_PYTHON2_INTERFACE], [1], [Create the python2 interface to RNAblueprint])
AC_SUBST([PYTHON2_INTERFACE], [Python2])
AC_CONFIG_FILES([interfaces/Python2/Makefile interfaces/Python2/version.i])
fi
[enable_python2_status="yes"]
], [
[enable_python2_status="no"]
])
# Python support
# Python3 support
######################################################################
AX_REQUIRE_DEFINED([AX_PYTHON3_DEVEL])
AC_ARG_ENABLE([python],
[AS_HELP_STRING([--disable-python],
[Disable the Python interface.])])
[Disable the Python 3.x interface.])])
AS_IF([test "x$enable_python" != "xno"], [
AC_MSG_NOTICE([Building with Python bindings])
AM_PATH_PYTHON(2.7, [], [
AC_MSG_ERROR([Python is required to build.])
[enable_python_status="Python is required to build."]
])
AX_PYTHON_DEVEL
AX_SWIG_PYTHON
AC_MSG_NOTICE([Building with Python 3.x bindings])
## check for python3 config
AX_PYTHON3_DEVEL
if test "x$python3_enabled_but_failed" != "x"
then
with_python="no"
else
AC_DEFINE([WITH_PYTHON3_INTERFACE], [1], [Create the Python3 interface to RNAlib])
AC_SUBST([PYTHON3_INTERFACE], [Python3])
fi
AC_CONFIG_FILES([interfaces/Python3/Makefile interfaces/Python3/version.i])
[enable_python_status="yes"]
], [
[enable_python_status="no"]
])
# Perl5 support
######################################################################
AC_ARG_ENABLE([perl],
Expand All @@ -232,23 +266,45 @@ AM_COND_IF([ENABLE_SWIG], [
AS_IF([test "x$enable_perl" != "xno"], [
AC_MSG_NOTICE([Building with Perl bindings])
AX_PERL_EXT([$prefix])
if test x"$PERL" = x; then
AX_PERL_EXT
if test "x$PERL" = "x"; then
AC_MSG_ERROR([Perl is required to build.])
[enable_python_status="Perl is required to build."]
[enable_perl_status="Perl is required to build."]
fi
AX_PERL_EXT_FLAGS([PERLXS_CFLAGS], [PERLXS_LDFLAGS])
AC_SUBST([PERLXS_CFLAGS])
AC_SUBST([PERLXS_LDFLAGS])
])
AS_IF([test "x$enable_perl" != "xno"], [
# Compose the correct installation path for perl modules
#
# here we actually have to account for INSTALLDIRS env variable, which can be
#
# site = where the local systems administrator installs packages to
# vendor = where system packages are installed to, or
# core = where perl core packages are installed
#
# The default selection is 'site', but upon packaging for a specific distribution
# we might want the user to set this to 'vendor'
#
AS_IF([ test "x$INSTALLDIRS" == "xvendor" ],[
PERL_ARCH_RELATIVE_INSTALL_DIR=`echo ${PERL_EXT_VENDORARCH} | sed "s,${PERL_EXT_VENDORPREFIX},,"`
PERL_LIB_RELATIVE_INSTALL_DIR=`echo ${PERL_EXT_VENDORLIB} | sed "s,${PERL_EXT_VENDORPREFIX},,"`
],[
PERL_ARCH_RELATIVE_INSTALL_DIR=`echo ${PERL_EXT_SITEARCH} | sed "s,${PERL_EXT_SITEPREFIX},,"`
PERL_LIB_RELATIVE_INSTALL_DIR=`echo ${PERL_EXT_SITELIB} | sed "s,${PERL_EXT_SITEPREFIX},,"`
])
AC_SUBST(PERL_ARCH_RELATIVE_INSTALL_DIR)
AC_SUBST(PERL_LIB_RELATIVE_INSTALL_DIR)
AC_DEFINE([WITH_PERL_INTERFACE], [1], [Create the perl interface to RNAlib])
AC_SUBST([PERL_INTERFACE], [Perl])
AC_CONFIG_FILES([interfaces/Perl/Makefile interfaces/Perl/version.i])
[enable_perl_status="yes"]
], [
[enable_perl_status="no"]
])
])

AM_CONDITIONAL([ENABLE_PYTHON],[test "x$enable_python_status" = x"yes"])
AM_CONDITIONAL([ENABLE_PERL5],[test "x$enable_perl_status" = x"yes"])

# Configure supported platforms
##########################################################################
case $host in
Expand All @@ -270,8 +326,6 @@ AC_CONFIG_FILES([lib/Makefile])
AC_CONFIG_FILES([src/Makefile])
AC_CONFIG_FILES([tests/Makefile])
AC_CONFIG_FILES([interfaces/Makefile])
AC_CONFIG_FILES([interfaces/Python/Makefile])
AC_CONFIG_FILES([interfaces/Perl/Makefile])

# generate the final Makefile etc. and display summary
##########################################################################
Expand All @@ -297,7 +351,8 @@ Options:
SWIG enabled: $enable_swig_status
Perl interface: $enable_perl_status
Python interface: $enable_python_status
Python2 interface: $enable_python2_status
Python3 interface: $enable_python_status
Documentation enabled: $doxygen_doc
(HTML): $doxygen_html
Expand Down
8 changes: 5 additions & 3 deletions interfaces/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# the subdirectories of the interface
if ENABLE_SWIG
SUBDIRS = @PERL_INTERFACE@ @PYTHON2_INTERFACE@ @PYTHON3_INTERFACE@

SUBDIRS = Python Perl
SOURCES = \
RNAblueprint.i

endif
EXTRA_DIST = \
RNAblueprint.i
6 changes: 6 additions & 0 deletions interfaces/Perl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ignore files that are created by SWIG
RNAblueprint.pm
RNAblueprint_wrap.*
auto
version.i

101 changes: 87 additions & 14 deletions interfaces/Perl/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,22 +1,95 @@
# this is: interfaces/Perl/Makefile.am
if ENABLE_PERL5
perlextdir = $(PERL_EXT_LIB)
include ../generic.mk


PERL_MODULE = $(SWIG_module_name).pm

perlextdir = $(prefix)$(PERL_ARCH_RELATIVE_INSTALL_DIR)/auto/RNAblueprint
perlext_LTLIBRARIES = RNAblueprint.la

RNAblueprint_la_SOURCES = $(top_srcdir)/interfaces/RNAblueprint.i
nodist_RNAblueprint_la_SOURCES = RNAblueprint_wrap.cxx $(SWIG_SOURCES)
nodist_perlext_SCRIPTS = RNAblueprint.pm
LANG_SPECIFIC_INTERFACE_FILES = \
$(builddir)/version.i

RNAblueprint_la_CPPFLAGS = -I$(top_srcdir)/lib $(PERL_EXT_CPPFLAGS) $(SWIG_PERL_CPPFLAGS) $(PERLXS_CFLAGS) $(BOOST_CPPFLAGS)
RNAblueprint_la_LIBADD = $(LDADD) $(top_srcdir)/lib/libRNAblueprint.la $(PERLXS_LIBS) $(BOOST_GRAPH_LIBS)
RNAblueprint_la_LDFLAGS = -avoid-version -module -shared -export-dynamic $(PERLXS_LDFLAGS) $(BOOST_GRAPH_LDFLAGS)
INTERFACE_FILES = $(SWIG_src) \
$(LANG_SPECIFIC_INTERFACE_FILES)

RNAblueprint_wrap.cxx: $(top_srcdir)/interfaces/RNAblueprint.i
$(SWIG) -I${top_srcdir}/lib -includeall -o RNAblueprint_wrap.cxx -perl ${top_srcdir}/interfaces/RNAblueprint.i
RNAblueprint_la_SOURCES = $(INTERFACE_FILES) \
$(SWIG_wrapper)

RNAblueprint.pm: RNAblueprint_wrap.cxx
perlmoddir = $(prefix)$(PERL_LIB_RELATIVE_INSTALL_DIR)
nobase_dist_perlmod_DATA = \
$(PERL_MODULE)

clean-local:
rm -rf RNAblueprint_wrap.cxx RNAblueprint.pm
RNAblueprint_la_CPPFLAGS = -I$(PERL_EXT_INC) -I$(top_srcdir)/lib $(BOOST_CPPFLAGS)
RNAblueprint_la_CXXFLAGS = -Wno-unused-label -Wno-unused-variable

RNAblueprint_la_LIBADD = \
$(LDADD) \
$(top_builddir)/lib/libRNAblueprint_conv.la \
$(BOOST_GRAPH_LIBS) \
-lstdc++

RNAblueprint_la_LDFLAGS = \
-avoid-version \
-module \
-shared \
-export-dynamic \
-shrext \
$(BOOST_GRAPH_LDFLAGS) \
$(PERL_SO)

EXTRA_DIST = \
$(SWIG_wrapper) \
$(PERL_MODULE) \
$(LANG_SPECIFIC_INTERFACE_FILES)

##
## SWIG interface wrapper code generation
##

if ENABLE_SWIG

$(SWIG_wrapper) $(PERL_MODULE): $(INTERFACE_FILES)
$(swig_verbose)$(SWIG) -I$(top_srcdir)/src \
-I$(srcdir) -I$(builddir) \
-includeall \
-perl5 -proxy -const -c++ \
-module RNAblueprint -o $(SWIG_wrapper) \
$(SWIG_main_src)

endif

##
## copy shared library for perl-tests
##

auto/RNAblueprint/RNAblueprint$(PERL_SO): RNAblueprint.la
$(AM_V_GEN)( $(MKDIR_P) auto/RNAblueprint ) && \
( \
$(LIBTOOL) --config > libtoolconfig.tmp && \
( . ./libtoolconfig.tmp; cp "$$objdir/RNAblueprint$(PERL_SO)" auto/RNAblueprint ) && \
rm -f libtoolconfig.tmp \
)

all-local: auto/RNAblueprint/RNAblueprint$(PERL_SO)

clean-local:
-rm -rf auto

## Remove the .la file - RNAblueprint.la is never linked against (it's a module)
## and Perl doesn't use libltdl. Note that the library gets installed by
## install-data, so that's where we need to hook.
install-data-hook:
rm -f $(DESTDIR)$(perlextdir)/RNAblueprint.la

## Because we don't install the .la file, "make uninstall" doesn't work and
## we need to remove the file ourselves.
uninstall-local:
eval `grep '^dlname=' $(perlext_LTLIBRARIES)` ; \
rm -f $(DESTDIR)$(perlextdir)/"$$dlname"

## remove all generated content
maintainer-clean-local:
-rm -f $(SWIG_wrapper) $(PERL_MODULE)

distclean-local:
-rm -f $(SWIG_wrapper) $(PERL_MODULE)
11 changes: 11 additions & 0 deletions interfaces/Perl/version.i.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
%{
/** @file version.i.in
* @brief Set $RNAblueprint::VERSION to the bindings version
*/
%}

%perlcode %{
our $VERSION = '@PACKAGE_VERSION@';
sub VERSION () { $VERSION };
%}

22 changes: 0 additions & 22 deletions interfaces/Python/Makefile.am

This file was deleted.

5 changes: 5 additions & 0 deletions interfaces/Python2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RNAblueprint/
RNAblueprint_wrap.*
RNAblueprint.py
version.i
*.so
Loading

0 comments on commit 0153010

Please sign in to comment.