mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2025-04-17 14:10:11 +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
|
||||
#+STARTUP: indent overview
|
||||
#+PROPERTY: header-args: :comments both
|
||||
|
||||
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
|
||||
|
||||
* Makefile
|
||||
:PROPERTIES:
|
||||
:header-args: :tangle ../src/Makefile :noweb yes :comments org
|
||||
:END:
|
||||
* Makefiles
|
||||
** Makefile.in
|
||||
:PROPERTIES:
|
||||
:header-args: :tangle ../src/Makefile.in :noweb yes :comments org
|
||||
:END:
|
||||
|
||||
This is the main Makefile invoked by the ~make~ command.
|
||||
The Makefile compiling the library is =Makefile.generated=, and is
|
||||
generated by the script detailed in the next section.
|
||||
** Header :noexport:
|
||||
This is the main Makefile invoked by the ~make~ command at the root
|
||||
of the package. To compile the sources, it calls the =Makefile=
|
||||
located in the =src= directory. This Makefile creates the source
|
||||
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()>>
|
||||
|
||||
.POSIX:
|
||||
#+end_src
|
||||
** Dependencies
|
||||
#+end_src
|
||||
|
||||
#+begin_src makefile
|
||||
LIBS=-lpthread
|
||||
#+end_src
|
||||
*** Compiler options
|
||||
|
||||
** 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))
|
||||
|
||||
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
|
||||
|
||||
ORG_SOURCE_FILES=$(wildcard *.org)
|
||||
ORG_SOURCE_FILES=$(wildcard $(QMCKL_ROOT)/*.org)
|
||||
C_SOURCE_FILES=$(patsubst %.org,%.c,$(ORG_SOURCE_FILES))
|
||||
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
|
||||
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
|
||||
#+begin_src makefile
|
||||
.PHONY: clean shared static doc all check install uninstall
|
||||
.SECONDARY: # Needed to keep the produced C and Fortran files
|
||||
|
||||
@ -183,11 +138,13 @@ all: shared static doc check
|
||||
check: $(static_lib)
|
||||
$(MAKE) -f Makefile.generated check
|
||||
|
||||
ifeq ($(HAS_CPPCHECK),1)
|
||||
cppcheck:
|
||||
cppcheck \
|
||||
--addon=cert \
|
||||
--enable=warning,style,performance,portability,information \
|
||||
qmckl_*.c
|
||||
--addon=cert \
|
||||
--enable=warning,style,performance,portability,information \
|
||||
qmckl_*.c
|
||||
endif
|
||||
|
||||
doc: $(ORG_SOURCE_FILES)
|
||||
$(QMCKL_ROOT)/tools/build_doc.sh
|
||||
@ -201,7 +158,7 @@ clean:
|
||||
|
||||
veryclean: clean FORCE
|
||||
- $(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
|
||||
$(QMCKL_ROOT)/tools/create_makefile.sh
|
||||
@ -212,52 +169,9 @@ Makefile.generated: Makefile $(QMCKL_ROOT)/tools/create_makefile.sh $(ORG_SOURC
|
||||
.org.c:
|
||||
$(QMCKL_ROOT)/tools/tangle.sh $<
|
||||
|
||||
#+end_src
|
||||
#+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
|
||||
|
||||
* Script to generate auto-generated Makefile
|
||||
** Script to generate auto-generated Makefile
|
||||
:PROPERTIES:
|
||||
:header-args: :tangle create_makefile.sh :noweb yes :shebang #!/bin/bash :comments org
|
||||
:END:
|
||||
@ -312,9 +226,9 @@ for i in $(ls test_qmckl_*_f.f90) ; do
|
||||
done >> $OUTPUT
|
||||
#+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}
|
||||
.POSIX:
|
||||
.SUFFIXES:
|
||||
@ -332,91 +246,141 @@ TESTS=$TESTS
|
||||
TESTS_F=$TESTS_F
|
||||
|
||||
LIBS=$LIBS
|
||||
EOF
|
||||
|
||||
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
|
||||
echo '
|
||||
<<rules>>
|
||||
' >> ${OUTPUT}
|
||||
#+end_src
|
||||
|
||||
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
|
||||
datarootdir=\$(prefix)/share
|
||||
datadir=\$(datarootdir)
|
||||
docdir=\$(datarootdir)/doc/\$(package)
|
||||
htmldir=\$(docdir)/html
|
||||
libdir=\$(prefix)/lib
|
||||
includedir=\$(prefix)/include
|
||||
fortrandir=\$(datarootdir)/\$(package)/fortran
|
||||
|
||||
datarootdir=$(prefix)/share
|
||||
datadir=$(datarootdir)
|
||||
docdir=$(datarootdir)/doc/$(package)
|
||||
htmldir=$(docdir)/html
|
||||
libdir=$(prefix)/lib
|
||||
includedir=$(prefix)/include
|
||||
fortrandir=$(datarootdir)/$(package)/fortran
|
||||
|
||||
|
||||
shared: $(shared_lib)
|
||||
static: $(static_lib)
|
||||
|
||||
shared: \$(shared_lib)
|
||||
static: \$(static_lib)
|
||||
|
||||
|
||||
all: shared static
|
||||
|
||||
\$(shared_lib): \$(OBJECT_FILES)
|
||||
\$(CC) -shared \$(OBJECT_FILES) -o \$(shared_lib)
|
||||
$(shared_lib): $(OBJECT_FILES)
|
||||
$(CC) -shared $(OBJECT_FILES) -o $(shared_lib)
|
||||
|
||||
\$(static_lib): \$(OBJECT_FILES)
|
||||
\$(AR) rcs \$(static_lib) \$(OBJECT_FILES)
|
||||
$(static_lib): $(OBJECT_FILES)
|
||||
$(AR) rcs $(static_lib) $(OBJECT_FILES)
|
||||
|
||||
|
||||
# Test
|
||||
|
||||
qmckl_f.o: \$(qmckl_f)
|
||||
\$(FC) \$(FFLAGS) -c \$(qmckl_f) -o \$@
|
||||
qmckl_f.o: $(qmckl_f)
|
||||
$(FC) $(FFLAGS) -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) test_qmckl.c -o \$@
|
||||
test_qmckl: test_qmckl.c $(qmckl_h) $(static_lib) $(TESTS) $(TESTS_F)
|
||||
$(CC) $(CFLAGS) $(munit) $(TESTS) $(TESTS_F) $(static_lib) $(LIBS) 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) 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) test_qmckl.c -o $@
|
||||
|
||||
check: test_qmckl test_qmckl_shared
|
||||
./test_qmckl
|
||||
|
||||
clean:
|
||||
\$(RM) -- *.o *.mod \$(shared_lib) \$(static_lib) test_qmckl
|
||||
$(RM) -- *.o *.mod $(shared_lib) $(static_lib) test_qmckl
|
||||
|
||||
|
||||
|
||||
|
||||
install:
|
||||
install -d \$(DESTDIR)\$(prefix)/lib
|
||||
install -d \$(DESTDIR)\$(prefix)/include
|
||||
install -d \$(DESTDIR)\$(prefix)/share/qmckl/fortran
|
||||
install -d \$(DESTDIR)\$(prefix)/share/doc/qmckl/html/
|
||||
install -d \$(DESTDIR)\$(prefix)/share/doc/qmckl/text/
|
||||
install \$(shared_lib) \$(DESTDIR)\$(libdir)/
|
||||
install \$(static_lib) \$(DESTDIR)\$(libdir)/
|
||||
install \$(qmckl_h) \$(DESTDIR)\$(includedir)
|
||||
install \$(qmckl_f) \$(DESTDIR)\$(fortrandir)
|
||||
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/text/*.txt \$(DESTDIR)\$(docdir)/text/
|
||||
install -d $(DESTDIR)$(prefix)/lib
|
||||
install -d $(DESTDIR)$(prefix)/include
|
||||
install -d $(DESTDIR)$(prefix)/share/qmckl/fortran
|
||||
install -d $(DESTDIR)$(prefix)/share/doc/qmckl/html/
|
||||
install -d $(DESTDIR)$(prefix)/share/doc/qmckl/text/
|
||||
install $(shared_lib) $(DESTDIR)$(libdir)/
|
||||
install $(static_lib) $(DESTDIR)$(libdir)/
|
||||
install $(qmckl_h) $(DESTDIR)$(includedir)
|
||||
install $(qmckl_f) $(DESTDIR)$(fortrandir)
|
||||
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/text/*.txt $(DESTDIR)$(docdir)/text/
|
||||
|
||||
uninstall:
|
||||
rm \$(DESTDIR)\$(libdir)/libqmckl.so
|
||||
rm \$(DESTDIR)\$(libdir)/libqmckl.a
|
||||
rm \$(DESTDIR)\$(includedir)/qmckl.h
|
||||
rm -rf \$(DESTDIR)\$(datarootdir)/\$(package)
|
||||
rm -rf \$(DESTDIR)\$(docdir)
|
||||
rm $(DESTDIR)$(libdir)/libqmckl.so
|
||||
rm $(DESTDIR)$(libdir)/libqmckl.a
|
||||
rm $(DESTDIR)$(includedir)/qmckl.h
|
||||
rm -rf $(DESTDIR)$(datarootdir)/$(package)
|
||||
rm -rf $(DESTDIR)$(docdir)
|
||||
|
||||
.SUFFIXES: .c .f90 .o
|
||||
|
||||
.c.o:
|
||||
\$(CC) \$(CFLAGS) -c \$*.c -o \$*.o
|
||||
$(CC) $(CFLAGS) -c $*.c -o $*.o
|
||||
|
||||
.f90.o: qmckl_f.o
|
||||
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o
|
||||
$(FC) $(FFLAGS) -c $*.f90 -o $*.o
|
||||
|
||||
.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
|
||||
|
||||
* 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}
|
||||
@ -79,87 +79,88 @@ TESTS=$TESTS
|
||||
TESTS_F=$TESTS_F
|
||||
|
||||
LIBS=$LIBS
|
||||
EOF
|
||||
|
||||
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
|
||||
echo '
|
||||
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
|
||||
datarootdir=\$(prefix)/share
|
||||
datadir=\$(datarootdir)
|
||||
docdir=\$(datarootdir)/doc/\$(package)
|
||||
htmldir=\$(docdir)/html
|
||||
libdir=\$(prefix)/lib
|
||||
includedir=\$(prefix)/include
|
||||
fortrandir=\$(datarootdir)/\$(package)/fortran
|
||||
|
||||
datarootdir=$(prefix)/share
|
||||
datadir=$(datarootdir)
|
||||
docdir=$(datarootdir)/doc/$(package)
|
||||
htmldir=$(docdir)/html
|
||||
libdir=$(prefix)/lib
|
||||
includedir=$(prefix)/include
|
||||
fortrandir=$(datarootdir)/$(package)/fortran
|
||||
|
||||
|
||||
shared: $(shared_lib)
|
||||
static: $(static_lib)
|
||||
|
||||
shared: \$(shared_lib)
|
||||
static: \$(static_lib)
|
||||
|
||||
|
||||
all: shared static
|
||||
|
||||
\$(shared_lib): \$(OBJECT_FILES)
|
||||
\$(CC) -shared \$(OBJECT_FILES) -o \$(shared_lib)
|
||||
$(shared_lib): $(OBJECT_FILES)
|
||||
$(CC) -shared $(OBJECT_FILES) -o $(shared_lib)
|
||||
|
||||
\$(static_lib): \$(OBJECT_FILES)
|
||||
\$(AR) rcs \$(static_lib) \$(OBJECT_FILES)
|
||||
$(static_lib): $(OBJECT_FILES)
|
||||
$(AR) rcs $(static_lib) $(OBJECT_FILES)
|
||||
|
||||
|
||||
# Test
|
||||
|
||||
qmckl_f.o: \$(qmckl_f)
|
||||
\$(FC) \$(FFLAGS) -c \$(qmckl_f) -o \$@
|
||||
qmckl_f.o: $(qmckl_f)
|
||||
$(FC) $(FFLAGS) -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) test_qmckl.c -o \$@
|
||||
test_qmckl: test_qmckl.c $(qmckl_h) $(static_lib) $(TESTS) $(TESTS_F)
|
||||
$(CC) $(CFLAGS) $(munit) $(TESTS) $(TESTS_F) $(static_lib) $(LIBS) 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) 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) test_qmckl.c -o $@
|
||||
|
||||
check: test_qmckl test_qmckl_shared
|
||||
./test_qmckl
|
||||
|
||||
clean:
|
||||
\$(RM) -- *.o *.mod \$(shared_lib) \$(static_lib) test_qmckl
|
||||
$(RM) -- *.o *.mod $(shared_lib) $(static_lib) test_qmckl
|
||||
|
||||
|
||||
|
||||
|
||||
install:
|
||||
install -d \$(DESTDIR)\$(prefix)/lib
|
||||
install -d \$(DESTDIR)\$(prefix)/include
|
||||
install -d \$(DESTDIR)\$(prefix)/share/qmckl/fortran
|
||||
install -d \$(DESTDIR)\$(prefix)/share/doc/qmckl/html/
|
||||
install -d \$(DESTDIR)\$(prefix)/share/doc/qmckl/text/
|
||||
install \$(shared_lib) \$(DESTDIR)\$(libdir)/
|
||||
install \$(static_lib) \$(DESTDIR)\$(libdir)/
|
||||
install \$(qmckl_h) \$(DESTDIR)\$(includedir)
|
||||
install \$(qmckl_f) \$(DESTDIR)\$(fortrandir)
|
||||
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/text/*.txt \$(DESTDIR)\$(docdir)/text/
|
||||
install -d $(DESTDIR)$(prefix)/lib
|
||||
install -d $(DESTDIR)$(prefix)/include
|
||||
install -d $(DESTDIR)$(prefix)/share/qmckl/fortran
|
||||
install -d $(DESTDIR)$(prefix)/share/doc/qmckl/html/
|
||||
install -d $(DESTDIR)$(prefix)/share/doc/qmckl/text/
|
||||
install $(shared_lib) $(DESTDIR)$(libdir)/
|
||||
install $(static_lib) $(DESTDIR)$(libdir)/
|
||||
install $(qmckl_h) $(DESTDIR)$(includedir)
|
||||
install $(qmckl_f) $(DESTDIR)$(fortrandir)
|
||||
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/text/*.txt $(DESTDIR)$(docdir)/text/
|
||||
|
||||
uninstall:
|
||||
rm \$(DESTDIR)\$(libdir)/libqmckl.so
|
||||
rm \$(DESTDIR)\$(libdir)/libqmckl.a
|
||||
rm \$(DESTDIR)\$(includedir)/qmckl.h
|
||||
rm -rf \$(DESTDIR)\$(datarootdir)/\$(package)
|
||||
rm -rf \$(DESTDIR)\$(docdir)
|
||||
rm $(DESTDIR)$(libdir)/libqmckl.so
|
||||
rm $(DESTDIR)$(libdir)/libqmckl.a
|
||||
rm $(DESTDIR)$(includedir)/qmckl.h
|
||||
rm -rf $(DESTDIR)$(datarootdir)/$(package)
|
||||
rm -rf $(DESTDIR)$(docdir)
|
||||
|
||||
.SUFFIXES: .c .f90 .o
|
||||
|
||||
.c.o:
|
||||
\$(CC) \$(CFLAGS) -c \$*.c -o \$*.o
|
||||
$(CC) $(CFLAGS) -c $*.c -o $*.o
|
||||
|
||||
.f90.o: qmckl_f.o
|
||||
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o
|
||||
$(FC) $(FFLAGS) -c $*.f90 -o $*.o
|
||||
|
||||
.PHONY: check cppcheck clean all
|
||||
EOF
|
||||
.PHONY: check cppcheck clean all
|
||||
' >> ${OUTPUT}
|
||||
|
Loading…
x
Reference in New Issue
Block a user