summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <wjp@usecode.org>2016-01-21 13:24:11 +0100
committerWillem Jan Palenstijn <wjp@usecode.org>2016-01-21 13:24:11 +0100
commitcd12edcd3ada212f27088a4e26e3eee5f89bcbad (patch)
treeee441dc41b25ac6fc7ad0b835917984fc4148187 /build
parentd6c0f64358a75565e70905d11c47511329ec3c53 (diff)
parent6a7eaf9c8fee52e01e7a48cd7e4630453c033655 (diff)
downloadastra-cd12edcd3ada212f27088a4e26e3eee5f89bcbad.tar.gz
astra-cd12edcd3ada212f27088a4e26e3eee5f89bcbad.tar.bz2
astra-cd12edcd3ada212f27088a4e26e3eee5f89bcbad.tar.xz
astra-cd12edcd3ada212f27088a4e26e3eee5f89bcbad.zip
Merge pull request #110 from wjp/build
Build system improvements
Diffstat (limited to 'build')
-rw-r--r--build/linux/Makefile.in100
-rw-r--r--build/linux/configure.ac15
2 files changed, 75 insertions, 40 deletions
diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in
index 01ef527..3018674 100644
--- a/build/linux/Makefile.in
+++ b/build/linux/Makefile.in
@@ -21,7 +21,10 @@ all: $(TARGETS)
prefix=@prefix@
exec_prefix=@exec_prefix@
-VPATH=../..
+srcdir=@srcdir@
+abs_top_builddir=@abs_top_builddir@
+
+VPATH=@VPATH_SRCDIR@/../..
CPPFLAGS=@SAVED_CPPFLAGS@
CXXFLAGS=@SAVED_CXXFLAGS@
@@ -29,7 +32,6 @@ NVCCFLAGS=@SAVED_NVCCFLAGS@
LDFLAGS=@SAVED_LDFLAGS@
LIBS=@SAVED_LIBS@
-CPPFLAGS+=-I../.. -I../../include -I../../lib/include
CXXFLAGS+=-g -O3 -Wall -Wshadow
LIBS+=-lpthread
LDFLAGS+=-g
@@ -38,7 +40,7 @@ CPPFLAGS+=@CPPFLAGS_OS@
ifeq ($(cuda),yes)
CPPFLAGS += @CPPFLAGS_CUDA@ -DASTRA_CUDA
-NVCCFLAGS += @NVCCFLAGS_EXTRA@ @CPPFLAGS_CUDA@ -I../.. -I../../include -DASTRA_CUDA
+NVCCFLAGS += @NVCCFLAGS_EXTRA@ @CPPFLAGS_CUDA@ -I$(srcdir)/../.. -I$(srcdir)/../../include -DASTRA_CUDA
LDFLAGS += @LDFLAGS_CUDA@
LIBS += -lcudart -lcufft
NVCC = @NVCC@
@@ -56,14 +58,18 @@ PYLIBDIR = $(shell $(PYTHON) -c 'from distutils.sysconfig import get_config_var;
PYINCDIR = $(shell $(PYTHON) -c 'from distutils.sysconfig import get_python_inc; import six; six.print_(get_python_inc())')
PYLIBVER = `basename $(PYINCDIR)`
CPPFLAGS += -DASTRA_PYTHON -I$(PYINCDIR)
-PYCPPFLAGS = $(CPPFLAGS)
+PYCPPFLAGS := $(CPPFLAGS)
PYCPPFLAGS += -I../include
PYLDFLAGS = $(LDFLAGS)
-PYLDFLAGS += -L../build/linux/.libs
+PYLDFLAGS += -L$(abs_top_builddir)/.libs
LIBS += -l$(PYLIBVER)
LDFLAGS += -L$(PYLIBDIR)
endif
+# This is below where PYCPPFLAGS copies CPPFLAGS. The python code is built
+# from a different directory, so these relative includes would be wrong.
+CPPFLAGS+=-I$(srcdir)/../.. -I$(srcdir)/../../include -I$(srcdir)/../../lib/include
+
BOOST_CPPFLAGS=
BOOST_LDFLAGS=
@@ -78,6 +84,7 @@ MKDIR=mkdir -p
CXX=@CXX@
LD=@CXX@
SHELL=@SHELL@
+INSTALL_SH=$(SHELL) $(srcdir)/install-sh
ifeq ($(matlab),yes)
MEXFLAGS = -cxx
@@ -264,12 +271,15 @@ endif
ifeq ($(python),yes)
py: libastra.la
- cd ../../python; CPPFLAGS="${PYCPPFLAGS}" LDFLAGS="${PYLDFLAGS}" $(PYTHON) builder.py install \
- --install-base=./finalbuild --install-headers=./finalbuild --install-purelib=./finalbuild \
- --install-platlib=./finalbuild --install-scripts=./finalbuild --install-data=./finalbuild
+ $(MKDIR) python/build
+ $(MKDIR) python/finalbuild
+ cd $(srcdir)/../../python; CPPFLAGS="${PYCPPFLAGS}" LDFLAGS="${PYLDFLAGS}" $(PYTHON) builder.py build --build-base=$(abs_top_builddir)/python/build install \
+ --install-base=$(abs_top_builddir)/python/finalbuild --install-headers=$(abs_top_builddir)/python/finalbuild --install-purelib=$(abs_top_builddir)/python/finalbuild \
+ --install-platlib=$(abs_top_builddir)/python/finalbuild --install-scripts=$(abs_top_builddir)/python/finalbuild --install-data=$(abs_top_builddir)/python/finalbuild
python-root-install: libastra.la
- cd ../../python; CPPFLAGS="${PYCPPFLAGS}" LDFLAGS="${PYLDFLAGS}" $(PYTHON) builder.py install
+ $(MKDIR) python/build
+ cd $(srcdir)/../../python; CPPFLAGS="${PYCPPFLAGS}" LDFLAGS="${PYLDFLAGS}" $(PYTHON) builder.py build --build-base=$(abs_top_builddir)/python/build install
endif
@@ -285,18 +295,23 @@ libastra.la: $(ALL_OBJECTS)
$(MKDIR) $(*D)/$(DEPDIR)
./libtool --mode=compile --tag=CXX $(CXX) -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP $(CXXFLAGS) $(CPPFLAGS) -c $(<) -o $*.o
+gen_static_libs := `./libtool --features | grep -q 'disable static' && echo no || echo yes`
+
ifeq ($(cuda),yes)
%.lo: %.cu
@# Behave like libtool: compile both a PIC and a non-PIC object file
@$(MKDIR) $(*D)
- $(NVCC) $(NVCCFLAGS) -c $(<) -o $*.o
@$(MKDIR) $(*D)/.libs
@$(MKDIR) $(*D)/$(DEPDIR)
- @$(NVCC) $(NVCCFLAGS) -c $(<) -Xcompiler -fPIC -DPIC -o $(*D)/.libs/$(*F).o >/dev/null 2>&1
- @# Generate a .d file, and change the target name in it from .o to .lo
- @$(NVCC) $(NVCCFLAGS) -M $(<) -odir $(*D) -o $(*D)/$(DEPDIR)/$(*F).d2
- @sed '1s/\.o :/.lo :/' < $(*D)/$(DEPDIR)/$(*F).d2 > $(*D)/$(DEPDIR)/$(*F).d
- @rm -f $(*D)/$(DEPDIR)/$(*F).d2
+ $(NVCC) $(NVCCFLAGS) -c $(<) -Xcompiler -fPIC -DPIC -o $(*D)/.libs/$(*F).o
+ifeq ($(gen_static_libs),yes)
+ @$(NVCC) $(NVCCFLAGS) -c $(<) -o $*.o >/dev/null 2>&1
+endif
+ @# Generate a .d file, with target name $*.lo
+ @$(NVCC) $(NVCCFLAGS) -M $(<) -MT $(*F).lo -odir $(*D) -o $(*D)/$(DEPDIR)/$(*F).d
+ @# Generate empty targets for all dependencies listed in the .d file.
+ @# This mimics gcc's -MP option.
+ @for x in `cat $(*D)/$(DEPDIR)/$(*F).d`; do if test a$$x != a: -a a$$x != a\\; then echo -e "\n$$x:\n" >> $(*D)/$(DEPDIR)/$(*F).d; fi; done
@# Generate a fake libtool .lo file
@echo "# $*.lo - a libtool object file" > $*.lo
@echo "# Generated by" `./libtool --version | head -n 1` >> $*.lo
@@ -308,7 +323,11 @@ ifeq ($(cuda),yes)
@echo "pic_object='.libs/$(*F).o'" >> $*.lo
@echo >> $*.lo
@echo "# Name of the non-PIC object." >> $*.lo
+ifeq ($(gen_static_libs),yes)
@echo "non_pic_object='$(*F).o'" >> $*.lo
+else
+ @echo "non_pic_object=none" >> $*.lo
+endif
@# Remove generated .linkinfo file
@rm -f $(*F).linkinfo
endif
@@ -331,33 +350,33 @@ clean:
rm -f $(addsuffix /*.d,$(DEPDIRS))
rm -f $(addsuffix /*,$(LIBDIRS))
rm -f $(TEST_OBJECTS) test.bin
- rm -fr ../../python/finalbuild/
- rm -fr ../../python/build/
- rm -f ../../python/astra/*.cpp
- rm -f ../../python/astra/*.c
+ rm -fr python/finalbuild/
+ rm -fr python/build/
+ rm -f $(srcdir)/../../python/astra/*.cpp
+ rm -f $(srcdir)/../../python/astra/*.c
distclean: clean
- rm -f config.guess config.sub ltmain.sh libtool install-sh
+ rm -f $(srcdir)/config.guess $(srcdir)/config.sub $(srcdir)/ltmain.sh libtool $(srcdir)/install-sh
rm -f config.log config.status
- rm -f aclocal.m4
- rm -rf autom4te.cache
- rm -f configure Makefile
+ rm -f $(srcdir)/aclocal.m4
+ rm -rf $(srcdir)/autom4te.cache
+ rm -f $(srcdir)/configure Makefile
install: install-libraries install-matlab install-python
install-libraries: libastra.la
- ./install-sh -m 755 -d @libdir@
- ./libtool --mode=install ./install-sh -m 644 libastra.la @libdir@
+ $(INSTALL_SH) -m 755 -d @libdir@
+ ./libtool --mode=install $(INSTALL_SH) -m 644 libastra.la @libdir@
./libtool --mode=finish @libdir@
ifeq ($(matlab),yes)
# TODO: This install location doesn't work well for /usr or /usr/local
install-matlab: $(MATLAB_MEX)
- ./install-sh -m 755 -d @prefix@/matlab
- ./install-sh -m 755 -d @prefix@/matlab/mex
- ./install-sh -m 755 -d @prefix@/matlab/tools
- ./install-sh -m 644 $(MATLAB_MEX) @prefix@/matlab/mex
- ./install-sh -m 644 ../../matlab/tools/*.m @prefix@/matlab/tools
+ $(INSTALL_SH) -m 755 -d @prefix@/matlab
+ $(INSTALL_SH) -m 755 -d @prefix@/matlab/mex
+ $(INSTALL_SH) -m 755 -d @prefix@/matlab/tools
+ $(INSTALL_SH) -m 644 $(MATLAB_MEX) @prefix@/matlab/mex
+ $(INSTALL_SH) -m 644 $(srcdir)/../../matlab/tools/*.m @prefix@/matlab/tools
# TODO: docs
else
install-matlab:
@@ -366,11 +385,11 @@ endif
ifeq ($(python),yes)
# TODO: This install location doesn't work well for /usr or /usr/local
install-python: py
- ./install-sh -m 755 -d @prefix@/python
- ./install-sh -m 755 -d @prefix@/python/astra
- ./install-sh -m 644 ../../python/finalbuild/astra/*.so @prefix@/python/astra
- ./install-sh -m 644 ../../python/finalbuild/astra/*.py @prefix@/python/astra
- ./install-sh -m 644 ../../python/finalbuild/*.egg-info @prefix@/python/
+ $(INSTALL_SH) -m 755 -d @prefix@/python
+ $(INSTALL_SH) -m 755 -d @prefix@/python/astra
+ $(INSTALL_SH) -m 644 python/finalbuild/astra/*.so @prefix@/python/astra
+ $(INSTALL_SH) -m 644 python/finalbuild/astra/*.py @prefix@/python/astra
+ $(INSTALL_SH) -m 644 python/finalbuild/*.egg-info @prefix@/python/
@echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
@echo "To use ASTRA in Python, add @prefix@/python/ to your PYTHONPATH"
@echo "and @libdir@ to your LD_LIBRARY_PATH."
@@ -381,18 +400,21 @@ install-python:
endif
-Makefile: Makefile.in config.status
+Makefile: $(srcdir)/Makefile.in config.status
CONFIG_HEADERS= CONFIG_LINKS= CONFIG_FILES=$@ $(SHELL) ./config.status
-config.status: configure
+config.status: $(srcdir)/configure
@echo "configure script has changed. Re-running it with last parameters"
$(SHELL) ./config.status --recheck
-configure: configure.ac
+$(srcdir)/configure: $(srcdir)/configure.ac
@echo "configure.ac has been changed. Regenerating configure script"
- $(SHELL) ./autogen.sh
+ cd $(srcdir) && $(SHELL) ./autogen.sh
.PHONY: all mex test clean distclean install install-libraries
# don't remove intermediate files:
.SECONDARY:
+
+# disable all implicit built-in rules
+.SUFFIXES:
diff --git a/build/linux/configure.ac b/build/linux/configure.ac
index 684a4c5..630b08d 100644
--- a/build/linux/configure.ac
+++ b/build/linux/configure.ac
@@ -213,12 +213,19 @@ assert(LooseVersion(Cython.__version__)>=LooseVersion("0.13"))
fi
AC_MSG_RESULT(yes)
AC_MSG_CHECKING(for six module)
- ASTRA_TRY_PYTHON([import six])
+ ASTRA_TRY_PYTHON([import six],,HAVEPYTHON=no)
if test x$HAVEPYTHON = xno; then
AC_MSG_RESULT(no)
AC_MSG_ERROR(You need the six module to use the ASTRA toolbox in Python)
fi
AC_MSG_RESULT(yes)
+ AC_MSG_CHECKING(for scipy module)
+ ASTRA_TRY_PYTHON([import scipy],,HAVEPYTHON=no)
+ if test x$HAVEPYTHON = xno; then
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR(You need the scipy module to use the ASTRA toolbox in Python)
+ fi
+ AC_MSG_RESULT(yes)
fi
AC_SUBST(HAVEPYTHON)
@@ -236,6 +243,12 @@ esac
AC_SUBST(CPPFLAGS_OS)
+# For some reason, some older versions of autoconf produce a config.status
+# that disables all lines looking like VPATH=@srcdir@
+# (More recent autoconf fixes the too broad matching there.)
+# We use a different variable name as a workaround.
+VPATH_SRCDIR="$srcdir"
+AC_SUBST(VPATH_SRCDIR)
# TODO: