diff --git a/Makefile.am b/Makefile.am index 7f42436..a792a52 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,7 +47,6 @@ pkgconfig_DATA = pkgconfig/qmckl.pc qmckl_h = include/qmckl.h include_HEADERS = $(qmckl_h) -qmckl_f = share/qmckl/fortran/qmckl_f.f90 test_qmckl_f = tests/qmckl_f.f90 test_qmckl_fo = tests/qmckl_f.o src_qmckl_f = src/qmckl_f.f90 @@ -55,19 +54,19 @@ src_qmckl_fo = src/qmckl_f.o header_tests = tests/chbrclf.h tests/n2.h fortrandir = $(datadir)/fortran -fortran_DATA = $(qmckl_f) +fortran_DATA = $(src_qmckl_f) -AM_CPPFLAGS = -I$(srcdir)/src -I$(srcdir)/include +AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_builddir)/include +AM_CPPFLAGS += -I$(srcdir)/src -I$(srcdir)/include AM_CPPFLAGS += -DQMCKL_TEST_DIR="\"$(abs_srcdir)/share/qmckl/test_data/\"" lib_LTLIBRARIES = src/libqmckl.la src_libqmckl_la_SOURCES = $(qmckl_h) $(src_qmckl_f) $(C_FILES) $(F_FILES) $(H_PRIVATE_FUNC_FILES) $(H_PRIVATE_TYPE_FILES) $(header_tests) -CLEANFILES+=$(test_qmckl_f) $(test_qmckl_fo) $(src_qmckl_f) $(src_qmckl_fo) $(test_qmckl_o) $(src_qmckl_o) +CLEANFILES+=$(test_qmckl_fo) $(src_qmckl_fo) $(test_qmckl_o) $(src_qmckl_o) $(FH_TYPE_FILES) $(FH_FUNC_FILES) -htmlize_el=share/doc/qmckl/html/htmlize.el include generated.mk @@ -76,16 +75,17 @@ ln_s_verbose = $(ln_s_verbose_@AM_V@) ln_s_verbose_ = $(ln_s_verbose_@AM_DEFAULT_V@) ln_s_verbose_0 = @echo " LN_S $<"; -htmldir = $(docdir)/html +htmldir = share/doc/qmckl/html +textdir = share/doc/qmckl/text +htmlize_el=$(htmldir)/htmlize.el dist_html_DATA = $(HTML_FILES) \ - share/doc/qmckl/html/index.html \ - share/doc/qmckl/html/qmckl.css + $(htmldir)/index.html \ + $(htmldir)/qmckl.css -textdir = $(docdir)/text dist_text_DATA = $(TEXT_FILES) -share/doc/qmckl/html/index.html: share/doc/qmckl/html/README.html - $(ln_s_verbose)cd share/doc/qmckl/html/ && \ +$(htmldir)/index.html: $(htmldir)/README.html + $(ln_s_verbose)cd $(htmldir)/ && \ rm -rf index.html && \ $(LN_S) README.html index.html @@ -103,11 +103,11 @@ if VFC_CI AM_LDFLAGS=-lvfc_probes -lvfc_probes_f endif -dist_src_DATA = $(ORG_FILES) $(TANGLED_FILES) $(EXPORTED_FILES) $(qmckl_f) $(test_qmckl_f) +dist_src_DATA = $(ORG_FILES) $(TANGLED_FILES) $(EXPORTED_FILES) $(test_qmckl_f) -BUILT_SOURCES = $(C_FILES) $(F_FILES) $(FH_FUNC_FILES) $(FH_TYPE_FILES) $(H_FUNC_FILES) $(H_TYPE_FILES) $(H_PRIVATE_FUNC_FILES) $(H_PRIVATE_TYPE_FILES) $(qmckl_f) $(src_qmckl_f) $(test_qmckl_f) $(qmckl_h) $(header_tests) +BUILT_SOURCES = $(C_FILES) $(F_FILES) $(FH_FUNC_FILES) $(FH_TYPE_FILES) $(H_FUNC_FILES) $(H_TYPE_FILES) $(H_PRIVATE_FUNC_FILES) $(H_PRIVATE_TYPE_FILES) $(src_qmckl_f) $(test_qmckl_f) $(qmckl_h) $(header_tests) -CLEANFILES += $(BUILT_SOURCES) $(C_TEST_FILES) $(F_TEST_FILES) $(TANGLED_FILES) $(C_TEST_FILES) $(F_TEST_FILES) $(qmckl_f) $(src_qmckl_f) $(test_qmckl_f) $(qmckl_h) $(HTML_FILES) $(TEXT_FILES) share/doc/qmckl/html/index.html $(EXPORTED_FILES) $(header_tests) +CLEANFILES += $(BUILT_SOURCES) $(C_TEST_FILES) $(F_TEST_FILES) $(TANGLED_FILES) $(C_TEST_FILES) $(F_TEST_FILES) $(src_qmckl_f) $(test_qmckl_f) $(qmckl_h) $(HTML_FILES) $(TEXT_FILES) $(htmldir)/index.html $(EXPORTED_FILES) $(header_tests) EXTRA_DIST += \ tools/build_doc.sh \ @@ -147,25 +147,22 @@ SUFFIXES = .f90 .h .org .c _f.f90 _func.h _type.h _private_func.h _private_type. $(test_qmckl_f): $(src_qmckl_f) cp $(src_qmckl_f) $(test_qmckl_f) -$(qmckl_f): $(src_qmckl_f) - cp $(src_qmckl_f) $(qmckl_f) - $(qmckl_h): $(H_FUNC_FILES) $(H_TYPE_FILES) - $(cat_h_verbose)top_builddir=$(top_builddir) srcdir=$(srcdir) qmckl_h=$(qmckl_h) $(srcdir)/tools/build_qmckl_h.sh + $(cat_h_verbose)top_builddir=$(abs_top_builddir) srcdir=$(abs_srcdir) qmckl_h=$(qmckl_h) $(srcdir)/tools/build_qmckl_h.sh $(src_qmckl_f): $(FH_FUNC_FILES) $(FH_TYPE_FILES) - $(cat_h_verbose)top_builddir=$(top_builddir) srcdir=$(srcdir) src_qmckl_f=$(src_qmckl_f) $(srcdir)/tools/build_qmckl_f.sh + echo $(FH_TYPE_FILES) $(FH_FUNC_FILES) + $(cat_h_verbose)top_builddir=$(abs_top_builddir) srcdir=$(abs_srcdir) src_qmckl_f=$(src_qmckl_f) $(srcdir)/tools/build_qmckl_f.sh $(htmlize_el): - $(srcdir)/tools/install_htmlize.sh $(htmlize_el) + $(MKDIR_P) $(htmldir) + $(MKDIR_P) $(textdir) + abs_srcdir=$(abs_srcdir) $(srcdir)/tools/install_htmlize.sh $(htmlize_el) tests/chbrclf.h: $(qmckl_h) tests/n2.h: $(qmckl_h) -generated.mk: $(ORG_FILES) - top_builddir=$(top_builddir) srcdir=$(srcdir) qmckl_h=$(qmckl_h) src_qmckl_f=$(src_qmckl_f) $(PYTHON) $(srcdir)/tools/build_makefile.py - cppcheck: cppcheck.out cppcheck.out: $(qmckl_h) @@ -175,7 +172,7 @@ cppcheck.out: $(qmckl_h) --suppress="unusedFunction" \ --suppress="missingIncludeSystem" \ --language=c --std=c99 -rp --platform=unix64 \ - -I../include *.c *.h 2>../$@ + -I$(srcdir)/include -I$(top_builddir)/include *.c *.h 2>../$@ .PHONY: cppcheck diff --git a/autogen.sh b/autogen.sh index 122cf87..85bebe6 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,4 +1,5 @@ #!/bin/bash -python ./tools/build_makefile.py +export srcdir="." +${PYTHON} ${srcdir}/tools/build_makefile.py autoreconf -i -Wall --no-recursive diff --git a/configure.ac b/configure.ac index d4f4621..fa3277d 100644 --- a/configure.ac +++ b/configure.ac @@ -41,7 +41,7 @@ AM_INIT_AUTOMAKE([subdir-objects color-tests parallel-tests silent-rules 1.11]) # Activate developer mode when the source is the git repository. # Otherwise, it is the source distribution and the developer mode should not be activated. -AS_IF([test -d .git], +AS_IF([test -d ${srcdir}/.git], [enable_maintainer_mode="yes"], [enable_maintainer_mode="no"] ) @@ -208,7 +208,6 @@ if test "x${QMCKL_DEVEL}" != "x"; then AC_PROG_AWK AM_PATH_PYTHON - ${PYTHON} ${srcdir}/tools/build_makefile.py AC_CHECK_PROGS([EMACS],[emacs26 emacs],[no]) if test x${EMACS} == xno ; then diff --git a/org/qmckl_tests.org b/org/qmckl_tests.org index 461772e..21ffe54 100644 --- a/org/qmckl_tests.org +++ b/org/qmckl_tests.org @@ -39,7 +39,7 @@ Br -1.218470 -0.187436 -0.028227 Nuclear coordinates are stored in atomic units in transposed format. -#+begin_src c :tangle ../tests/chbrclf.h +#+begin_src c :tangle (concat tests "chbrclf.h") #define chbrclf_nucl_num ((int64_t) 5) double chbrclf_charge[chbrclf_nucl_num] = { 6., 1., 9., 17., 35. }; @@ -523,7 +523,7 @@ F 1 #+END_example -#+begin_src c :tangle ../tests/chbrclf.h +#+begin_src c :tangle (concat tests "chbrclf.h") #define chbrclf_shell_num 72 #define chbrclf_prim_num 297 #define chbrclf_ao_num 263 @@ -968,7 +968,7 @@ double chbrclf_basis_prim_factor[chbrclf_prim_num] = ** Molecular orbitals -#+begin_src c :tangle ../tests/chbrclf.h +#+begin_src c :tangle (concat tests "chbrclf.h") #define chbrclf_mo_num ((int64_t) 224) double chbrclf_mo_coef[chbrclf_mo_num*chbrclf_ao_num] = { @@ -59891,7 +59891,7 @@ double chbrclf_mo_coef[chbrclf_mo_num*chbrclf_ao_num] = Electron coordinates are stored in atomic units in normal format. -#+begin_src c :tangle ../tests/chbrclf.h +#+begin_src c :tangle (concat tests "chbrclf.h") #define chbrclf_elec_up_num ((int64_t) 34) #define chbrclf_elec_dn_num ((int64_t) 34) #define chbrclf_elec_num ((int64_t) 68) @@ -60064,7 +60064,7 @@ N2 Nuclear coordinates are stored in atomic units in transposed format. -#+begin_src c :tangle ../tests/n2.h +#+begin_src c :tangle (concat tests "n2.h") #define n2_nucl_num ((int64_t) 2) double n2_charge[n2_nucl_num] = { 5., 5.}; @@ -60080,7 +60080,7 @@ double n2_nucl_coord[3][n2_nucl_num] = Electron coordinates are stored in atomic units in normal format. -#+begin_src c :tangle ../tests/n2.h +#+begin_src c :tangle (concat tests "n2.h") #define n2_elec_up_num ((int64_t) 5) #define n2_elec_dn_num ((int64_t) 5) #define n2_elec_num ((int64_t) 10) @@ -60105,7 +60105,7 @@ double n2_elec_coord[n2_walk_num][n2_elec_num][3] = { { This test is mainly for the Jastrow factor and was supplied by Ramon Panades Baruetta. -#+begin_src c :tangle ../tests/n2.h +#+begin_src c :tangle (concat tests "n2.h") /* Jastrow related */ #define n2_type_nucl_num ((int64_t) 1) diff --git a/tools/build_doc.sh b/tools/build_doc.sh index f218c15..519b417 100755 --- a/tools/build_doc.sh +++ b/tools/build_doc.sh @@ -32,7 +32,7 @@ function extract_doc() --load="${HTMLIZE}" \ --load="${CONFIG_DOC}" \ ${org} \ - --load="../${CONFIG_TANGLE}" \ + --load="${CONFIG_TANGLE}" \ -f org-html-export-to-html \ -f org-ascii-export-to-ascii @@ -47,7 +47,7 @@ function extract_doc() for i in $@ do exported=${i%.org}.exported - exported=$(dirname $exported)/.$(basename $exported) + exported=${top_builddir}/src/$(basename $exported) NOW=$(date +"%m%d%H%M.%S") extract_doc ${i} &> $exported rc=$? diff --git a/tools/build_makefile.py b/tools/build_makefile.py index e3851c2..014daca 100755 --- a/tools/build_makefile.py +++ b/tools/build_makefile.py @@ -4,8 +4,16 @@ from __future__ import print_function from glob import glob +import os def main(): + wd = os.getcwd() + try: + srcdir = os.environ["srcdir"] + os.chdir(srcdir) + except KeyError: + pass + C_FILES = [] C_O_FILES = [] F_FILES = [] @@ -33,8 +41,8 @@ def main(): for org in glob("org/*.org"): i = org.split('/')[-1].rsplit(".",1)[0] - tangled = "org/."+i+".tangled" - exported = "org/."+i+".exported" + tangled = "src/"+i+".tangled" + exported = "src/"+i+".exported" c_test_x = "tests/test_"+i c_test_o = "tests/test_"+i+".$(OBJEXT)" f_test_o = "tests/test_"+i+"_f.$(OBJEXT)" @@ -181,7 +189,7 @@ def main(): output = ["", "## Source files", "", - "ORG_FILES="+" ".join(ORG_FILES), + "ORG_FILES="+" ".join([ "$(srcdir)/"+ x for x in ORG_FILES]), "TANGLED_FILES="+" ".join(TANGLED_FILES), "EXPORTED_FILES="+" ".join(EXPORTED_FILES), "C_FILES="+" ".join(C_FILES), @@ -195,7 +203,7 @@ def main(): "H_PRIVATE_TYPE_FILES="+" ".join(H_PRIVATE_TYPE_FILES), "C_TEST_FILES="+" ".join(C_TEST_FILES), "F_TEST_FILES="+" ".join(F_TEST_FILES), - "TESTS="+" ".join(TESTS.keys()).replace("$(srcdir)/",""), + "TESTS="+" ".join(TESTS.keys()), "HTML_FILES="+" ".join(HTML.values()), "TEXT_FILES="+" ".join(TEXT.values()), "" ] @@ -205,8 +213,8 @@ def main(): "", "if QMCKL_DEVEL" ] for f in DEPS_ORG.keys(): - output += [ DEPS_ORG[f] + ": "+f, - "\t$(tangle_verbose)top_builddir=$(top_builddir) srcdir=$(srcdir) $(srcdir)/tools/missing bash $(srcdir)/tools/tangle.sh "+f, + output += [ DEPS_ORG[f] + ": $(srcdir)/"+f, + "\t$(tangle_verbose)top_builddir=$(abs_top_builddir) srcdir=$(abs_srcdir) $(srcdir)/tools/missing bash $(srcdir)/tools/tangle.sh $(srcdir)/"+f, "" ] output += [ "endif", "" ] @@ -233,7 +241,7 @@ def main(): for f in sorted(TESTS.keys()): prefix = "tests_" + f.rsplit("/",1)[-1] output += [ prefix + "_SOURCES = " + \ - " ".join(TESTS[f]).replace("$(srcdir)",""), + " ".join(TESTS[f]), prefix + "_LDADD = src/libqmckl.la", prefix + "_LDFLAGS = -no-install", "" ] @@ -252,16 +260,16 @@ def main(): for f in sorted(ORG_FILES): output += [ HTML[f] + ": " + DEPS_DOC[f], - TEXT[f] + ": " + DEPS_DOC[f], + TEXT[f] + ": " + DEPS_DOC[f], "" ] for f in sorted(DEPS_DOC.keys()): - output += [ DEPS_DOC[f] + ": " + f + " $(htmlize_el)", - "\t$(export_verbose)top_builddir=$(top_builddir) srcdir=$(srcdir) $(srcdir)/tools/missing bash $(srcdir)/tools/build_doc.sh "+f, + output += [ DEPS_DOC[f] + ": $(srcdir)/" + f + " $(htmlize_el)", + "\t$(export_verbose)top_builddir=$(abs_top_builddir) srcdir=$(abs_srcdir) $(srcdir)/tools/missing bash $(srcdir)/tools/build_doc.sh $(srcdir)/"+f, "" ] output += ["endif"] - f = open("generated.mk","w") + f = open(srcdir+"/generated.mk","w") f.write("\n".join(output)) diff --git a/tools/build_qmckl_h.sh b/tools/build_qmckl_h.sh index d74d30e..eef0487 100755 --- a/tools/build_qmckl_h.sh +++ b/tools/build_qmckl_h.sh @@ -99,7 +99,7 @@ EOF for i in ${HEADERS} do - header=${srcdir}/src/$i + header=${top_builddir}/src/$i if [ -f $header ] ; then echo "/* $header */" >> ${qmckl_h} cat $header >> ${qmckl_h} diff --git a/tools/config_tangle.el b/tools/config_tangle.el index 542715f..4c29fc9 100755 --- a/tools/config_tangle.el +++ b/tools/config_tangle.el @@ -33,19 +33,21 @@ ; The following is required to compute the file names -(setq pwd (file-name-directory buffer-file-name)) -(setq wd (concat pwd "/../src/")) -(setq td (concat pwd "/../tests/")) -(setq name (file-name-nondirectory (substring buffer-file-name 0 -4))) -(setq f (concat wd name "_f.f90")) -(setq fh_func (concat wd name "_fh_func.f90")) -(setq fh_type (concat wd name "_fh_type.f90")) -(setq c (concat wd name ".c")) -(setq h_func (concat wd name "_func.h")) -(setq h_type (concat wd name "_type.h")) -(setq h_private_type (concat wd name "_private_type.h")) -(setq h_private_func (concat wd name "_private_func.h")) -(setq c_test (concat td "test_" name ".c")) -(setq f_test (concat td "test_" name "_f.f90")) -(org-babel-lob-ingest "../tools/lib.org") +(setq top_builddir (or (getenv "top_builddir") ".")) +(setq srcdir (or (getenv "srcdir") ".")) + +(setq src (concat top_builddir "/src/")) +(setq tests (concat top_builddir "/tests/")) +(setq name (file-name-nondirectory (substring buffer-file-name 0 -4))) +(setq f (concat src name "_f.f90")) +(setq fh_func (concat src name "_fh_func.f90")) +(setq fh_type (concat src name "_fh_type.f90")) +(setq c (concat src name ".c")) +(setq h_func (concat src name "_func.h")) +(setq h_type (concat src name "_type.h")) +(setq h_private_type (concat src name "_private_type.h")) +(setq h_private_func (concat src name "_private_func.h")) +(setq c_test (concat tests "test_" name ".c")) +(setq f_test (concat tests "test_" name "_f.f90")) +(org-babel-lob-ingest (concat srcdir "/tools/lib.org")) diff --git a/tools/install_htmlize.sh b/tools/install_htmlize.sh index b069777..b1f52d7 100755 --- a/tools/install_htmlize.sh +++ b/tools/install_htmlize.sh @@ -2,7 +2,7 @@ # # Installs the htmlize Emacs plugin -./tools/missing git clone "https://github.com/hniksic/emacs-htmlize" +${abs_srcdir}/tools/missing git clone "https://github.com/TREX-CoE/emacs-htmlize" mv emacs-htmlize/htmlize.el $1 rm -rf emacs-htmlize diff --git a/tools/tangle.sh b/tools/tangle.sh index 56e2667..2f37b95 100755 --- a/tools/tangle.sh +++ b/tools/tangle.sh @@ -14,7 +14,7 @@ if [[ -z ${srcdir} ]] ; then fi if [[ -z ${top_builddir} ]] ; then - echo "Error: srcdir environment variable is not defined" + echo "Error: top_builddir environment variable is not defined" exit 1 fi @@ -31,14 +31,14 @@ function tangle() fi ${srcdir}/tools/missing \ emacs --batch ${org_file} \ - --load=${PWD}/tools/config_tangle.el \ + --load=${srcdir}/tools/config_tangle.el \ -f org-babel-tangle } for i in $@ do tangled=${i%.org}.tangled - tangled=$(dirname $tangled)/.$(basename $tangled) + tangled=${top_builddir}/src/$(basename $tangled) NOW=$(date +"%m%d%H%M.%S") tangle ${i} &> $tangled rc=$? @@ -47,6 +47,6 @@ do # Fail if tangling failed if [[ $rc -ne 0 ]] ; then cat $tangled - exit rc + exit $rc fi done