2020-10-16 13:58:05 +02:00
|
|
|
#!/bin/bash
|
2021-03-09 01:16:23 +01:00
|
|
|
# Script to generate auto-generated Makefile
|
|
|
|
# :PROPERTIES:
|
|
|
|
# :header-args: :tangle create_makefile.sh :noweb yes :shebang #!/bin/bash :comments org
|
|
|
|
# :END:
|
|
|
|
|
|
|
|
# This script generates the Makefile that compiles the library.
|
|
|
|
# The ~OUTPUT~ variable contains the name of the generated Makefile,typically
|
|
|
|
# =Makefile.generated=.
|
2021-03-19 13:47:50 +01:00
|
|
|
|
2021-03-09 01:16:23 +01:00
|
|
|
|
|
|
|
# This file was created by tools/Building.org
|
|
|
|
|
2020-10-16 13:58:05 +02:00
|
|
|
|
2021-03-06 14:46:01 +01:00
|
|
|
|
2020-10-16 13:58:05 +02:00
|
|
|
OUTPUT=Makefile.generated
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-09 01:16:23 +01:00
|
|
|
# We start by tangling all the org-mode files.
|
|
|
|
|
|
|
|
|
|
|
|
${QMCKL_ROOT}/tools/tangle.sh *.org
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Then we create the list of ~*.o~ files to be created, for library
|
|
|
|
# functions:
|
2020-10-16 13:58:05 +02:00
|
|
|
|
|
|
|
|
2021-03-18 18:02:06 +01:00
|
|
|
OBJECTS="qmckl_f.o"
|
2021-03-19 13:47:50 +01:00
|
|
|
for i in $(ls qmckl_*.c qmckl_*f.f90) ; do
|
|
|
|
FILE=${i%.*}
|
|
|
|
OBJECTS+=" ${FILE}.o"
|
2020-10-16 13:58:05 +02:00
|
|
|
done >> $OUTPUT
|
|
|
|
|
2021-03-09 01:16:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
# for tests in C:
|
|
|
|
|
|
|
|
|
2020-10-17 00:28:49 +02:00
|
|
|
TESTS=""
|
2020-10-21 19:50:18 +02:00
|
|
|
for i in $(ls test_qmckl_*.c) ; do
|
2021-03-19 13:47:50 +01:00
|
|
|
FILE=${i%.c}
|
|
|
|
TESTS+=" ${FILE}.o"
|
2020-10-17 00:28:49 +02:00
|
|
|
done >> $OUTPUT
|
|
|
|
|
2021-03-09 01:16:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
# and for tests in Fortran:
|
|
|
|
|
|
|
|
|
2020-10-26 16:51:16 +01:00
|
|
|
TESTS_F=""
|
2021-03-09 01:16:23 +01:00
|
|
|
for i in $(ls test_qmckl_*_f.f90) ; do
|
2021-03-19 13:47:50 +01:00
|
|
|
FILE=${i%.f90}
|
|
|
|
TESTS_F+=" ${FILE}.o"
|
2020-10-26 16:51:16 +01:00
|
|
|
done >> $OUTPUT
|
|
|
|
|
2020-10-16 13:58:05 +02:00
|
|
|
|
|
|
|
|
2021-03-09 01:16:23 +01:00
|
|
|
# Finally, we append the rules to the Makefile
|
|
|
|
|
|
|
|
|
|
|
|
cat << EOF > ${OUTPUT}
|
2020-10-16 13:58:05 +02:00
|
|
|
CC=$CC
|
2021-03-19 13:47:50 +01:00
|
|
|
CFLAGS=$CFLAGS -I../munit/
|
2020-10-16 13:58:05 +02:00
|
|
|
|
|
|
|
FC=$FC
|
|
|
|
FFLAGS=$FFLAGS
|
|
|
|
OBJECT_FILES=$OBJECTS
|
2020-10-17 00:28:49 +02:00
|
|
|
TESTS=$TESTS
|
2020-10-26 16:51:16 +01:00
|
|
|
TESTS_F=$TESTS_F
|
2020-10-16 13:58:05 +02:00
|
|
|
|
2020-10-22 00:50:07 +02:00
|
|
|
LIBS=$LIBS
|
|
|
|
|
2020-10-16 13:58:05 +02:00
|
|
|
libqmckl.so: \$(OBJECT_FILES)
|
|
|
|
\$(CC) -shared \$(OBJECT_FILES) -o libqmckl.so
|
2021-03-19 13:47:50 +01:00
|
|
|
|
|
|
|
%.o: %.c
|
2020-10-16 13:58:05 +02:00
|
|
|
\$(CC) \$(CFLAGS) -c \$*.c -o \$*.o
|
|
|
|
|
2020-11-05 12:57:39 +01:00
|
|
|
%.o: %.f90 qmckl_f.o
|
2020-10-16 13:58:05 +02:00
|
|
|
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o
|
|
|
|
|
2021-03-18 18:02:06 +01:00
|
|
|
../include/qmckl.h ../include/qmckl_f.f90:
|
|
|
|
../tools/build_qmckl_h.sh
|
|
|
|
|
|
|
|
qmckl_f.o: ../include/qmckl_f.f90
|
|
|
|
\$(FC) \$(FFLAGS) -c ../include/qmckl_f.f90 -o qmckl_f.o
|
2021-03-09 01:16:23 +01:00
|
|
|
|
2020-10-26 16:51:16 +01:00
|
|
|
test_qmckl: test_qmckl.c libqmckl.so \$(TESTS) \$(TESTS_F)
|
2020-10-17 00:28:49 +02:00
|
|
|
\$(CC) \$(CFLAGS) -Wl,-rpath,$PWD -L. \
|
2020-10-26 16:51:16 +01:00
|
|
|
../munit/munit.c \$(TESTS) \$(TESTS_F) -lqmckl \$(LIBS) test_qmckl.c -o test_qmckl
|
2020-10-17 00:28:49 +02:00
|
|
|
|
2020-10-21 19:50:18 +02:00
|
|
|
test: test_qmckl
|
|
|
|
./test_qmckl
|
2020-10-17 00:28:49 +02:00
|
|
|
|
|
|
|
.PHONY: test
|
2020-10-16 13:58:05 +02:00
|
|
|
EOF
|