diff --git a/Makefile.am b/Makefile.am index 1e81ff2..ca6e761 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,23 +1,12 @@ -include ./etc/make/emacs.mk +include $(top_srcdir)/etc/make/emacs.mk +include $(top_srcdir)/atrip.mk SUBDIRS = src bench -if WITH_BUILD_CTF -CTF_COMMIT = 968f8f9eb6aab1d6b67d2fcc1a70c9fc3b98adfa -CTF_GIT_REPOSITORY = https://github.com/cc4s/ctf -CTF_BUILD_PATH = $(builddir)/extern/build/$(CONFIG)/ctf/$(CTF_COMMIT) -CTF_SRC_PATH = $(builddir)/extern/src/$(CONFIG)/ctf/$(CTF_COMMIT) -include $(srcdir)/etc/make/ctf.mk -src: ctf -SUBDIRS += extern/ctf/ -endif _ATRIPSRCS = Sources.mk -## include $(_ATRIPSRCS) ORG_MAIN = atrip.org -ATRIP_SHARED_LIBRARY = lib/$(CONFIG)/libatrip.so -ATRIP_STATIC_LIBRARY = lib/$(CONFIG)/libatrip.a tangle: $(ORG_MAIN) $(call tangle,$<) diff --git a/atrip.mk b/atrip.mk index b2d901a..8b88c96 100644 --- a/atrip.mk +++ b/atrip.mk @@ -1,8 +1,9 @@ -ATRIP_ROOT := $(abspath $(PWD)) -CXXFLAGS += -I$(ATRIP_ROOT)/include +if WITH_BUILD_CTF CTF_COMMIT = 968f8f9eb6aab1d6b67d2fcc1a70c9fc3b98adfa CTF_GIT_REPOSITORY = https://github.com/cc4s/ctf -CTF_BUILD_PATH = $(ATRIP_ROOT)/extern/build/$(CONFIG)/ctf/$(CTF_COMMIT) -CTF_SRC_PATH = $(ATRIP_ROOT)/extern/src/$(CONFIG)/ctf/$(CTF_COMMIT) -CXXFLAGS += -I$(CTF_BUILD_PATH)/include +CTF_BUILD_PATH = $(top_builddir)/extern/build/ctf/$(CTF_COMMIT) +CTF_SRC_PATH = $(top_builddir)/extern/src/ctf/$(CTF_COMMIT) +CTF_CPPFLAGS = -I$(CTF_BUILD_PATH)/include +include $(top_srcdir)/etc/make/ctf.mk +endif diff --git a/bench/Makefile.am b/bench/Makefile.am index 56fc654..94cc72e 100644 --- a/bench/Makefile.am +++ b/bench/Makefile.am @@ -1,12 +1,20 @@ -AM_LDFLAGS = -fopenmp -AM_CPPFLAGS = -I$(top_srcdir)/include/ +include $(top_srcdir)/atrip.mk + +AM_CPPFLAGS = -I$(top_srcdir)/include/ $(CTF_CPPFLAGS) +AM_LDFLAGS = -lgomp bin_PROGRAMS = test_main test_main_SOURCES = test_main.cxx -test_main_LDADD = \ --lopenblas \ --lscalapack \ -@LIBCTF_LD_LIBRARY_PATH@/libctf.a \ -$(top_builddir)/src/libatrip.a + +test_main_LDADD = \ + -lopenblas \ + -lscalapack \ + $(top_builddir)/src/libatrip.a + +if WITH_BUILD_CTF +test_main_LDADD += $(CTF_BUILD_PATH)/lib/libctf.a +else +test_main_LDADD += @LIBCTF_LD_LIBRARY_PATH@/libctf.a +endif diff --git a/configure.ac b/configure.ac index a8e962c..c004015 100644 --- a/configure.ac +++ b/configure.ac @@ -26,11 +26,11 @@ dnl LIBGC library options AC_ARG_WITH(libctf-prefix, AS_HELP_STRING([--with-libctf-prefix=path], [prefix for CTF includes and libraries] ), - [LIBCTF_CPATH="`readlink -f $withval`/include"; - LIBCTF_LD_LIBRARY_PATH="`readlink -f $withval`/lib"; - BUILD_CTF=NO], + [LIBCTF_PATH="`readlink -f $withval`"; + LIBCTF_CPATH="`readlink -f $withval`/include"; + LIBCTF_LD_LIBRARY_PATH="`readlink -f $withval`/lib"; + BUILD_CTF=NO], [BUILD_CTF=YES]) -AM_CONDITIONAL([WITH_BUILD_CTF], [test x${BUILD_CTF} = xYES]) AC_ARG_WITH([clang-check], [AS_HELP_STRING([--with-clang-check], @@ -54,6 +54,8 @@ dnl AC_ARG_VAR([ecldir], [the directory where *.fas files are installed]) ATRIP_LDFLAGS="-L$PWD/src -latrip" AC_SUBST(ATRIP_LDFLAGS) +AM_CONDITIONAL([WITH_BUILD_CTF], [test x${BUILD_CTF} = xYES]) +AC_SUBST(LIBCTF_PATH) AC_SUBST(LIBCTF_CPATH) AC_SUBST(LIBCTF_LD_LIBRARY_PATH) @@ -71,10 +73,15 @@ AC_PROG_LN_S dnl sets variable LN_S AC_PROG_MAKE_SET dnl set $(MAKE) if needed AC_PROG_RANLIB dnl set variable RANLIB AC_CHECK_TOOL([AR],[ar]) dnl set variable AR to appropriate `ar' program +AC_OPENMP AC_TYPE_SIZE_T AC_FUNC_MALLOC + +AX_BLAS([], [AC_MSG_FAILURE([Could not find BLAS library.])]) +AX_LAPACK([], [AC_MSG_FAILURE([Could not find LAPACK library.])]) + AX_CXX_COMPILE_STDCXX([11]) AX_CXX_STATIC_CAST AX_CXX_TEMPLATES diff --git a/etc/make/ctf.mk b/etc/make/ctf.mk index f4d43e5..7595ceb 100644 --- a/etc/make/ctf.mk +++ b/etc/make/ctf.mk @@ -1,4 +1,4 @@ -CTF_CONFIG_FLAGS = +CTF_CONFIG_FLAGS = CXX="$(CXX)" LIB_PATH="$(LDFLAGS)" CXXFLAGS="$(CXXFLAGS)" --no-dynamic CTF_STATIC_LIB = $(CTF_BUILD_PATH)/lib/libctf.a CTF_SHARED_LIB = $(CTF_BUILD_PATH)/lib/libctf.so CTF_GIT_REPOSITORY ?= https://github.com/cyclops-community/ctf @@ -10,7 +10,9 @@ $(CTF_SRC_PATH)/configure: $(CTF_BUILD_PATH)/Makefile: $(CTF_SRC_PATH)/configure mkdir -p $(CTF_BUILD_PATH) - cd $(CTF_BUILD_PATH) && $(abspath $(CTF_SRC_PATH))/configure $(CTF_CONFIG_FLAGS) + cd $(CTF_BUILD_PATH) && \ + $(abspath $(CTF_SRC_PATH))/configure $(CTF_CONFIG_FLAGS) + $(CTF_STATIC_LIB): $(CTF_BUILD_PATH)/Makefile $(info Compiling $@) diff --git a/shell.nix b/shell.nix index 3f5c456..0ab5258 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,4 @@ -{ pkgs ? import {} , with-clang ? false , with-mkl ? false }: +{ compiler, pkgs ? import {} , with-mkl ? false }: let @@ -10,14 +10,23 @@ let clang = import ./etc/nix/clang.nix { inherit pkgs; }; - compiler-configuration - = if with-clang - then clang.buildInputs - else [ pkgs.gcc ]; - in -pkgs.mkShell { +pkgs.mkShell rec { + + compiler-pkg + = if compiler == "gcc11" then pkgs.gcc11 + else if compiler == "gcc10" then pkgs.gcc10 + else if compiler == "gcc9" then pkgs.gcc9 + else if compiler == "gcc8" then pkgs.gcc8 + else if compiler == "gcc7" then pkgs.gcc7 + else if compiler == "gcc6" then pkgs.gcc6 + else if compiler == "clang13" then pkgs.clang_13 + else if compiler == "clang12" then pkgs.clang_12 + else if compiler == "clang11" then pkgs.clang_11 + else if compiler == "clang10" then pkgs.clang_10 + else if compiler == "clang9" then pkgs.clang_9 + else pkgs.gcc; buildInputs = with pkgs; [ @@ -26,6 +35,7 @@ pkgs.mkShell { git openmpi + llvmPackages.openmp binutils emacs @@ -36,13 +46,22 @@ pkgs.mkShell { automake pkg-config ] - ++ compiler-configuration ++ (if with-mkl then mkl.buildInputs else openblas.buildInputs) ; + CXX = "${compiler-pkg}/bin/c++"; + CC = "${compiler-pkg}/bin/cc"; + LD = "${compiler-pkg}/bin/ld"; + shellHook - = (if with-clang then clang.shellHook else "") - + (if with-mkl then mkl.shellHook else openblas.shellHook) + = #(if with-mkl then mkl.shellHook else openblas.shellHook) + '' + export OMPI_CXX=${CXX} + export OMPI_CC=${CC} + CXX=${CXX} + CC=${CC} + LD=${LD} + '' ; } diff --git a/src/Makefile.am b/src/Makefile.am index e15f5dd..0ce98d1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,7 @@ AUTOMAKE_OPTIONS = subdir-objects +include $(top_srcdir)/atrip.mk -AM_CXXFLAGS = -Wall --pedantic +AM_CXXFLAGS = -Wall --pedantic $(CTF_CPPFLAGS) lib_LIBRARIES = libatrip.a