1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-11-19 20:42:50 +01:00
qmckl/src/create_makefile.sh

86 lines
1.4 KiB
Bash
Raw Normal View History

2020-10-16 13:58:05 +02:00
#!/bin/bash
OUTPUT=Makefile.generated
# Tangle org files
emacsclient -a "" \
--socket-name=org_to_code \
--eval "(require 'org)"
for INPUT in $@ ; do
emacsclient \
--no-wait \
--socket-name=org_to_code \
--eval "(org-babel-tangle-file \"$INPUT\")"
done
emacsclient \
--no-wait \
--socket-name=org_to_code \
--eval '(kill-emacs)'
# 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
2020-10-17 00:28:49 +02:00
TESTS=""
for i in $(ls test_*.c) ; do
FILE=${i%.c}
TESTS="${TESTS} ${FILE}"
done >> $OUTPUT
2020-10-16 13:58:05 +02:00
# Write the Makefile
cat << EOF > $OUTPUT
CC=$CC
CFLAGS=$CFLAGS
FC=$FC
FFLAGS=$FFLAGS
OBJECT_FILES=$OBJECTS
2020-10-17 00:28:49 +02:00
TESTS=$TESTS
2020-10-16 13:58:05 +02:00
libqmckl.so: \$(OBJECT_FILES)
\$(CC) -shared \$(OBJECT_FILES) -o libqmckl.so
%.o: %.c
\$(CC) \$(CFLAGS) -c \$*.c -o \$*.o
%.o: %.f90
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o
2020-10-17 00:28:49 +02:00
test_%: test_%.c
\$(CC) \$(CFLAGS) -Wl,-rpath,$PWD -L. \
-I../munit/ ../munit/munit.c test_\$*.c -lqmckl -o test_\$*
test: libqmckl.so \$(TESTS)
2020-10-17 01:14:57 +02:00
for i in \$(TESTS) ; do ./\$\$i ; done
2020-10-17 00:28:49 +02:00
.PHONY: test
2020-10-16 13:58:05 +02:00
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
2020-10-17 00:28:49 +02:00