diff --git a/Makefile.in b/Makefile.in index 0753232..d1ad62b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -51,7 +51,7 @@ $(distdir): $(qmckl_h) $(qmckl_f) $(static_lib) $(shared_lib) $(srcdir)/src/Make cp $(srcdir)/munit/munit.h munit/munit.c $(distdir)/munit/ cp $(srcdir)/src/*.c src/*.h src/*.f90 $(distdir)/src/ cp $(srcdir)/src/Makefile.generated.in $(distdir)/src/Makefile.in - cp $(srcdir)/config.h.in $(distdir)/config.h.in + cp $(srcdir)/include/config.h.in $(distdir)/include/config.h.in cp $(qmckl_h) $(distdir)/include cp $(srcdir)/Makefile.in $(distdir)/ cp $(srcdir)/share/doc/qmckl/html/*.html $(distdir)/share/doc/qmckl/html/ diff --git a/autogen.sh b/autogen.sh index dd62ab2..0670857 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,5 +1,6 @@ #!/bin/bash autoreconf --install -automake --add-missing --copy > /dev/null 2>&1 +automake --add-missing --copy &> /dev/null +exit 0 diff --git a/configure.ac b/configure.ac index dfe5344..456e560 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,7 @@ AC_INIT([QMCkl],[0.1.1], [https://trex-coe.github.io/qmckl/index.html]) AC_CONFIG_SRCDIR([src/README.org]) -AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_HEADERS([include/config.h]) AC_CONFIG_MACRO_DIR([m4]) #AM_MAINTAINER_MODE @@ -40,6 +40,7 @@ AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_CC_C99 AC_CHECK_PROGS([EMACS],[emacs26 emacs],[no]) +AC_CHECK_PROGS([HAS_CPPCHECK],[cppcheck],[no]) PKG_PROG_PKG_CONFIG() PKG_LIBS="" PKG_CFLAGS="" @@ -52,6 +53,13 @@ if test x${EMACS} == xno ; then ]) fi +if test x${HAS_CPPCHECK} == xno ; then + HAS_CPPCHECK=0 +else + HAS_CPPCHECK=1 +fi +AC_SUBST([HAS_CPPCHECK]) + # fPIC option AC_MSG_CHECKING(whether fPIC compiler option is accepted in C) SAVED_CFLAGS="${CFLAGS}" @@ -120,22 +128,26 @@ if test "$ok" = "yes"; then -traceback -check all -debug all -fpe-all=0 -implicitnone" fi AC_DEFINE(DEBUG,1,[Define to turn on debugging checks]) + ARGS="${ARGS} debug" fi -AC_ARG_ENABLE(debug-malloc, [AC_HELP_STRING([--enable-debug-malloc],[use debug malloc/free])], ok=$enableval, ok=no) +AC_ARG_ENABLE(malloc-trace, [AC_HELP_STRING([--enable-malloc-trace],[use debug malloc/free])], ok=$enableval, ok=no) if test "$ok" = "yes"; then - AC_DEFINE(DEBUG_MALLOC,1,[Define to use debugging malloc/free]) + AC_DEFINE(MALLOC_TRACE,"malloc_trace.dat",[Define to use debugging malloc/free]) + ARGS="${ARGS} malloc-trace" fi AC_ARG_ENABLE(prof, [AC_HELP_STRING([--enable-prof],[compile for profiling])], ok=$enableval, ok=no) if test "$ok" = "yes"; then CFLAGS="${CFLAGS} -pg" AC_DEFINE(ENABLE_PROF,1,[Define when using the profiler tool]) + ARGS="${ARGS} prof" fi AC_ARG_WITH(efence, [AC_HELP_STRING([--with-efence],[use ElectricFence library])], ok=$withval, ok=no) if test "$ok" = "yes"; then AC_CHECK_LIB(efence, malloc) + ARGS="${ARGS} efence" fi AC_ARG_WITH(munit, [AC_HELP_STRING([--without-munit],[use munit for testing])], ok=yes, ok=no) @@ -147,9 +159,9 @@ AC_CHECK_FILE([munit/munit.h], [], $ git submodule update --init ------------------------------------------------- ]) ) - - AC_DEFINE(ENABLE_MUNIT,1,[Define when using munit]) - HAVE_MUNIT=1 +else + ARGS="${ARGS} munit" + AC_DEFINE(HAVE_MUNIT,1,[Define when using munit]) fi @@ -223,7 +235,7 @@ LDFLAGS: ${LDFLAGS} LIBS: ${LIBS} Package features: - Compilation with HDF5: ${hdf5} + ${ARGS} Now type 'make @<:@@:>@' where the optional is: diff --git a/config.h.in b/include/config.h.in similarity index 98% rename from config.h.in rename to include/config.h.in index a044e0d..577aca2 100644 --- a/config.h.in +++ b/include/config.h.in @@ -1,14 +1,8 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ +/* include/config.h.in. Generated from configure.ac by autoheader. */ /* Define to turn on debugging checks */ #undef DEBUG -/* Define to use debugging malloc/free */ -#undef DEBUG_MALLOC - -/* Define when using munit */ -#undef ENABLE_MUNIT - /* Define when using the profiler tool */ #undef ENABLE_PROF @@ -80,6 +74,9 @@ /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET +/* Define when using munit */ +#undef HAVE_MUNIT + /* Define to 1 if you have the `nl_langinfo' function. */ #undef HAVE_NL_LANGINFO @@ -150,6 +147,9 @@ /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL +/* Define to use debugging malloc/free */ +#undef MALLOC_TRACE + /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O diff --git a/src/Makefile.generated.in b/src/Makefile.generated.in index 742c527..3ba9e42 100644 --- a/src/Makefile.generated.in +++ b/src/Makefile.generated.in @@ -6,8 +6,11 @@ version = @PACKAGE_VERSION@ prefix = @prefix@ -CC = @CC@ -CFLAGS= @CFLAGS@ -I../munit/ -I../include +CC = @CC@ +DEFS = @DEFS@ +CFLAGS = @CFLAGS@ -I../munit/ -I../include -I. -I$(srcdir) +CPPFLAGS = @CPPFLAGS@ +LIBS = @LIBS@ FC = @FC@ FCFLAGS= @FCFLAGS@ @@ -20,7 +23,7 @@ TESTS_F = test_qmckl_ao_f.o test_qmckl_distance_f.o LIBS = @LIBS@ FCLIBS = @FCLIBS@ -QMCKL_ROOT=$(shell dirname $(CURDIR)) +QMCKL_ROOT=.. shared_lib=$(QMCKL_ROOT)/lib/libqmckl.so static_lib=$(QMCKL_ROOT)/lib/libqmckl.a qmckl_h=$(QMCKL_ROOT)/include/qmckl.h @@ -55,12 +58,13 @@ qmckl_f.o: $(qmckl_f) $(FC) $(FCFLAGS) -c $(qmckl_f) -o $@ test_qmckl: test_qmckl.c $(qmckl_h) $(static_lib) $(TESTS) $(TESTS_F) - $(CC) $(CFLAGS) $(munit) $(TESTS) $(TESTS_F) $(static_lib) $(LIBS) \ - $(FCLIBS) test_qmckl.c -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(munit) $(TESTS) $(TESTS_F) \ + $(static_lib) $(LIBS) $(FCLIBS) test_qmckl.c -o $@ test_qmckl_shared: test_qmckl.c $(qmckl_h) $(shared_lib) $(TESTS) $(TESTS_F) - $(CC) $(CFLAGS) -Wl,-rpath,$(QMCKL_ROOT)/lib -L$(QMCKL_ROOT)/lib \ - $(munit) $(TESTS) $(TESTS_F) -lqmckl $(LIBS) $(FCLIBS) test_qmckl.c -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) \ + -Wl,-rpath,$(QMCKL_ROOT)/lib -L$(QMCKL_ROOT)/lib $(munit) $(TESTS) \ + $(TESTS_F) -lqmckl $(LIBS) $(FCLIBS) test_qmckl.c -o $@ check: test_qmckl test_qmckl_shared ./test_qmckl @@ -95,7 +99,7 @@ uninstall: .SUFFIXES: .c .f90 .o .c.o: - $(CC) $(CFLAGS) -c $*.c -o $*.o + $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c $*.c -o $*.o .f90.o: qmckl_f.o $(FC) $(FCFLAGS) -c $*.f90 -o $*.o diff --git a/src/Makefile.in b/src/Makefile.in index f221b66..59805cc 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -18,20 +18,24 @@ FC = @FC@ CFLAGS = @CFLAGS@ FCFLAGS = @FCFLAGS@ LDFLAGS = @LDFLAGS@ +DEFS = @DEFS@ # Variables HAS_CPPCHECK = @HAS_CPPCHECK@ -QMCKL_ROOT=$(shell dirname $(CURDIR)) +# VPATH-related substitution variables +srcdir = @srcdir@ +VPATH = @srcdir@ +QMCKL_ROOT=$(srcdir)/.. shared_lib=$(QMCKL_ROOT)/lib/libqmckl.so static_lib=$(QMCKL_ROOT)/lib/libqmckl.a qmckl_h=$(QMCKL_ROOT)/include/qmckl.h qmckl_f=$(QMCKL_ROOT)/share/qmckl/fortran/qmckl_f.f90 -export CC CFLAGS FC FCFLAGS LIBS QMCKL_ROOT +export CC CFLAGS DEFS FC FCFLAGS LIBS QMCKL_ROOT ORG_SOURCE_FILES=$(wildcard $(QMCKL_ROOT)/*.org) C_SOURCE_FILES=$(patsubst %.org,%.c,$(ORG_SOURCE_FILES)) diff --git a/src/qmckl_ao.org b/src/qmckl_ao.org index 0c6c62a..98e0de2 100644 --- a/src/qmckl_ao.org +++ b/src/qmckl_ao.org @@ -36,24 +36,33 @@ gradients and Laplacian of the atomic basis functions. * Headers :noexport: #+begin_src elisp :noexport :results none (org-babel-lob-ingest "../tools/lib.org") -#+end_src + #+end_src #+begin_src c :tangle (eval h_private_type) #ifndef QMCKL_AO_HPT #define QMCKL_AO_HPT + #include #+end_src #+begin_src c :tangle (eval c_test) :noweb yes #include "qmckl.h" #include "munit.h" +#if HAVE_CONFIG_H +#include +#endif + MunitResult test_<>() { qmckl_context context; context = qmckl_context_create(); #+end_src #+begin_src c :tangle (eval c) +#if HAVE_CONFIG_H +#include +#endif + #include #include #include @@ -911,7 +920,7 @@ munit_assert(qmckl_ao_basis_provided(context)); const double* X, const int32_t* LMAX, double* const P, - const int64_t ldp ); + const int64_t ldp ); #+end_src *** Source diff --git a/src/qmckl_context.org b/src/qmckl_context.org index 14a2a45..05e0bc2 100644 --- a/src/qmckl_context.org +++ b/src/qmckl_context.org @@ -7,6 +7,9 @@ #+begin_src c :tangle (eval c_test) :noweb yes #include "qmckl.h" #include "munit.h" +#if HAVE_CONFIG_H +#include +#endif MunitResult test_<>() { #+end_src @@ -25,6 +28,9 @@ MunitResult test_<>() { #+end_src #+begin_src c :tangle (eval c) +#if HAVE_CONFIG_H +#include +#endif #include #include #include diff --git a/src/qmckl_distance.org b/src/qmckl_distance.org index c03155c..0715978 100644 --- a/src/qmckl_distance.org +++ b/src/qmckl_distance.org @@ -12,6 +12,9 @@ Functions for the computation of distances between particles. #+begin_src c :comments link :tangle (eval c_test) :noweb yes #include "qmckl.h" #include "munit.h" +#if HAVE_CONFIG_H +#include +#endif MunitResult test_<>() { qmckl_context context; context = qmckl_context_create(); diff --git a/src/qmckl_electron.org b/src/qmckl_electron.org index 0942421..40d1468 100644 --- a/src/qmckl_electron.org +++ b/src/qmckl_electron.org @@ -21,12 +21,18 @@ up-spin and down-spin electrons, and the electron coordinates. #+begin_src c :tangle (eval c_test) :noweb yes #include "qmckl.h" #include "munit.h" +#if HAVE_CONFIG_H +#include +#endif MunitResult test_<>() { qmckl_context context; context = qmckl_context_create(); #+end_src #+begin_src c :tangle (eval c) +#if HAVE_CONFIG_H +#include +#endif #include #include #include diff --git a/src/qmckl_error.org b/src/qmckl_error.org index af63b29..629772c 100644 --- a/src/qmckl_error.org +++ b/src/qmckl_error.org @@ -10,6 +10,9 @@ #+end_src #+begin_src c :tangle (eval c) +#if HAVE_CONFIG_H +#include +#endif #include #include #include @@ -27,6 +30,9 @@ #+begin_src c :tangle (eval c_test) :noweb yes #include "qmckl.h" #include "munit.h" +#if HAVE_CONFIG_H +#include +#endif MunitResult test_<>() { #+end_src diff --git a/src/qmckl_memory.org b/src/qmckl_memory.org index f5942f3..c47a757 100644 --- a/src/qmckl_memory.org +++ b/src/qmckl_memory.org @@ -9,6 +9,9 @@ optimized libraries to fine-tune the memory allocation. * Headers :noexport: #+begin_src c :tangle (eval c) +#if HAVE_CONFIG_H +#include +#endif #include #include #include @@ -28,6 +31,9 @@ optimized libraries to fine-tune the memory allocation. #+begin_src c :tangle (eval c_test) :noweb yes #include "qmckl.h" #include "munit.h" +#if HAVE_CONFIG_H +#include +#endif #include "qmckl_context_private_type.h" #include "qmckl_memory_private_func.h" MunitResult test_<>() { diff --git a/src/qmckl_numprec.org b/src/qmckl_numprec.org index 24f6a69..57872b3 100644 --- a/src/qmckl_numprec.org +++ b/src/qmckl_numprec.org @@ -7,6 +7,9 @@ #+begin_src c :tangle (eval c_test) :noweb yes #include "qmckl.h" #include "munit.h" +#if HAVE_CONFIG_H +#include +#endif MunitResult test_<>() { #+end_src @@ -18,6 +21,9 @@ MunitResult test_<>() { #+end_src #+begin_src c :tangle (eval c) +#if HAVE_CONFIG_H +#include +#endif #include #include #include diff --git a/src/test_qmckl.org b/src/test_qmckl.org index 6e1b7a9..7936d12 100644 --- a/src/test_qmckl.org +++ b/src/test_qmckl.org @@ -82,6 +82,9 @@ echo "#+end_src" #include "qmckl.h" #include "munit.h" #include "mcheck.h" +#if HAVE_CONFIG_H +#include +#endif <> int main(int argc, char* argv[MUNIT_ARRAY_PARAM(argc + 1)]) { diff --git a/tools/Building.org b/tools/Building.org index 221c960..d07b452 100644 --- a/tools/Building.org +++ b/tools/Building.org @@ -91,6 +91,7 @@ FC = @FC@ CFLAGS = @CFLAGS@ FCFLAGS = @FCFLAGS@ LDFLAGS = @LDFLAGS@ +DEFS = @DEFS@ #+end_src @@ -109,7 +110,7 @@ static_lib=$(QMCKL_ROOT)/lib/libqmckl.a qmckl_h=$(QMCKL_ROOT)/include/qmckl.h qmckl_f=$(QMCKL_ROOT)/share/qmckl/fortran/qmckl_f.f90 -export CC CFLAGS FC FCFLAGS LIBS QMCKL_ROOT +export CC CFLAGS DEFS FC FCFLAGS LIBS QMCKL_ROOT ORG_SOURCE_FILES=$(wildcard $(QMCKL_ROOT)/*.org) C_SOURCE_FILES=$(patsubst %.org,%.c,$(ORG_SOURCE_FILES)) @@ -243,8 +244,11 @@ version = @PACKAGE_VERSION@ prefix = @prefix@ -CC = @CC@ -CFLAGS= @CFLAGS@ -I../munit/ -I../include +CC = @CC@ +DEFS = @DEFS@ +CFLAGS = @CFLAGS@ -I../munit/ -I../include -I. -I\$(srcdir) +CPPFLAGS = @CPPFLAGS@ +LIBS = @LIBS@ FC = @FC@ FCFLAGS= @FCFLAGS@ @@ -268,7 +272,7 @@ and the rules: #+NAME: rules #+begin_src makefile :tangle no -QMCKL_ROOT=$(shell dirname $(CURDIR)) +QMCKL_ROOT=.. shared_lib=$(QMCKL_ROOT)/lib/libqmckl.so static_lib=$(QMCKL_ROOT)/lib/libqmckl.a qmckl_h=$(QMCKL_ROOT)/include/qmckl.h @@ -303,12 +307,13 @@ qmckl_f.o: $(qmckl_f) $(FC) $(FCFLAGS) -c $(qmckl_f) -o $@ test_qmckl: test_qmckl.c $(qmckl_h) $(static_lib) $(TESTS) $(TESTS_F) - $(CC) $(CFLAGS) $(munit) $(TESTS) $(TESTS_F) $(static_lib) $(LIBS) \ - $(FCLIBS) test_qmckl.c -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(munit) $(TESTS) $(TESTS_F) \ + $(static_lib) $(LIBS) $(FCLIBS) test_qmckl.c -o $@ test_qmckl_shared: test_qmckl.c $(qmckl_h) $(shared_lib) $(TESTS) $(TESTS_F) - $(CC) $(CFLAGS) -Wl,-rpath,$(QMCKL_ROOT)/lib -L$(QMCKL_ROOT)/lib \ - $(munit) $(TESTS) $(TESTS_F) -lqmckl $(LIBS) $(FCLIBS) test_qmckl.c -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) \ + -Wl,-rpath,$(QMCKL_ROOT)/lib -L$(QMCKL_ROOT)/lib $(munit) $(TESTS) \ + $(TESTS_F) -lqmckl $(LIBS) $(FCLIBS) test_qmckl.c -o $@ check: test_qmckl test_qmckl_shared ./test_qmckl @@ -343,7 +348,7 @@ uninstall: .SUFFIXES: .c .f90 .o .c.o: - $(CC) $(CFLAGS) -c $*.c -o $*.o + $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c $*.c -o $*.o .f90.o: qmckl_f.o $(FC) $(FCFLAGS) -c $*.f90 -o $*.o diff --git a/tools/create_makefile.sh b/tools/create_makefile.sh index 95fb222..7496818 100755 --- a/tools/create_makefile.sh +++ b/tools/create_makefile.sh @@ -71,8 +71,11 @@ version = @PACKAGE_VERSION@ prefix = @prefix@ -CC = @CC@ -CFLAGS= @CFLAGS@ -I../munit/ -I../include +CC = @CC@ +DEFS = @DEFS@ +CFLAGS = @CFLAGS@ -I../munit/ -I../include -I. -I\$(srcdir) +CPPFLAGS = @CPPFLAGS@ +LIBS = @LIBS@ FC = @FC@ FCFLAGS= @FCFLAGS@ @@ -87,7 +90,7 @@ FCLIBS = @FCLIBS@ EOF echo ' -QMCKL_ROOT=$(shell dirname $(CURDIR)) +QMCKL_ROOT=.. shared_lib=$(QMCKL_ROOT)/lib/libqmckl.so static_lib=$(QMCKL_ROOT)/lib/libqmckl.a qmckl_h=$(QMCKL_ROOT)/include/qmckl.h @@ -122,12 +125,13 @@ qmckl_f.o: $(qmckl_f) $(FC) $(FCFLAGS) -c $(qmckl_f) -o $@ test_qmckl: test_qmckl.c $(qmckl_h) $(static_lib) $(TESTS) $(TESTS_F) - $(CC) $(CFLAGS) $(munit) $(TESTS) $(TESTS_F) $(static_lib) $(LIBS) \ - $(FCLIBS) test_qmckl.c -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(munit) $(TESTS) $(TESTS_F) \ + $(static_lib) $(LIBS) $(FCLIBS) test_qmckl.c -o $@ test_qmckl_shared: test_qmckl.c $(qmckl_h) $(shared_lib) $(TESTS) $(TESTS_F) - $(CC) $(CFLAGS) -Wl,-rpath,$(QMCKL_ROOT)/lib -L$(QMCKL_ROOT)/lib \ - $(munit) $(TESTS) $(TESTS_F) -lqmckl $(LIBS) $(FCLIBS) test_qmckl.c -o $@ + $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) \ + -Wl,-rpath,$(QMCKL_ROOT)/lib -L$(QMCKL_ROOT)/lib $(munit) $(TESTS) \ + $(TESTS_F) -lqmckl $(LIBS) $(FCLIBS) test_qmckl.c -o $@ check: test_qmckl test_qmckl_shared ./test_qmckl @@ -162,7 +166,7 @@ uninstall: .SUFFIXES: .c .f90 .o .c.o: - $(CC) $(CFLAGS) -c $*.c -o $*.o + $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) -c $*.c -o $*.o .f90.o: qmckl_f.o $(FC) $(FCFLAGS) -c $*.f90 -o $*.o