mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2025-01-03 10:06:09 +01:00
Cleaned Makefiles
This commit is contained in:
parent
afd3f6ae7a
commit
3618cde7b1
2
.github/workflows/test-build.yml
vendored
2
.github/workflows/test-build.yml
vendored
@ -37,4 +37,4 @@ jobs:
|
||||
git submodule sync
|
||||
git submodule update --init --recursive
|
||||
- name: make
|
||||
run: make -C src/ test
|
||||
run: make -C src/ check
|
||||
|
41
src/Makefile
41
src/Makefile
@ -3,6 +3,8 @@
|
||||
|
||||
# This file was created by tools/Building.org
|
||||
|
||||
.POSIX:
|
||||
|
||||
# Dependencies
|
||||
|
||||
|
||||
@ -13,10 +15,15 @@ LIBS=-lpthread
|
||||
|
||||
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)/include/qmckl_f.f90
|
||||
|
||||
export CC CFLAGS FC FFLAGS LIBS QMCKL_ROOT
|
||||
|
||||
ORG_SOURCE_FILES=$(wildcard *.org)
|
||||
OBJECT_FILES=$(filter-out $(EXCLUDED_OBJECTS), $(patsubst %.org,%.o,$(ORG_SOURCE_FILES)))
|
||||
C_SOURCE_FILES=$(patsubst %.org,%.c,$(ORG_SOURCE_FILES))
|
||||
INCLUDE=-I$(QMCKL_ROOT)/include/
|
||||
|
||||
# Compiler options
|
||||
@ -82,27 +89,41 @@ endif
|
||||
# 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.
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
.PHONY: clean shared static doc all check
|
||||
.SECONDARY: # Needed to keep the produced C and Fortran files
|
||||
|
||||
libqmckl.so: ../include/qmckl.h
|
||||
$(MAKE) -f Makefile.generated
|
||||
$(shared_lib) $(static_lib): $(qmckl_h) $(qmckl_f) Makefile.generated
|
||||
$(MAKE) -f Makefile.generated $@
|
||||
|
||||
../include/qmckl.h: Makefile.generated
|
||||
$(qmckl_f) $(qmckl_h): Makefile.generated
|
||||
../tools/build_qmckl_h.sh
|
||||
|
||||
test: libqmckl.so
|
||||
$(MAKE) -f Makefile.generated test
|
||||
shared: $(shared_lib)
|
||||
static: $(static_lib)
|
||||
all: shared static doc
|
||||
|
||||
check: $(static_lib)
|
||||
$(MAKE) -f Makefile.generated check
|
||||
|
||||
doc: $(ORG_SOURCE_FILES)
|
||||
$(QMCKL_ROOT)/tools/build_doc.sh
|
||||
|
||||
clean:
|
||||
$(RM) test_qmckl_* test_qmckl.c test_qmckl \
|
||||
qmckl_*.f90 qmckl_*.c qmckl_*.o qmckl_*.h \
|
||||
Makefile.generated libqmckl.so *.html *.mod
|
||||
- $(MAKE) -f Makefile.generated clean
|
||||
- $(RM) test_qmckl_* test_qmckl.c \
|
||||
$(qmckl_h) $(qmckl_f) \
|
||||
qmckl_*.f90 qmckl_*.c qmckl_*.h \
|
||||
Makefile.generated *.html
|
||||
|
||||
Makefile.generated: Makefile $(QMCKL_ROOT)/tools/create_makefile.sh $(ORG_SOURCE_FILES)
|
||||
$(QMCKL_ROOT)/tools/create_makefile.sh
|
||||
|
||||
|
||||
.SUFFIXES: .org .c
|
||||
|
||||
.org.c:
|
||||
../tools/tangle.sh $<
|
||||
|
||||
|
@ -68,6 +68,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#+begin_src makefile
|
||||
# <<header()>>
|
||||
|
||||
.POSIX:
|
||||
#+end_src
|
||||
** Dependencies
|
||||
|
||||
@ -80,10 +82,15 @@ LIBS=-lpthread
|
||||
#+begin_src makefile
|
||||
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)/include/qmckl_f.f90
|
||||
|
||||
export CC CFLAGS FC FFLAGS LIBS QMCKL_ROOT
|
||||
|
||||
ORG_SOURCE_FILES=$(wildcard *.org)
|
||||
OBJECT_FILES=$(filter-out $(EXCLUDED_OBJECTS), $(patsubst %.org,%.o,$(ORG_SOURCE_FILES)))
|
||||
C_SOURCE_FILES=$(patsubst %.org,%.c,$(ORG_SOURCE_FILES))
|
||||
INCLUDE=-I$(QMCKL_ROOT)/include/
|
||||
#+end_src
|
||||
|
||||
@ -154,30 +161,44 @@ endif
|
||||
** 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
|
||||
.PHONY: clean shared static doc all check
|
||||
.SECONDARY: # Needed to keep the produced C and Fortran files
|
||||
|
||||
libqmckl.so: ../include/qmckl.h
|
||||
$(MAKE) -f Makefile.generated
|
||||
$(shared_lib) $(static_lib): $(qmckl_h) $(qmckl_f) Makefile.generated
|
||||
$(MAKE) -f Makefile.generated $@
|
||||
|
||||
../include/qmckl.h: Makefile.generated
|
||||
../tools/build_qmckl_h.sh
|
||||
$(qmckl_f) $(qmckl_h): Makefile.generated
|
||||
$(QMCKL_ROOT)/tools/build_qmckl_h.sh
|
||||
|
||||
test: libqmckl.so
|
||||
$(MAKE) -f Makefile.generated test
|
||||
shared: $(shared_lib)
|
||||
static: $(static_lib)
|
||||
all: shared static doc
|
||||
|
||||
check: $(static_lib)
|
||||
$(MAKE) -f Makefile.generated check
|
||||
|
||||
doc: $(ORG_SOURCE_FILES)
|
||||
$(QMCKL_ROOT)/tools/build_doc.sh
|
||||
|
||||
clean:
|
||||
$(RM) test_qmckl_* test_qmckl.c test_qmckl \
|
||||
qmckl_*.f90 qmckl_*.c qmckl_*.o qmckl_*.h \
|
||||
Makefile.generated libqmckl.so *.html *.mod
|
||||
- $(MAKE) -f Makefile.generated clean
|
||||
- $(RM) test_qmckl_* test_qmckl.c \
|
||||
$(qmckl_h) $(qmckl_f) \
|
||||
qmckl_*.f90 qmckl_*.c qmckl_*.h \
|
||||
Makefile.generated *.html
|
||||
|
||||
Makefile.generated: Makefile $(QMCKL_ROOT)/tools/create_makefile.sh $(ORG_SOURCE_FILES)
|
||||
$(QMCKL_ROOT)/tools/create_makefile.sh
|
||||
|
||||
|
||||
.SUFFIXES: .org .c
|
||||
|
||||
.org.c:
|
||||
$(QMCKL_ROOT)/tools/tangle.sh $<
|
||||
|
||||
#+end_src
|
||||
|
||||
* Script to tangle the org-mode files
|
||||
@ -244,6 +265,7 @@ OUTPUT=Makefile.generated
|
||||
|
||||
#+begin_src bash
|
||||
${QMCKL_ROOT}/tools/tangle.sh *.org
|
||||
${QMCKL_ROOT}/tools/build_qmckl_h.sh
|
||||
#+end_src
|
||||
|
||||
Then we create the list of ~*.o~ files to be created, for library
|
||||
@ -281,40 +303,69 @@ done >> $OUTPUT
|
||||
|
||||
#+begin_src bash
|
||||
cat << EOF > ${OUTPUT}
|
||||
.POSIX:
|
||||
.SUFFIXES:
|
||||
|
||||
PREFIX=/usr/local
|
||||
|
||||
CC=$CC
|
||||
CFLAGS=$CFLAGS -I../munit/
|
||||
|
||||
FC=$FC
|
||||
FFLAGS=$FFLAGS
|
||||
|
||||
OBJECT_FILES=$OBJECTS
|
||||
TESTS=$TESTS
|
||||
TESTS_F=$TESTS_F
|
||||
|
||||
LIBS=$LIBS
|
||||
|
||||
libqmckl.so: \$(OBJECT_FILES)
|
||||
\$(CC) -shared \$(OBJECT_FILES) -o libqmckl.so
|
||||
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)/include/qmckl_f.f90
|
||||
munit=\$(QMCKL_ROOT)/munit/munit.c
|
||||
|
||||
%.o: %.c
|
||||
\$(CC) \$(CFLAGS) -c \$*.c -o \$*.o
|
||||
shared: \$(shared_lib)
|
||||
static: \$(static_lib)
|
||||
all: shared static
|
||||
|
||||
%.o: %.f90 qmckl_f.o
|
||||
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o
|
||||
\$(shared_lib): \$(OBJECT_FILES)
|
||||
\$(CC) -shared \$(OBJECT_FILES) -o \$(shared_lib)
|
||||
|
||||
../include/qmckl.h ../include/qmckl_f.f90:
|
||||
../tools/build_qmckl_h.sh
|
||||
\$(static_lib): \$(OBJECT_FILES)
|
||||
\$(AR) rcs \$(static_lib) \$(OBJECT_FILES)
|
||||
|
||||
qmckl_f.o: ../include/qmckl_f.f90
|
||||
\$(FC) \$(FFLAGS) -c ../include/qmckl_f.f90 -o qmckl_f.o
|
||||
|
||||
test_qmckl: test_qmckl.c libqmckl.so \$(TESTS) \$(TESTS_F)
|
||||
\$(CC) \$(CFLAGS) -Wl,-rpath,$PWD -L. \
|
||||
../munit/munit.c \$(TESTS) \$(TESTS_F) -lqmckl \$(LIBS) test_qmckl.c -o test_qmckl
|
||||
# Test
|
||||
|
||||
test: test_qmckl
|
||||
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_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
|
||||
|
||||
.PHONY: test
|
||||
clean:
|
||||
\$(RM) -- *.o *.mod \$(shared_lib) \$(static_lib) test_qmckl
|
||||
|
||||
.SUFFIXES: .c .f90 .o
|
||||
|
||||
.c.o:
|
||||
\$(CC) \$(CFLAGS) -c \$*.c -o \$*.o
|
||||
|
||||
.f90.o: qmckl_f.o
|
||||
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o
|
||||
|
||||
.PHONY: check clean all
|
||||
EOF
|
||||
|
||||
#+end_src
|
||||
|
@ -21,6 +21,7 @@ OUTPUT=Makefile.generated
|
||||
|
||||
|
||||
${QMCKL_ROOT}/tools/tangle.sh *.org
|
||||
../tools/build_qmckl_h.sh
|
||||
|
||||
|
||||
|
||||
@ -62,38 +63,67 @@ done >> $OUTPUT
|
||||
|
||||
|
||||
cat << EOF > ${OUTPUT}
|
||||
.POSIX:
|
||||
.SUFFIXES:
|
||||
|
||||
PREFIX=/usr/local
|
||||
|
||||
CC=$CC
|
||||
CFLAGS=$CFLAGS -I../munit/
|
||||
|
||||
FC=$FC
|
||||
FFLAGS=$FFLAGS
|
||||
|
||||
OBJECT_FILES=$OBJECTS
|
||||
TESTS=$TESTS
|
||||
TESTS_F=$TESTS_F
|
||||
|
||||
LIBS=$LIBS
|
||||
|
||||
libqmckl.so: \$(OBJECT_FILES)
|
||||
\$(CC) -shared \$(OBJECT_FILES) -o libqmckl.so
|
||||
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)/include/qmckl_f.f90
|
||||
munit=\$(QMCKL_ROOT)/munit/munit.c
|
||||
|
||||
%.o: %.c
|
||||
\$(CC) \$(CFLAGS) -c \$*.c -o \$*.o
|
||||
shared: \$(shared_lib)
|
||||
static: \$(static_lib)
|
||||
all: shared static
|
||||
|
||||
%.o: %.f90 qmckl_f.o
|
||||
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o
|
||||
\$(shared_lib): \$(OBJECT_FILES)
|
||||
\$(CC) -shared \$(OBJECT_FILES) -o \$(shared_lib)
|
||||
|
||||
../include/qmckl.h ../include/qmckl_f.f90:
|
||||
../tools/build_qmckl_h.sh
|
||||
\$(static_lib): \$(OBJECT_FILES)
|
||||
\$(AR) rcs \$(static_lib) \$(OBJECT_FILES)
|
||||
|
||||
qmckl_f.o: ../include/qmckl_f.f90
|
||||
\$(FC) \$(FFLAGS) -c ../include/qmckl_f.f90 -o qmckl_f.o
|
||||
|
||||
test_qmckl: test_qmckl.c libqmckl.so \$(TESTS) \$(TESTS_F)
|
||||
\$(CC) \$(CFLAGS) -Wl,-rpath,$PWD -L. \
|
||||
../munit/munit.c \$(TESTS) \$(TESTS_F) -lqmckl \$(LIBS) test_qmckl.c -o test_qmckl
|
||||
# Test
|
||||
|
||||
test: test_qmckl
|
||||
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_shared: test_qmckl.c \$(qmckl_h) \$(shared_lib) \$(TESTS) \$(TESTS_F)
|
||||
\$(CC) \$(CFLAGS) -Wl,-rpath,$PWD/../lib -L../lib \
|
||||
\$(munit) \$(TESTS) \$(TESTS_F) -lqmckl \$(LIBS) test_qmckl.c -o \$@
|
||||
|
||||
check: test_qmckl test_qmckl_shared
|
||||
./test_qmckl
|
||||
|
||||
.PHONY: test
|
||||
clean:
|
||||
\$(RM) -- *.o *.mod \$(shared_lib) \$(static_lib) test_qmckl
|
||||
|
||||
.SUFFIXES: .c .f90 .o
|
||||
|
||||
.c.o:
|
||||
\$(CC) \$(CFLAGS) -c \$*.c -o \$*.o
|
||||
|
||||
.f90.o: qmckl_f.o
|
||||
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o
|
||||
|
||||
.PHONY: check clean all
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue
Block a user