Commit 52776667 authored by Philipp  Trunschke's avatar Philipp Trunschke

add option to build python3 bindings

parent 521dd164
......@@ -142,11 +142,7 @@ warn:
# Fake rule to create arbitary headers, to prevent errors if files are moved/renamed
%.h:
ifdef BUILD_PYTHON_BINDINGS
shared: build/libxerus_misc.so build/libxerus.so build/xerus.so
else
shared: build/libxerus_misc.so build/libxerus.so
endif
build/libxerus_misc.so: $(MINIMAL_DEPS) $(MISC_SOURCES)
mkdir -p $(dir $@)
......@@ -157,11 +153,16 @@ build/libxerus.so: $(MINIMAL_DEPS) $(XERUS_SOURCES) build/libxerus_misc.so
$(CXX) -shared -fPIC -Wl,-soname,libxerus.so $(FLAGS) -I include $(XERUS_SOURCES) -L ./build/ -Wl,--as-needed -lxerus_misc $(SUITESPARSE) $(LAPACK_LIBRARIES) $(BLAS_LIBRARIES) -o build/libxerus.so
python: build/xerus.so
python: build/python2/xerus.so build/python3/xerus.so
build/python2/xerus.so: $(MINIMAL_DEPS) $(PYTHON_SOURCES) build/libxerus.so
mkdir -p $(dir $@)
$(CXX) -shared -fPIC -Wl,-soname,xerus.so `$(PYTHON2_CONFIG) --cflags --ldflags` $(PYTHON_FLAGS) -I include $(PYTHON_SOURCES) -L ./build/ -Wl,--as-needed -lxerus $(BOOST_PYTHON2) -o $@
build/xerus.so: $(MINIMAL_DEPS) $(PYTHON_SOURCES) build/libxerus.so
build/python3/xerus.so: $(MINIMAL_DEPS) $(PYTHON_SOURCES) build/libxerus.so
mkdir -p $(dir $@)
$(CXX) -shared -fPIC -Wl,-soname,xerus.so `python2-config --cflags --ldflags` $(PYTHON_FLAGS) -I include $(PYTHON_SOURCES) -L ./build/ -Wl,--as-needed -lxerus $(BOOST_PYTHON) -o build/xerus.so
@# -fpermissive is needed because of a bug in the definition of BOOST_PYTHON_MODULE_INIT in <boost/python/module_init.h>
$(CXX) -shared -fPIC -Wl,-soname,xerus.so `$(PYTHON3_CONFIG) --cflags --ldflags` $(PYTHON_FLAGS) -fpermissive -I include $(PYTHON_SOURCES) -L ./build/ -Wl,--as-needed -lxerus $(BOOST_PYTHON3) -o $@
static: build/libxerus_misc.a build/libxerus.a
......@@ -183,13 +184,12 @@ else
endif
ifdef DESTDIR
INSTALL_LIB_PATH = $(DESTDIR)/lib/
INSTALL_HEADER_PATH = $(DESTDIR)/include/
INSTALL_PYTHON_PATH = $(DESTDIR)/lib/python/site-packages/
ifdef INSTALL_PYTHON2_PATH
install: build/python2/xerus.so
endif
ifdef INSTALL_PYTHON3_PATH
install: build/python3/xerus.so
endif
ifdef INSTALL_LIB_PATH
ifdef INSTALL_HEADER_PATH
install: shared
......@@ -200,8 +200,13 @@ install: shared
cp -r include/xerus $(INSTALL_HEADER_PATH)
cp build/libxerus_misc.so $(INSTALL_LIB_PATH)
cp build/libxerus.so $(INSTALL_LIB_PATH)
ifdef BUILD_PYTHON_BINDINGS
cp build/xerus.so $(INSTALL_PYTHON_PATH)
ifdef INSTALL_PYTHON2_PATH
@printf "Installing xerus.so to $(strip $(INSTALL_PYTHON2_PATH)).\n"
cp build/python2/xerus.so $(INSTALL_PYTHON2_PATH)
endif
ifdef INSTALL_PYTHON3_PATH
@printf "Installing xerus.so to $(strip $(INSTALL_PYTHON3_PATH)).\n"
cp build/python3/xerus.so $(INSTALL_PYTHON3_PATH)
endif
else
install:
......
......@@ -5,6 +5,8 @@
# Set the CXX variable to the one you want to use.
CXX = g++
# CXX = clang++
PYTHON2_CONFIG = python2-config
PYTHON3_CONFIG = python3-config
#=================================================================================================
# C++ Version
......@@ -13,13 +15,6 @@ CXX = g++
# even C++17 in order to activated.
COMPATIBILITY = -std=c++11
#=================================================================================================
# Library Options
#=================================================================================================
# Xerus offers python bindings through boost python, which can be build in a seperate library object
# xerus.so
# BUILD_PYTHON_BINDINGS = TRUE
#=================================================================================================
# Optimization
......@@ -107,9 +102,10 @@ LOGGING += -D XERUS_LOG_INFO # Information that is not linke
#=================================================================================================
# Set the directories to install libxerus.
#INSTALL_LIB_PATH = /usr/local/lib64/ # Path where to install the libxerus.so shared library.
#INSTALL_HEADER_PATH = /usr/local/include/ # Path where to install the xerus header files.
#INSTALL_PYTHON_PATH = /usr/local/lib64/python2.7/site-packages/ # Path for the installation of the python bindings.
# INSTALL_LIB_PATH = /usr/local/lib/ # Path where to install the libxerus.so shared library.
# INSTALL_HEADER_PATH = /usr/local/include/ # Path where to install the xerus header files.
# INSTALL_PYTHON2_PATH = /usr/local/lib/python2.7/site-packages/ # Path for the installation of the python2 bindings.
# INSTALL_PYTHON3_PATH = /usr/local/lib/python3.5/site-packages/ # Path for the installation of the python3 bindings.
#=================================================================================================
......@@ -136,7 +132,8 @@ LAPACK_LIBRARIES = -llapacke -llapack # Standard Lapack +
SUITESPARSE = -lcholmod -lspqr
# Uncomment or add the appropriate boost python library
BOOST_PYTHON = -lboost_python
BOOST_PYTHON2 = -lboost_python-py27
BOOST_PYTHON3 = -lboost_python-py35
# Custom include paths
# OTHER += -I /path/to/include
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment