From f03cff153ebdc1d61d251f61bde6463001f50c92 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 6 Mar 2021 18:19:13 +0100 Subject: [PATCH] Fixed makefile --- src/Makefile | 11 ++++---- src/README.org | 23 +++++++++------- src/create_doc.sh | 41 ---------------------------- src/merge_org.sh | 17 ------------ src/table_of_contents | 9 +++++++ tools/create_doc.sh | 45 +++++++++++++++++++++++++++++++ {src => tools}/create_makefile.sh | 7 ++--- tools/merge_org.sh | 8 ++++++ 8 files changed, 85 insertions(+), 76 deletions(-) delete mode 100755 src/create_doc.sh delete mode 100755 src/merge_org.sh create mode 100644 src/table_of_contents create mode 100755 tools/create_doc.sh rename {src => tools}/create_makefile.sh (95%) create mode 100755 tools/merge_org.sh diff --git a/src/Makefile b/src/Makefile index 7ec36ea..d343eea 100644 --- a/src/Makefile +++ b/src/Makefile @@ -34,9 +34,10 @@ LIBS=-lm endif -export CC CFLAGS FC FFLAGS LIBS +QMCKL_ROOT=$(PWD)/.. + +export CC CFLAGS FC FFLAGS LIBS QMCKL_ROOT -MERGED_ORG=merged_qmckl.org ORG_SOURCE_FILES=$(wildcard *.org) OBJECT_FILES=$(filter-out $(EXCLUDED_OBJECTS), $(patsubst %.org,%.o,$(ORG_SOURCE_FILES))) @@ -51,12 +52,12 @@ test: Makefile.generated doc: $(ORG_SOURCE_FILES) - ./create_doc.sh $(MERGED_ORG) + $(QMCKL_ROOT)/tools/create_doc.sh clean: rm -f qmckl.h test_qmckl_* test_qmckl.c test_qmckl qmckl_*.f90 qmckl_*.c qmckl_*.o qmckl_*.h Makefile.generated libqmckl.so *.html *.fh *.mod -Makefile.generated: Makefile create_makefile.sh $(ORG_SOURCE_FILES) - ./create_makefile.sh $(MERGED_ORG) +Makefile.generated: Makefile $(QMCKL_ROOT)/tools/create_makefile.sh $(ORG_SOURCE_FILES) + $(QMCKL_ROOT)/tools/create_makefile.sh diff --git a/src/README.org b/src/README.org index 0bed5e0..a2c2c9e 100644 --- a/src/README.org +++ b/src/README.org @@ -6,7 +6,7 @@ * Introduction - + The ultimate goal of the QMCkl library is to provide a high-performance implementation of the main kernels of QMC. In this particular @@ -15,9 +15,9 @@ HPC experts to use this repository as a reference for re-writing optimized libraries. - + ** Literate programming - + In a traditional source code, most of the lines of source files of a program are code, scripts, Makefiles, and only a few lines are comments explaining parts of the code that are non-trivial to understand. The documentation of @@ -49,7 +49,7 @@ easily extracted from the org-mode files invoking the Emacs text editor from the command-line in the =Makefile=, and then the produced files are compiled. Moreover, within the Emacs text editor the source code blocks can be executed - interactively, in the same spirit as Jupyter notebooks. + interactively, in the same spirit as Jupyter notebooks. ** Source code editing @@ -59,7 +59,7 @@ Any text editor can be used to edit org-mode files. For a better user experience Emacs is recommended. For users hating Emacs, it is good to know that Emacs can behave like Vim when switched into - ``Evil'' mode. + ``Evil'' mode. In the =tools/init.el= file, we provide a minimal Emacs configuration file for vim users. This file should be copied into =.emacs.d/init.el=. @@ -137,9 +137,9 @@ If the name of the org-mode file is =xxx.org=, the name of the produced C files should be =xxx.c= and =xxx.h= and the name of the produced Fortran file should be =xxx.f90=. - + Arrays are in uppercase and scalars are in lowercase. - + In the names of the variables and functions, only the singular form is allowed. @@ -224,7 +224,7 @@ variable. ** Algorithms - + Reducing the scaling of an algorithm usually implies also reducing its arithmetic complexity (number of flops per byte). Therefore, for small sizes \(\mathcal{O}(N^3)\) and \(\mathcal{O}(N^2)\) @@ -233,11 +233,14 @@ implemented adapted to different problem sizes. ** Rules for the API - + - =stdint= should be used for integers (=int32_t=, =int64_t=) - integers used for counting should always be =int64_t= - - floats should be by default =double=, unless explicitly mentioned + - floats should be by default =double=, unless explicitly mentioned - pointers are converted to =int64_t= to increase portability * Documentation + # The .org files will be appended here in the order specified in the + # table_of_contents file + diff --git a/src/create_doc.sh b/src/create_doc.sh deleted file mode 100755 index c5b092b..0000000 --- a/src/create_doc.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -INPUT=$1 -SRC=$PWD - - -# Install htmlize if needed -[[ -f ../docs/htmlize.el ]] || ( - cd ../docs/ - git clone https://github.com/hniksic/emacs-htmlize - cp emacs-htmlize/htmlize.el . - rm -rf emacs-htmlize - cd - -) - -[[ -f ../docs/htmlize.el ]] || exit 1 - - -# Switch to TMPDIR for easy cleanup -TMPDIR=$(mktemp -d) -./merge_org.sh $TMPDIR/$INPUT -cd $TMPDIR - - -# Create documentation -emacs --batch \ - --load ${SRC}/../docs/htmlize.el \ - --load ${SRC}/../toold/init.el \ - $INPUT -f org-html-export-to-html - -if [[ $? -eq 0 ]] -then - rm -rf $TMPDIR - exit 0 -else - mv index.html ${SRC}/../docs/ - rm -rf $TMPDIR - exit 2 -fi - - diff --git a/src/merge_org.sh b/src/merge_org.sh deleted file mode 100755 index 61d182f..0000000 --- a/src/merge_org.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -OUTPUT=$1 - -for i in README.org \ - qmckl.org \ - qmckl_context.org \ - qmckl_error.org \ - qmckl_precision.org \ - qmckl_memory.org \ - qmckl_distance.org \ - qmckl_ao.org \ - qmckl_footer.org \ - test_qmckl.org -do - cat $i >> $1 -done diff --git a/src/table_of_contents b/src/table_of_contents new file mode 100644 index 0000000..2fbbb05 --- /dev/null +++ b/src/table_of_contents @@ -0,0 +1,9 @@ +qmckl.org +qmckl_context.org +qmckl_error.org +qmckl_precision.org +qmckl_memory.org +qmckl_distance.org +qmckl_ao.org +test_qmckl.org +qmckl_footer.org diff --git a/tools/create_doc.sh b/tools/create_doc.sh new file mode 100755 index 0000000..a71845d --- /dev/null +++ b/tools/create_doc.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +INPUT=merged.org +if [[ -z $QMCKL_ROOT ]] +then + print "QMCKL_ROOT is not defined" + exit 1 +fi + + +# Install htmlize if needed +[[ -f ${QMCKL_ROOT}/docs/htmlize.el ]] || ( + cd ${QMCKL_ROOT}/docs/ + git clone https://github.com/hniksic/emacs-htmlize + cp emacs-htmlize/htmlize.el . + rm -rf emacs-htmlize + cd - +) + +[[ -f ${QMCKL_ROOT}/docs/htmlize.el ]] || exit 1 + + +# Switch to TMPDIR for easy cleanup +TMPDIR=$(mktemp -d) +${QMCKL_ROOT}/tools/merge_org.sh $TMPDIR/$INPUT +cd $TMPDIR + + +# Create documentation +emacs --batch \ + --load ${QMCKL_ROOT}/docs/htmlize.el \ + --load ${QMCKL_ROOT}/tools/init.el \ + $INPUT -f org-html-export-to-html + +if [[ $? -eq 0 ]] +then + rm -rf $TMPDIR + exit 0 +else + mv index.html ${QMCKL_ROOT}/docs/ + rm -rf $TMPDIR + exit 2 +fi + + diff --git a/src/create_makefile.sh b/tools/create_makefile.sh similarity index 95% rename from src/create_makefile.sh rename to tools/create_makefile.sh index 20a1ec7..3e81c7d 100755 --- a/src/create_makefile.sh +++ b/tools/create_makefile.sh @@ -1,17 +1,18 @@ #!/bin/bash -INPUT=$1 -./merge_org.sh $INPUT +MERGED=merged.org +${QMCKL_ROOT}/tools/merge_org.sh $MERGED OUTPUT=Makefile.generated # Tangle org files emacs \ - $INPUT \ + $MERGED \ --batch \ -f org-babel-tangle \ --kill +rm $MERGED # Create the list of *.o files to be created diff --git a/tools/merge_org.sh b/tools/merge_org.sh new file mode 100755 index 0000000..97b749a --- /dev/null +++ b/tools/merge_org.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +OUTPUT=$1 + +for i in README.org $(cat $QMCKL_ROOT/src/table_of_contents) +do + cat $i >> $1 +done