mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2025-04-19 07:00:10 +02:00
Cleaned Makefile
This commit is contained in:
parent
c2d02f755b
commit
0dffa4ce4c
35
configure.ac
Normal file
35
configure.ac
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
VERSION=[1.0]
|
||||||
|
AC_SUBST([VERSION])
|
||||||
|
|
||||||
|
AC_REVISION([c2d02f7 Added DESTDIR in Makefile])
|
||||||
|
AC_INIT([QMCkl],[1.0],
|
||||||
|
[https://github.com/TREX-CoE/qmckl/issues], [],
|
||||||
|
[https://trex-coe.github.io/qmckl/index.html])
|
||||||
|
|
||||||
|
AC_CONFIG_SRCDIR([src/README.org])
|
||||||
|
|
||||||
|
AC_LANG_PUSH([C])
|
||||||
|
AC_PROG_CC([gcc icc clang nvcc xlc])
|
||||||
|
|
||||||
|
AC_CHECK_HEADERS([assert.h errno.h malloc.h math.h pthread.h stdbool.h stdint.h stdio.h stdlib.h string.h])
|
||||||
|
|
||||||
|
AC_PROG_FC([ifort gfortran flang nvfortran xlf90],[Fortran])
|
||||||
|
AC_PROG_FC_C_O
|
||||||
|
AC_FC_SRCEXT([f90])
|
||||||
|
AC_FC_FREEFORM
|
||||||
|
|
||||||
|
AC_CHECK_HEADER([munit/munit.h], [echo found], [echo not found] )
|
||||||
|
|
||||||
|
AC_CHECK_LIB([pthread], [pthread_create])
|
||||||
|
|
||||||
|
AC_SEARCH_LIBS([dgemm], [blas mkl],
|
||||||
|
[],
|
||||||
|
AC_MSG_ERROR([Unable to find a BLAS library]) )
|
||||||
|
|
||||||
|
AC_CONFIG_FILES(Makefile)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AC_CHECK_PROGS([HAS_EMACS],[emacs],[])
|
||||||
|
|
||||||
|
AC_OUTPUT
|
137
configure.org
137
configure.org
@ -1,137 +0,0 @@
|
|||||||
#+TITLE: QMCkl configuration
|
|
||||||
|
|
||||||
This files contains al the information to generate the files required
|
|
||||||
by Autotools to build the =configure= script for the library.
|
|
||||||
|
|
||||||
* Scripts analyzing source code
|
|
||||||
|
|
||||||
** Version of the library
|
|
||||||
|
|
||||||
#+NAME: version
|
|
||||||
#+BEGIN_SRC sh
|
|
||||||
echo 1.0
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
#+RESULTS: version
|
|
||||||
: 1.0
|
|
||||||
|
|
||||||
#+NAME: issues
|
|
||||||
#+BEGIN_SRC sh
|
|
||||||
echo "https://github.com/TREX-CoE/qmckl/issues"
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
#+RESULTS: issues
|
|
||||||
: https://github.com/TREX-CoE/qmckl/issues
|
|
||||||
|
|
||||||
#+NAME: website
|
|
||||||
#+BEGIN_SRC sh
|
|
||||||
echo "https://trex-coe.github.io/qmckl/index.html"
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
#+RESULTS: website
|
|
||||||
: https://trex-coe.github.io/qmckl/index.html
|
|
||||||
|
|
||||||
|
|
||||||
#+NAME: revision
|
|
||||||
#+BEGIN_SRC sh
|
|
||||||
git log --oneline | head -1
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
#+RESULTS: revision
|
|
||||||
: 5f2da3e Fixed website
|
|
||||||
|
|
||||||
** C Header files
|
|
||||||
|
|
||||||
#+NAME: headers
|
|
||||||
#+BEGIN_SRC sh :tangle no
|
|
||||||
#grep --regexp="\#include\\s+<.*>" --no-filename src/*.org \
|
|
||||||
grep --regexp="\#include\\s*<.*>" --no-filename src/*.org \
|
|
||||||
| sort \
|
|
||||||
| uniq \
|
|
||||||
| cut -d '<' -f 2 \
|
|
||||||
| cut -d '>' -f 1 \
|
|
||||||
| tr '\n' ' '
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
#+RESULTS: headers
|
|
||||||
: assert.h errno.h math.h stdint.h stdlib.h string.h
|
|
||||||
|
|
||||||
|
|
||||||
* configure.ac
|
|
||||||
|
|
||||||
** Initialization
|
|
||||||
|
|
||||||
#+BEGIN_SRC sh :noweb yes :tangle configure.ac
|
|
||||||
# This file was generated from the org-mode file configure.org
|
|
||||||
|
|
||||||
VERSION=[<<version()>>]
|
|
||||||
AC_SUBST([VERSION])
|
|
||||||
|
|
||||||
AC_REVISION([<<revision()>>])
|
|
||||||
AC_INIT([QMCkl],[<<version()>>],
|
|
||||||
[<<issues()>>], [],
|
|
||||||
[<<website()>>])
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** Source files
|
|
||||||
#+BEGIN_SRC sh :noweb yes :tangle configure.ac
|
|
||||||
AC_CONFIG_SRCDIR([src/README.org])
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** C Compiler
|
|
||||||
|
|
||||||
#+BEGIN_SRC sh :noweb yes :tangle configure.ac
|
|
||||||
AC_LANG_PUSH([C])
|
|
||||||
AC_PROG_CC
|
|
||||||
|
|
||||||
AC_CHECK_HEADERS([<<headers()>>])
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** Fortran Compiler
|
|
||||||
|
|
||||||
#+BEGIN_SRC sh :noweb yes :tangle configure.ac
|
|
||||||
AC_PROG_FC([ifort gfortran flang],[Fortran])
|
|
||||||
AC_PROG_FC_C_O
|
|
||||||
AC_FC_SRCEXT([f90])
|
|
||||||
AC_FC_FREEFORM
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** External libraries
|
|
||||||
|
|
||||||
#+BEGIN_SRC sh :tangle configure.ac
|
|
||||||
AC_CHECK_HEADER([munit/munit.h], [echo found], [echo not found] )
|
|
||||||
|
|
||||||
AC_CHECK_LIB([pthread], [pthread_create])
|
|
||||||
|
|
||||||
AC_SEARCH_LIBS([dgemm], [blas mkl],
|
|
||||||
[],
|
|
||||||
AC_MSG_ERROR([Unable to find a BLAS library])
|
|
||||||
])
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** Makefile
|
|
||||||
|
|
||||||
#+BEGIN_SRC sh :tangle configure.ac
|
|
||||||
AC_CONFIG_FILES(Makefile)
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** Library
|
|
||||||
|
|
||||||
#+BEGIN_SRC sh :tangle configure.ac
|
|
||||||
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** Documentation
|
|
||||||
|
|
||||||
#+BEGIN_SRC sh :noweb yes :tangle configure.ac
|
|
||||||
AC_CHECK_PROGS([HAS_EMACS],[emacs],[])
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** Finalization
|
|
||||||
|
|
||||||
#+BEGIN_SRC sh :tangle configure.ac
|
|
||||||
AC_OUTPUT
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
* Makefile.am
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
|||||||
#+TITLE: Building tools
|
#+TITLE: Building tools
|
||||||
|
#+STARTUP: indent overview
|
||||||
|
#+PROPERTY: header-args: :comments both
|
||||||
|
|
||||||
This file contains all the tools needed to build the QMCkl library.
|
This file contains all the tools needed to build the QMCkl library.
|
||||||
|
|
||||||
@ -56,30 +58,47 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#+end_example
|
#+end_example
|
||||||
|
|
||||||
* Makefile
|
* Makefiles
|
||||||
:PROPERTIES:
|
** Makefile.in
|
||||||
:header-args: :tangle ../src/Makefile :noweb yes :comments org
|
:PROPERTIES:
|
||||||
:END:
|
:header-args: :tangle ../src/Makefile.in :noweb yes :comments org
|
||||||
|
:END:
|
||||||
|
|
||||||
This is the main Makefile invoked by the ~make~ command.
|
This is the main Makefile invoked by the ~make~ command at the root
|
||||||
The Makefile compiling the library is =Makefile.generated=, and is
|
of the package. To compile the sources, it calls the =Makefile=
|
||||||
generated by the script detailed in the next section.
|
located in the =src= directory. This Makefile creates the source
|
||||||
** Header :noexport:
|
file from the org-mode file, as well as a Makefile,
|
||||||
|
=Makefile.generated=, dedicated to the compilation of the sources.
|
||||||
|
|
||||||
|
*** Header
|
||||||
|
|
||||||
#+begin_src makefile
|
We want the Makefile to be POSIX-compliant, such that it works not
|
||||||
|
only with GNU Make.
|
||||||
|
|
||||||
|
#+begin_src makefile
|
||||||
# <<header()>>
|
# <<header()>>
|
||||||
|
|
||||||
.POSIX:
|
.POSIX:
|
||||||
#+end_src
|
#+end_src
|
||||||
** Dependencies
|
|
||||||
|
|
||||||
#+begin_src makefile
|
*** Compiler options
|
||||||
LIBS=-lpthread
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
** Variables
|
Compiler variables are obtained from the configure script (see =configure.ac=)
|
||||||
|
|
||||||
|
#+begin_src makefile
|
||||||
|
CC = @CC@
|
||||||
|
FC = @FC@
|
||||||
|
CFLAGS = @CFLAGS@
|
||||||
|
FFLAGS = @FFLAGS@
|
||||||
|
LDFLAGS= @LDFLAGS@
|
||||||
|
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Variables
|
||||||
|
|
||||||
|
#+begin_src makefile
|
||||||
|
HAS_CPPCHECK = @HAS_CPPCHECK@
|
||||||
|
|
||||||
#+begin_src makefile
|
|
||||||
QMCKL_ROOT=$(shell dirname $(CURDIR))
|
QMCKL_ROOT=$(shell dirname $(CURDIR))
|
||||||
|
|
||||||
shared_lib=$(QMCKL_ROOT)/lib/libqmckl.so
|
shared_lib=$(QMCKL_ROOT)/lib/libqmckl.so
|
||||||
@ -89,81 +108,17 @@ qmckl_f=$(QMCKL_ROOT)/share/qmckl/fortran/qmckl_f.f90
|
|||||||
|
|
||||||
export CC CFLAGS FC FFLAGS LIBS QMCKL_ROOT
|
export CC CFLAGS FC FFLAGS LIBS QMCKL_ROOT
|
||||||
|
|
||||||
ORG_SOURCE_FILES=$(wildcard *.org)
|
ORG_SOURCE_FILES=$(wildcard $(QMCKL_ROOT)/*.org)
|
||||||
C_SOURCE_FILES=$(patsubst %.org,%.c,$(ORG_SOURCE_FILES))
|
C_SOURCE_FILES=$(patsubst %.org,%.c,$(ORG_SOURCE_FILES))
|
||||||
INCLUDE=-I$(QMCKL_ROOT)/include/
|
INCLUDE=-I$(QMCKL_ROOT)/include/
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Compiler options
|
*** Rules
|
||||||
|
|
||||||
GNU, Intel and LLVM compilers are supported. Choose here:
|
The source files are created during the generation of the file ~Makefile.generated~.
|
||||||
|
The Makefile.generated is the one that will be distributed with the library.
|
||||||
|
|
||||||
#+begin_src makefile
|
#+begin_src makefile
|
||||||
COMPILER=GNU
|
|
||||||
#COMPILER=INTEL
|
|
||||||
#COMPILER=LLVM
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** GNU
|
|
||||||
|
|
||||||
#+begin_src makefile
|
|
||||||
ifeq ($(COMPILER),GNU)
|
|
||||||
#----------------------------------------------------------
|
|
||||||
CC=gcc -g
|
|
||||||
CFLAGS=-fPIC $(INCLUDE) \
|
|
||||||
-fexceptions -Wall -Werror -Wpedantic -Wextra -fmax-errors=3
|
|
||||||
|
|
||||||
FC=gfortran -g
|
|
||||||
FFLAGS=-fPIC $(INCLUDE) \
|
|
||||||
-fcheck=all -Waliasing -Wampersand -Wconversion -Wsurprising \
|
|
||||||
-Wintrinsics-std -Wno-tabs -Wintrinsic-shadow -Wline-truncation \
|
|
||||||
-Wreal-q-constant -Wuninitialized -fbacktrace -finit-real=nan \
|
|
||||||
-ffpe-trap=zero,overflow,underflow
|
|
||||||
|
|
||||||
LIBS+=-lgfortran -lm
|
|
||||||
#----------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** Intel
|
|
||||||
|
|
||||||
#+begin_src makefile
|
|
||||||
ifeq ($(COMPILER),INTEL)
|
|
||||||
#----------------------------------------------------------
|
|
||||||
CC=icc -xHost
|
|
||||||
CFLAGS=-fPIC -g -O2 $(INCLUDE)
|
|
||||||
|
|
||||||
FC=ifort -xHost
|
|
||||||
FFLAGS=-fPIC -g -O2 $(INCLUDE)
|
|
||||||
|
|
||||||
LIBS+=-lm -lifcore -lirc
|
|
||||||
#----------------------------------------------------------
|
|
||||||
CC=icc -xHost
|
|
||||||
endif
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** LLVM
|
|
||||||
|
|
||||||
#+begin_src makefile
|
|
||||||
ifeq ($(COMPILER),LLVM)
|
|
||||||
#----------------------------------------------------------
|
|
||||||
CC=clang
|
|
||||||
CFLAGS=-fPIC -g -O2 $(INCLUDE)
|
|
||||||
|
|
||||||
FC=flang
|
|
||||||
FFLAGS=fPIC -g -O2 $(INCLUDE)
|
|
||||||
|
|
||||||
LIBS+=-lm
|
|
||||||
#----------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
** Rules
|
|
||||||
|
|
||||||
The source files are created during the generation of the file ~Makefile.generated~.
|
|
||||||
The Makefile.generated is the one that will be distributed with the library.
|
|
||||||
|
|
||||||
#+begin_src makefile
|
|
||||||
.PHONY: clean shared static doc all check install uninstall
|
.PHONY: clean shared static doc all check install uninstall
|
||||||
.SECONDARY: # Needed to keep the produced C and Fortran files
|
.SECONDARY: # Needed to keep the produced C and Fortran files
|
||||||
|
|
||||||
@ -183,11 +138,13 @@ all: shared static doc check
|
|||||||
check: $(static_lib)
|
check: $(static_lib)
|
||||||
$(MAKE) -f Makefile.generated check
|
$(MAKE) -f Makefile.generated check
|
||||||
|
|
||||||
|
ifeq ($(HAS_CPPCHECK),1)
|
||||||
cppcheck:
|
cppcheck:
|
||||||
cppcheck \
|
cppcheck \
|
||||||
--addon=cert \
|
--addon=cert \
|
||||||
--enable=warning,style,performance,portability,information \
|
--enable=warning,style,performance,portability,information \
|
||||||
qmckl_*.c
|
qmckl_*.c
|
||||||
|
endif
|
||||||
|
|
||||||
doc: $(ORG_SOURCE_FILES)
|
doc: $(ORG_SOURCE_FILES)
|
||||||
$(QMCKL_ROOT)/tools/build_doc.sh
|
$(QMCKL_ROOT)/tools/build_doc.sh
|
||||||
@ -201,7 +158,7 @@ clean:
|
|||||||
|
|
||||||
veryclean: clean FORCE
|
veryclean: clean FORCE
|
||||||
- $(RM) $(QMCKL_ROOT)/share/doc/qmckl/html/*.html \
|
- $(RM) $(QMCKL_ROOT)/share/doc/qmckl/html/*.html \
|
||||||
$(QMCKL_ROOT)/share/doc/qmckl/text/*.txt
|
$(QMCKL_ROOT)/share/doc/qmckl/text/*.txt
|
||||||
|
|
||||||
Makefile.generated: Makefile $(QMCKL_ROOT)/tools/create_makefile.sh $(ORG_SOURCE_FILES) ../tools/Building.org
|
Makefile.generated: Makefile $(QMCKL_ROOT)/tools/create_makefile.sh $(ORG_SOURCE_FILES) ../tools/Building.org
|
||||||
$(QMCKL_ROOT)/tools/create_makefile.sh
|
$(QMCKL_ROOT)/tools/create_makefile.sh
|
||||||
@ -212,52 +169,9 @@ Makefile.generated: Makefile $(QMCKL_ROOT)/tools/create_makefile.sh $(ORG_SOURC
|
|||||||
.org.c:
|
.org.c:
|
||||||
$(QMCKL_ROOT)/tools/tangle.sh $<
|
$(QMCKL_ROOT)/tools/tangle.sh $<
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* Script to tangle the org-mode files
|
** Script to generate auto-generated Makefile
|
||||||
:PROPERTIES:
|
|
||||||
:header-args: :tangle tangle.sh :noweb yes :shebang #!/bin/bash :comments org
|
|
||||||
:END:
|
|
||||||
|
|
||||||
#+begin_src bash
|
|
||||||
# <<header()>>
|
|
||||||
|
|
||||||
<<check_src>>
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
This file needs to be run from the QMCKL =src= directory.
|
|
||||||
|
|
||||||
It tangles all the files in the directory. It uses the
|
|
||||||
=config_tangle.el= file, which contains information required to
|
|
||||||
compute the current file names using for example ~(eval c)~ to get
|
|
||||||
the name of the produced C file.
|
|
||||||
|
|
||||||
The file is not tangled if the last modification date of the org
|
|
||||||
file is less recent than one of the tangled files.
|
|
||||||
|
|
||||||
#+begin_src bash
|
|
||||||
function tangle()
|
|
||||||
{
|
|
||||||
local org_file=$1
|
|
||||||
local c_file=${org_file%.org}.c
|
|
||||||
local f_file=${org_file%.org}.f90
|
|
||||||
|
|
||||||
if [[ ${org_file} -ot ${c_file} ]] ; then
|
|
||||||
return
|
|
||||||
elif [[ ${org_file} -ot ${f_file} ]] ; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
emacs --batch ${org_file} --load=../tools/config_tangle.el -f org-babel-tangle
|
|
||||||
}
|
|
||||||
|
|
||||||
for i in $@
|
|
||||||
do
|
|
||||||
echo "--- ${i} ----"
|
|
||||||
tangle ${i}
|
|
||||||
done
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
* Script to generate auto-generated Makefile
|
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:header-args: :tangle create_makefile.sh :noweb yes :shebang #!/bin/bash :comments org
|
:header-args: :tangle create_makefile.sh :noweb yes :shebang #!/bin/bash :comments org
|
||||||
:END:
|
:END:
|
||||||
@ -312,9 +226,9 @@ for i in $(ls test_qmckl_*_f.f90) ; do
|
|||||||
done >> $OUTPUT
|
done >> $OUTPUT
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Finally, we append the rules to the Makefile
|
Finally, we append the variables to the Makefile
|
||||||
|
|
||||||
#+begin_src bash
|
#+begin_src bash :noweb yes
|
||||||
cat << EOF > ${OUTPUT}
|
cat << EOF > ${OUTPUT}
|
||||||
.POSIX:
|
.POSIX:
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
@ -332,91 +246,141 @@ TESTS=$TESTS
|
|||||||
TESTS_F=$TESTS_F
|
TESTS_F=$TESTS_F
|
||||||
|
|
||||||
LIBS=$LIBS
|
LIBS=$LIBS
|
||||||
|
EOF
|
||||||
|
|
||||||
QMCKL_ROOT=\$(shell dirname \$(CURDIR))
|
echo '
|
||||||
shared_lib=\$(QMCKL_ROOT)/lib/libqmckl.so
|
<<rules>>
|
||||||
static_lib=\$(QMCKL_ROOT)/lib/libqmckl.a
|
' >> ${OUTPUT}
|
||||||
qmckl_h=\$(QMCKL_ROOT)/include/qmckl.h
|
#+end_src
|
||||||
qmckl_f=\$(QMCKL_ROOT)/share/qmckl/fortran/qmckl_f.f90
|
|
||||||
munit=\$(QMCKL_ROOT)/munit/munit.c
|
and the rules:
|
||||||
|
|
||||||
|
#+NAME: rules
|
||||||
|
#+begin_src makefile :tangle no
|
||||||
|
QMCKL_ROOT=$(shell dirname $(CURDIR))
|
||||||
|
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
|
||||||
|
munit=$(QMCKL_ROOT)/munit/munit.c
|
||||||
|
|
||||||
package=qmckl
|
package=qmckl
|
||||||
datarootdir=\$(prefix)/share
|
datarootdir=$(prefix)/share
|
||||||
datadir=\$(datarootdir)
|
datadir=$(datarootdir)
|
||||||
docdir=\$(datarootdir)/doc/\$(package)
|
docdir=$(datarootdir)/doc/$(package)
|
||||||
htmldir=\$(docdir)/html
|
htmldir=$(docdir)/html
|
||||||
libdir=\$(prefix)/lib
|
libdir=$(prefix)/lib
|
||||||
includedir=\$(prefix)/include
|
includedir=$(prefix)/include
|
||||||
fortrandir=\$(datarootdir)/\$(package)/fortran
|
fortrandir=$(datarootdir)/$(package)/fortran
|
||||||
|
|
||||||
|
|
||||||
|
shared: $(shared_lib)
|
||||||
|
static: $(static_lib)
|
||||||
|
|
||||||
shared: \$(shared_lib)
|
|
||||||
static: \$(static_lib)
|
|
||||||
|
|
||||||
|
|
||||||
all: shared static
|
all: shared static
|
||||||
|
|
||||||
\$(shared_lib): \$(OBJECT_FILES)
|
$(shared_lib): $(OBJECT_FILES)
|
||||||
\$(CC) -shared \$(OBJECT_FILES) -o \$(shared_lib)
|
$(CC) -shared $(OBJECT_FILES) -o $(shared_lib)
|
||||||
|
|
||||||
\$(static_lib): \$(OBJECT_FILES)
|
$(static_lib): $(OBJECT_FILES)
|
||||||
\$(AR) rcs \$(static_lib) \$(OBJECT_FILES)
|
$(AR) rcs $(static_lib) $(OBJECT_FILES)
|
||||||
|
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
|
|
||||||
qmckl_f.o: \$(qmckl_f)
|
qmckl_f.o: $(qmckl_f)
|
||||||
\$(FC) \$(FFLAGS) -c \$(qmckl_f) -o \$@
|
$(FC) $(FFLAGS) -c $(qmckl_f) -o $@
|
||||||
|
|
||||||
test_qmckl: test_qmckl.c \$(qmckl_h) \$(static_lib) \$(TESTS) \$(TESTS_F)
|
test_qmckl: test_qmckl.c $(qmckl_h) $(static_lib) $(TESTS) $(TESTS_F)
|
||||||
\$(CC) \$(CFLAGS) \
|
$(CC) $(CFLAGS) $(munit) $(TESTS) $(TESTS_F) $(static_lib) $(LIBS) test_qmckl.c -o $@
|
||||||
\$(munit) \$(TESTS) \$(TESTS_F) \$(static_lib) \$(LIBS) test_qmckl.c -o \$@
|
|
||||||
|
|
||||||
test_qmckl_shared: test_qmckl.c \$(qmckl_h) \$(shared_lib) \$(TESTS) \$(TESTS_F)
|
test_qmckl_shared: test_qmckl.c $(qmckl_h) $(shared_lib) $(TESTS) $(TESTS_F)
|
||||||
\$(CC) \$(CFLAGS) -Wl,-rpath,\$(QMCKL_ROOT)/lib -L\$(QMCKL_ROOT)/lib \
|
$(CC) $(CFLAGS) -Wl,-rpath,$(QMCKL_ROOT)/lib -L$(QMCKL_ROOT)/lib \
|
||||||
\$(munit) \$(TESTS) \$(TESTS_F) -lqmckl \$(LIBS) test_qmckl.c -o \$@
|
$(munit) $(TESTS) $(TESTS_F) -lqmckl $(LIBS) test_qmckl.c -o $@
|
||||||
|
|
||||||
check: test_qmckl test_qmckl_shared
|
check: test_qmckl test_qmckl_shared
|
||||||
./test_qmckl
|
./test_qmckl
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
\$(RM) -- *.o *.mod \$(shared_lib) \$(static_lib) test_qmckl
|
$(RM) -- *.o *.mod $(shared_lib) $(static_lib) test_qmckl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
install -d \$(DESTDIR)\$(prefix)/lib
|
install -d $(DESTDIR)$(prefix)/lib
|
||||||
install -d \$(DESTDIR)\$(prefix)/include
|
install -d $(DESTDIR)$(prefix)/include
|
||||||
install -d \$(DESTDIR)\$(prefix)/share/qmckl/fortran
|
install -d $(DESTDIR)$(prefix)/share/qmckl/fortran
|
||||||
install -d \$(DESTDIR)\$(prefix)/share/doc/qmckl/html/
|
install -d $(DESTDIR)$(prefix)/share/doc/qmckl/html/
|
||||||
install -d \$(DESTDIR)\$(prefix)/share/doc/qmckl/text/
|
install -d $(DESTDIR)$(prefix)/share/doc/qmckl/text/
|
||||||
install \$(shared_lib) \$(DESTDIR)\$(libdir)/
|
install $(shared_lib) $(DESTDIR)$(libdir)/
|
||||||
install \$(static_lib) \$(DESTDIR)\$(libdir)/
|
install $(static_lib) $(DESTDIR)$(libdir)/
|
||||||
install \$(qmckl_h) \$(DESTDIR)\$(includedir)
|
install $(qmckl_h) $(DESTDIR)$(includedir)
|
||||||
install \$(qmckl_f) \$(DESTDIR)\$(fortrandir)
|
install $(qmckl_f) $(DESTDIR)$(fortrandir)
|
||||||
install \$(QMCKL_ROOT)/share/doc/qmckl/html/*.html \$(DESTDIR)\$(docdir)/html/
|
install $(QMCKL_ROOT)/share/doc/qmckl/html/*.html $(DESTDIR)$(docdir)/html/
|
||||||
install \$(QMCKL_ROOT)/share/doc/qmckl/html/*.css \$(DESTDIR)\$(docdir)/html/
|
install $(QMCKL_ROOT)/share/doc/qmckl/html/*.css $(DESTDIR)$(docdir)/html/
|
||||||
install \$(QMCKL_ROOT)/share/doc/qmckl/text/*.txt \$(DESTDIR)\$(docdir)/text/
|
install $(QMCKL_ROOT)/share/doc/qmckl/text/*.txt $(DESTDIR)$(docdir)/text/
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm \$(DESTDIR)\$(libdir)/libqmckl.so
|
rm $(DESTDIR)$(libdir)/libqmckl.so
|
||||||
rm \$(DESTDIR)\$(libdir)/libqmckl.a
|
rm $(DESTDIR)$(libdir)/libqmckl.a
|
||||||
rm \$(DESTDIR)\$(includedir)/qmckl.h
|
rm $(DESTDIR)$(includedir)/qmckl.h
|
||||||
rm -rf \$(DESTDIR)\$(datarootdir)/\$(package)
|
rm -rf $(DESTDIR)$(datarootdir)/$(package)
|
||||||
rm -rf \$(DESTDIR)\$(docdir)
|
rm -rf $(DESTDIR)$(docdir)
|
||||||
|
|
||||||
.SUFFIXES: .c .f90 .o
|
.SUFFIXES: .c .f90 .o
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
\$(CC) \$(CFLAGS) -c \$*.c -o \$*.o
|
$(CC) $(CFLAGS) -c $*.c -o $*.o
|
||||||
|
|
||||||
.f90.o: qmckl_f.o
|
.f90.o: qmckl_f.o
|
||||||
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o
|
$(FC) $(FFLAGS) -c $*.f90 -o $*.o
|
||||||
|
|
||||||
.PHONY: check cppcheck clean all
|
.PHONY: check cppcheck clean all
|
||||||
EOF
|
#+end_src
|
||||||
|
|
||||||
|
* Script to tangle the org-mode files
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args: :tangle tangle.sh :noweb yes :shebang #!/bin/bash :comments org
|
||||||
|
:END:
|
||||||
|
|
||||||
|
#+begin_src bash
|
||||||
|
# <<header()>>
|
||||||
|
|
||||||
|
<<check_src>>
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
This file needs to be run from the QMCKL =src= directory.
|
||||||
|
|
||||||
|
It tangles all the files in the directory. It uses the
|
||||||
|
=config_tangle.el= file, which contains information required to
|
||||||
|
compute the current file names using for example ~(eval c)~ to get
|
||||||
|
the name of the produced C file.
|
||||||
|
|
||||||
|
The file is not tangled if the last modification date of the org
|
||||||
|
file is less recent than one of the tangled files.
|
||||||
|
|
||||||
|
#+begin_src bash
|
||||||
|
function tangle()
|
||||||
|
{
|
||||||
|
local org_file=$1
|
||||||
|
local c_file=${org_file%.org}.c
|
||||||
|
local f_file=${org_file%.org}.f90
|
||||||
|
|
||||||
|
if [[ ${org_file} -ot ${c_file} ]] ; then
|
||||||
|
return
|
||||||
|
elif [[ ${org_file} -ot ${f_file} ]] ; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
emacs --batch ${org_file} --load=../tools/config_tangle.el -f org-babel-tangle
|
||||||
|
}
|
||||||
|
|
||||||
|
for i in $@
|
||||||
|
do
|
||||||
|
echo "--- ${i} ----"
|
||||||
|
tangle ${i}
|
||||||
|
done
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* Script to build the final qmckl.h file
|
* Script to build the final qmckl.h file
|
||||||
|
@ -59,7 +59,7 @@ done >> $OUTPUT
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Finally, we append the rules to the Makefile
|
# Finally, we append the variables to the Makefile
|
||||||
|
|
||||||
|
|
||||||
cat << EOF > ${OUTPUT}
|
cat << EOF > ${OUTPUT}
|
||||||
@ -79,87 +79,88 @@ TESTS=$TESTS
|
|||||||
TESTS_F=$TESTS_F
|
TESTS_F=$TESTS_F
|
||||||
|
|
||||||
LIBS=$LIBS
|
LIBS=$LIBS
|
||||||
|
EOF
|
||||||
|
|
||||||
QMCKL_ROOT=\$(shell dirname \$(CURDIR))
|
echo '
|
||||||
shared_lib=\$(QMCKL_ROOT)/lib/libqmckl.so
|
QMCKL_ROOT=$(shell dirname $(CURDIR))
|
||||||
static_lib=\$(QMCKL_ROOT)/lib/libqmckl.a
|
shared_lib=$(QMCKL_ROOT)/lib/libqmckl.so
|
||||||
qmckl_h=\$(QMCKL_ROOT)/include/qmckl.h
|
static_lib=$(QMCKL_ROOT)/lib/libqmckl.a
|
||||||
qmckl_f=\$(QMCKL_ROOT)/share/qmckl/fortran/qmckl_f.f90
|
qmckl_h=$(QMCKL_ROOT)/include/qmckl.h
|
||||||
munit=\$(QMCKL_ROOT)/munit/munit.c
|
qmckl_f=$(QMCKL_ROOT)/share/qmckl/fortran/qmckl_f.f90
|
||||||
|
munit=$(QMCKL_ROOT)/munit/munit.c
|
||||||
|
|
||||||
package=qmckl
|
package=qmckl
|
||||||
datarootdir=\$(prefix)/share
|
datarootdir=$(prefix)/share
|
||||||
datadir=\$(datarootdir)
|
datadir=$(datarootdir)
|
||||||
docdir=\$(datarootdir)/doc/\$(package)
|
docdir=$(datarootdir)/doc/$(package)
|
||||||
htmldir=\$(docdir)/html
|
htmldir=$(docdir)/html
|
||||||
libdir=\$(prefix)/lib
|
libdir=$(prefix)/lib
|
||||||
includedir=\$(prefix)/include
|
includedir=$(prefix)/include
|
||||||
fortrandir=\$(datarootdir)/\$(package)/fortran
|
fortrandir=$(datarootdir)/$(package)/fortran
|
||||||
|
|
||||||
|
|
||||||
|
shared: $(shared_lib)
|
||||||
|
static: $(static_lib)
|
||||||
|
|
||||||
shared: \$(shared_lib)
|
|
||||||
static: \$(static_lib)
|
|
||||||
|
|
||||||
|
|
||||||
all: shared static
|
all: shared static
|
||||||
|
|
||||||
\$(shared_lib): \$(OBJECT_FILES)
|
$(shared_lib): $(OBJECT_FILES)
|
||||||
\$(CC) -shared \$(OBJECT_FILES) -o \$(shared_lib)
|
$(CC) -shared $(OBJECT_FILES) -o $(shared_lib)
|
||||||
|
|
||||||
\$(static_lib): \$(OBJECT_FILES)
|
$(static_lib): $(OBJECT_FILES)
|
||||||
\$(AR) rcs \$(static_lib) \$(OBJECT_FILES)
|
$(AR) rcs $(static_lib) $(OBJECT_FILES)
|
||||||
|
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
|
|
||||||
qmckl_f.o: \$(qmckl_f)
|
qmckl_f.o: $(qmckl_f)
|
||||||
\$(FC) \$(FFLAGS) -c \$(qmckl_f) -o \$@
|
$(FC) $(FFLAGS) -c $(qmckl_f) -o $@
|
||||||
|
|
||||||
test_qmckl: test_qmckl.c \$(qmckl_h) \$(static_lib) \$(TESTS) \$(TESTS_F)
|
test_qmckl: test_qmckl.c $(qmckl_h) $(static_lib) $(TESTS) $(TESTS_F)
|
||||||
\$(CC) \$(CFLAGS) \
|
$(CC) $(CFLAGS) $(munit) $(TESTS) $(TESTS_F) $(static_lib) $(LIBS) test_qmckl.c -o $@
|
||||||
\$(munit) \$(TESTS) \$(TESTS_F) \$(static_lib) \$(LIBS) test_qmckl.c -o \$@
|
|
||||||
|
|
||||||
test_qmckl_shared: test_qmckl.c \$(qmckl_h) \$(shared_lib) \$(TESTS) \$(TESTS_F)
|
test_qmckl_shared: test_qmckl.c $(qmckl_h) $(shared_lib) $(TESTS) $(TESTS_F)
|
||||||
\$(CC) \$(CFLAGS) -Wl,-rpath,\$(QMCKL_ROOT)/lib -L\$(QMCKL_ROOT)/lib \
|
$(CC) $(CFLAGS) -Wl,-rpath,$(QMCKL_ROOT)/lib -L$(QMCKL_ROOT)/lib \
|
||||||
\$(munit) \$(TESTS) \$(TESTS_F) -lqmckl \$(LIBS) test_qmckl.c -o \$@
|
$(munit) $(TESTS) $(TESTS_F) -lqmckl $(LIBS) test_qmckl.c -o $@
|
||||||
|
|
||||||
check: test_qmckl test_qmckl_shared
|
check: test_qmckl test_qmckl_shared
|
||||||
./test_qmckl
|
./test_qmckl
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
\$(RM) -- *.o *.mod \$(shared_lib) \$(static_lib) test_qmckl
|
$(RM) -- *.o *.mod $(shared_lib) $(static_lib) test_qmckl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
install -d \$(DESTDIR)\$(prefix)/lib
|
install -d $(DESTDIR)$(prefix)/lib
|
||||||
install -d \$(DESTDIR)\$(prefix)/include
|
install -d $(DESTDIR)$(prefix)/include
|
||||||
install -d \$(DESTDIR)\$(prefix)/share/qmckl/fortran
|
install -d $(DESTDIR)$(prefix)/share/qmckl/fortran
|
||||||
install -d \$(DESTDIR)\$(prefix)/share/doc/qmckl/html/
|
install -d $(DESTDIR)$(prefix)/share/doc/qmckl/html/
|
||||||
install -d \$(DESTDIR)\$(prefix)/share/doc/qmckl/text/
|
install -d $(DESTDIR)$(prefix)/share/doc/qmckl/text/
|
||||||
install \$(shared_lib) \$(DESTDIR)\$(libdir)/
|
install $(shared_lib) $(DESTDIR)$(libdir)/
|
||||||
install \$(static_lib) \$(DESTDIR)\$(libdir)/
|
install $(static_lib) $(DESTDIR)$(libdir)/
|
||||||
install \$(qmckl_h) \$(DESTDIR)\$(includedir)
|
install $(qmckl_h) $(DESTDIR)$(includedir)
|
||||||
install \$(qmckl_f) \$(DESTDIR)\$(fortrandir)
|
install $(qmckl_f) $(DESTDIR)$(fortrandir)
|
||||||
install \$(QMCKL_ROOT)/share/doc/qmckl/html/*.html \$(DESTDIR)\$(docdir)/html/
|
install $(QMCKL_ROOT)/share/doc/qmckl/html/*.html $(DESTDIR)$(docdir)/html/
|
||||||
install \$(QMCKL_ROOT)/share/doc/qmckl/html/*.css \$(DESTDIR)\$(docdir)/html/
|
install $(QMCKL_ROOT)/share/doc/qmckl/html/*.css $(DESTDIR)$(docdir)/html/
|
||||||
install \$(QMCKL_ROOT)/share/doc/qmckl/text/*.txt \$(DESTDIR)\$(docdir)/text/
|
install $(QMCKL_ROOT)/share/doc/qmckl/text/*.txt $(DESTDIR)$(docdir)/text/
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm \$(DESTDIR)\$(libdir)/libqmckl.so
|
rm $(DESTDIR)$(libdir)/libqmckl.so
|
||||||
rm \$(DESTDIR)\$(libdir)/libqmckl.a
|
rm $(DESTDIR)$(libdir)/libqmckl.a
|
||||||
rm \$(DESTDIR)\$(includedir)/qmckl.h
|
rm $(DESTDIR)$(includedir)/qmckl.h
|
||||||
rm -rf \$(DESTDIR)\$(datarootdir)/\$(package)
|
rm -rf $(DESTDIR)$(datarootdir)/$(package)
|
||||||
rm -rf \$(DESTDIR)\$(docdir)
|
rm -rf $(DESTDIR)$(docdir)
|
||||||
|
|
||||||
.SUFFIXES: .c .f90 .o
|
.SUFFIXES: .c .f90 .o
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
\$(CC) \$(CFLAGS) -c \$*.c -o \$*.o
|
$(CC) $(CFLAGS) -c $*.c -o $*.o
|
||||||
|
|
||||||
.f90.o: qmckl_f.o
|
.f90.o: qmckl_f.o
|
||||||
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o
|
$(FC) $(FFLAGS) -c $*.f90 -o $*.o
|
||||||
|
|
||||||
.PHONY: check cppcheck clean all
|
.PHONY: check cppcheck clean all
|
||||||
EOF
|
' >> ${OUTPUT}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user