From eee5fe536591e96af67ad4bcd417d6c8b89e26bb Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 19 Jan 2016 14:25:03 +0100 Subject: Allow out-of-tree builds --- build/linux/Makefile.in | 67 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 30 deletions(-) (limited to 'build/linux') diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in index 01ef527..90f8801 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=$(srcdir)/../.. CPPFLAGS=@SAVED_CPPFLAGS@ CXXFLAGS=@SAVED_CXXFLAGS@ @@ -29,7 +32,7 @@ NVCCFLAGS=@SAVED_NVCCFLAGS@ LDFLAGS=@SAVED_LDFLAGS@ LIBS=@SAVED_LIBS@ -CPPFLAGS+=-I../.. -I../../include -I../../lib/include +CPPFLAGS+=-I$(srcdir)/../.. -I$(srcdir)/../../include -I$(srcdir)/../../lib/include CXXFLAGS+=-g -O3 -Wall -Wshadow LIBS+=-lpthread LDFLAGS+=-g @@ -38,7 +41,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@ @@ -59,7 +62,7 @@ CPPFLAGS += -DASTRA_PYTHON -I$(PYINCDIR) 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 @@ -78,6 +81,7 @@ MKDIR=mkdir -p CXX=@CXX@ LD=@CXX@ SHELL=@SHELL@ +INSTALL_SH=$(SHELL) $(srcdir)/install-sh ifeq ($(matlab),yes) MEXFLAGS = -cxx @@ -264,12 +268,12 @@ endif ifeq ($(python),yes) py: libastra.la - cd ../../python; CPPFLAGS="${PYCPPFLAGS}" LDFLAGS="${PYLDFLAGS}" $(PYTHON) builder.py install \ + cd $(srcdir)/../../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 python-root-install: libastra.la - cd ../../python; CPPFLAGS="${PYCPPFLAGS}" LDFLAGS="${PYLDFLAGS}" $(PYTHON) builder.py install + cd $(srcdir)/../../python; CPPFLAGS="${PYCPPFLAGS}" LDFLAGS="${PYLDFLAGS}" $(PYTHON) builder.py install endif @@ -331,33 +335,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 $(srcdir)/../../python/finalbuild/ + rm -fr $(srcdir)/../../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 +370,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 $(srcdir)/../../python/finalbuild/astra/*.so @prefix@/python/astra + $(INSTALL_SH) -m 644 $(srcdir)/../../python/finalbuild/astra/*.py @prefix@/python/astra + $(INSTALL_SH) -m 644 $(srcdir)/../../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 +385,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: -- cgit v1.2.3 From 61d95e4d4cabcc1da959ccf68588895862ec64c5 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 19 Jan 2016 15:54:08 +0100 Subject: Place Python build/temporary files in build directory This also allows out-of-tree builds for Python. --- build/linux/Makefile.in | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'build/linux') diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in index 90f8801..4f99db2 100644 --- a/build/linux/Makefile.in +++ b/build/linux/Makefile.in @@ -268,12 +268,15 @@ endif ifeq ($(python),yes) py: libastra.la - cd $(srcdir)/../../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 $(srcdir)/../../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 @@ -335,8 +338,8 @@ clean: rm -f $(addsuffix /*.d,$(DEPDIRS)) rm -f $(addsuffix /*,$(LIBDIRS)) rm -f $(TEST_OBJECTS) test.bin - rm -fr $(srcdir)/../../python/finalbuild/ - rm -fr $(srcdir)/../../python/build/ + rm -fr python/finalbuild/ + rm -fr python/build/ rm -f $(srcdir)/../../python/astra/*.cpp rm -f $(srcdir)/../../python/astra/*.c @@ -372,9 +375,9 @@ ifeq ($(python),yes) install-python: py $(INSTALL_SH) -m 755 -d @prefix@/python $(INSTALL_SH) -m 755 -d @prefix@/python/astra - $(INSTALL_SH) -m 644 $(srcdir)/../../python/finalbuild/astra/*.so @prefix@/python/astra - $(INSTALL_SH) -m 644 $(srcdir)/../../python/finalbuild/astra/*.py @prefix@/python/astra - $(INSTALL_SH) -m 644 $(srcdir)/../../python/finalbuild/*.egg-info @prefix@/python/ + $(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." -- cgit v1.2.3 From 2d2be13aa9dcfc77afed1dbe52c78e5dce5a04fa Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 19 Jan 2016 17:06:57 +0100 Subject: Fail when python six module is not found --- build/linux/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'build/linux') diff --git a/build/linux/configure.ac b/build/linux/configure.ac index 684a4c5..354bccc 100644 --- a/build/linux/configure.ac +++ b/build/linux/configure.ac @@ -213,7 +213,7 @@ 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) -- cgit v1.2.3 From 5c33826855a8d88889cdbbfc78b27c86549715d5 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 20 Jan 2016 13:02:36 +0100 Subject: Add check for scipy The module matrix_c.pyx uses it. --- build/linux/configure.ac | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'build/linux') diff --git a/build/linux/configure.ac b/build/linux/configure.ac index 354bccc..5a04509 100644 --- a/build/linux/configure.ac +++ b/build/linux/configure.ac @@ -219,6 +219,13 @@ assert(LooseVersion(Cython.__version__)>=LooseVersion("0.13")) 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) -- cgit v1.2.3 From 5e3bcf20be6188331c856d9d8854fb931b2abba7 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 20 Jan 2016 14:34:00 +0100 Subject: Avoid incorrect include dirs when building python modules --- build/linux/Makefile.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'build/linux') diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in index 4f99db2..c165d37 100644 --- a/build/linux/Makefile.in +++ b/build/linux/Makefile.in @@ -32,7 +32,6 @@ NVCCFLAGS=@SAVED_NVCCFLAGS@ LDFLAGS=@SAVED_LDFLAGS@ LIBS=@SAVED_LIBS@ -CPPFLAGS+=-I$(srcdir)/../.. -I$(srcdir)/../../include -I$(srcdir)/../../lib/include CXXFLAGS+=-g -O3 -Wall -Wshadow LIBS+=-lpthread LDFLAGS+=-g @@ -59,7 +58,7 @@ 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$(abs_top_builddir)/.libs @@ -67,6 +66,10 @@ 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= -- cgit v1.2.3 From 29c5c86e56697286a92031aaa9fdd903b3bcc426 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 20 Jan 2016 16:18:05 +0100 Subject: Use nvcc's -MT option --- build/linux/Makefile.in | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'build/linux') diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in index c165d37..12c9e2b 100644 --- a/build/linux/Makefile.in +++ b/build/linux/Makefile.in @@ -303,10 +303,8 @@ ifeq ($(cuda),yes) @$(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 + @# Generate a .d file, with target name $*.lo + @$(NVCC) $(NVCCFLAGS) -M $(<) -MT $(*F).lo -odir $(*D) -o $(*D)/$(DEPDIR)/$(*F).d @# Generate a fake libtool .lo file @echo "# $*.lo - a libtool object file" > $*.lo @echo "# Generated by" `./libtool --version | head -n 1` >> $*.lo -- cgit v1.2.3 From b428366389ecdad457fb04e13857902e11585881 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 20 Jan 2016 16:18:08 +0100 Subject: Try to improve nvcc dependency file generation We now append empty targets for all dependencies listed in the .d file generated by nvcc. This mimics the behaviour of gcc's -MP option, and prevents deleted header files from breaking the build. --- build/linux/Makefile.in | 3 +++ 1 file changed, 3 insertions(+) (limited to 'build/linux') diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in index 12c9e2b..f556066 100644 --- a/build/linux/Makefile.in +++ b/build/linux/Makefile.in @@ -305,6 +305,9 @@ ifeq ($(cuda),yes) @$(NVCC) $(NVCCFLAGS) -c $(<) -Xcompiler -fPIC -DPIC -o $(*D)/.libs/$(*F).o >/dev/null 2>&1 @# 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 -- cgit v1.2.3 From 8fecf27e5eba5e89d9212c2235e957a64e58ec22 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 20 Jan 2016 16:38:01 +0100 Subject: Don't build cuda non-PIC object if static libs are disabled This significantly speeds up builds since we usually pass disable-static to libtool. --- build/linux/Makefile.in | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'build/linux') diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in index f556066..8398e35 100644 --- a/build/linux/Makefile.in +++ b/build/linux/Makefile.in @@ -295,14 +295,18 @@ 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 + $(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. @@ -319,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 -- cgit v1.2.3 From 6a7eaf9c8fee52e01e7a48cd7e4630453c033655 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 21 Jan 2016 11:29:53 +0100 Subject: Fix VPATH problem with older autoconf versions --- build/linux/Makefile.in | 2 +- build/linux/configure.ac | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'build/linux') diff --git a/build/linux/Makefile.in b/build/linux/Makefile.in index 8398e35..3018674 100644 --- a/build/linux/Makefile.in +++ b/build/linux/Makefile.in @@ -24,7 +24,7 @@ exec_prefix=@exec_prefix@ srcdir=@srcdir@ abs_top_builddir=@abs_top_builddir@ -VPATH=$(srcdir)/../.. +VPATH=@VPATH_SRCDIR@/../.. CPPFLAGS=@SAVED_CPPFLAGS@ CXXFLAGS=@SAVED_CXXFLAGS@ diff --git a/build/linux/configure.ac b/build/linux/configure.ac index 5a04509..630b08d 100644 --- a/build/linux/configure.ac +++ b/build/linux/configure.ac @@ -243,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: -- cgit v1.2.3