mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2025-01-10 04:58:33 +01:00
99 lines
1.7 KiB
Bash
Executable File
99 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
MERGED=merged.org
|
|
${QMCKL_ROOT}/tools/merge_org.sh $MERGED
|
|
|
|
OUTPUT=Makefile.generated
|
|
|
|
# Tangle org files
|
|
emacs \
|
|
$MERGED \
|
|
--batch \
|
|
-f org-babel-tangle \
|
|
--kill
|
|
|
|
rm $MERGED
|
|
|
|
|
|
# Create the list of *.o files to be created
|
|
|
|
OBJECTS=""
|
|
for i in $(ls qmckl_*.c) ; do
|
|
FILE=${i%.c}
|
|
OBJECTS="${OBJECTS} ${FILE}.o"
|
|
done >> $OUTPUT
|
|
|
|
for i in $(ls qmckl_*.f90) ; do
|
|
FILE=${i%.f90}
|
|
OBJECTS="${OBJECTS} ${FILE}.o"
|
|
done >> $OUTPUT
|
|
|
|
TESTS=""
|
|
for i in $(ls test_qmckl_*.c) ; do
|
|
FILE=${i%.c}.o
|
|
TESTS="${TESTS} ${FILE}"
|
|
done >> $OUTPUT
|
|
|
|
TESTS_F=""
|
|
for i in $(ls test_qmckl_*.f90) ; do
|
|
FILE=${i%.f90}.o
|
|
TESTS_F="${TESTS_F} ${FILE}"
|
|
done >> $OUTPUT
|
|
|
|
|
|
# Write the Makefile
|
|
|
|
cat << EOF > $OUTPUT
|
|
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
|
|
|
|
%.o: %.c
|
|
\$(CC) \$(CFLAGS) -c \$*.c -o \$*.o
|
|
|
|
%.o: %.f90 qmckl_f.o
|
|
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.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_qmckl
|
|
./test_qmckl
|
|
|
|
.PHONY: test
|
|
EOF
|
|
|
|
for i in $(ls qmckl_*.c) ; do
|
|
FILE=${i%.c}
|
|
echo "${FILE}.o: ${FILE}.c " *.h
|
|
done >> $OUTPUT
|
|
|
|
for i in $(ls qmckl_*.f90) ; do
|
|
FILE=${i%.f90}
|
|
echo "${FILE}.o: ${FILE}.f90"
|
|
done >> $OUTPUT
|
|
|
|
for i in $(ls test_qmckl_*.c) ; do
|
|
FILE=${i%.c}
|
|
echo "${FILE}.o: ${FILE}.c qmckl.h"
|
|
done >> $OUTPUT
|
|
|
|
|
|
for i in $(ls test_qmckl*.f90) ; do
|
|
FILE=${i%.f90}
|
|
echo "${FILE}.o: ${FILE}.f90"
|
|
done >> $OUTPUT
|
|
|
|
|