2021-05-11 11:45:49 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Creates all the dependencies from the org-mode files
|
|
|
|
|
|
|
|
if [[ -z ${srcdir} ]] ; then
|
2021-05-12 01:51:26 +02:00
|
|
|
srcdir=.
|
2021-05-11 11:45:49 +02:00
|
|
|
fi
|
|
|
|
|
2021-05-11 12:15:08 +02:00
|
|
|
|
2021-05-11 11:45:49 +02:00
|
|
|
WD=$PWD
|
|
|
|
|
|
|
|
function make_src()
|
|
|
|
{
|
|
|
|
|
|
|
|
cd ${srcdir}
|
|
|
|
|
2021-05-12 00:22:51 +02:00
|
|
|
declare -A DEPS DEPS_ORG DEPS_TEST TESTS HTML TEXT DEPS_DOC
|
2021-05-11 11:45:49 +02:00
|
|
|
|
|
|
|
C_FILES=
|
|
|
|
F_FILES=
|
|
|
|
FH_FUNC_FILES=
|
|
|
|
FH_TYPE_FILES=
|
|
|
|
H_FUNC_FILES=
|
|
|
|
H_TYPE_FILES=
|
|
|
|
H_PRIVATE_FUNC_FILES=
|
|
|
|
H_PRIVATE_TYPE_FILES=
|
|
|
|
C_TEST_FILES=
|
|
|
|
F_TEST_FILES=
|
2021-05-11 12:15:08 +02:00
|
|
|
TANGLED_FILES=
|
2021-05-11 11:45:49 +02:00
|
|
|
|
|
|
|
for org in org/*.org ; do
|
2021-05-11 12:56:41 +02:00
|
|
|
i=$(basename ${org%.org})
|
2021-05-12 02:16:45 +02:00
|
|
|
tangled="org/${i}.tangled"
|
|
|
|
exported="org/${i}.exported"
|
|
|
|
c_test_x="tests/test_${i}"
|
|
|
|
c_test_o="tests/test_${i}.\$(OBJEXT)"
|
|
|
|
f_test_o="tests/test_${i}_f.\$(OBJEXT)"
|
|
|
|
c_test="tests/test_${i}.c"
|
|
|
|
f_test="tests/test_${i}_f.f90"
|
|
|
|
html="share/doc/qmckl/html/${i}.html"
|
|
|
|
text="share/doc/qmckl/text/${i}.txt"
|
|
|
|
|
|
|
|
i="src/${i}"
|
2021-05-11 12:56:41 +02:00
|
|
|
|
2021-05-11 11:45:49 +02:00
|
|
|
c="${i}.c"
|
2021-05-12 01:51:26 +02:00
|
|
|
o="${i}.\$(OBJEXT)"
|
2021-05-11 11:45:49 +02:00
|
|
|
h_func="${i}_func.h"
|
|
|
|
h_type="${i}_type.h"
|
|
|
|
h_private_func="${i}_private_func.h"
|
|
|
|
h_private_type="${i}_private_type.h"
|
|
|
|
f90="${i}_f.f90"
|
2021-05-12 01:51:26 +02:00
|
|
|
fo="${i}_f.\$(OBJEXT)"
|
2021-05-11 11:45:49 +02:00
|
|
|
fh_func="${i}_fh_func.f90"
|
|
|
|
fh_type="${i}_fh_type.f90"
|
|
|
|
|
2021-05-11 12:15:08 +02:00
|
|
|
ORG_FILES+="\$(srcdir)/$org "
|
|
|
|
TANGLED_FILES+="$tangled "
|
2021-05-12 00:22:51 +02:00
|
|
|
EXPORTED_FILES+="$exported "
|
2021-05-11 12:15:08 +02:00
|
|
|
DEPS_ORG["\$(srcdir)/$org"]=$tangled
|
2021-05-12 00:22:51 +02:00
|
|
|
DEPS_DOC["\$(srcdir)/$org"]=$exported
|
|
|
|
TEXT["\$(srcdir)/$org"]=$text
|
|
|
|
HTML["\$(srcdir)/$org"]=$html
|
2021-05-11 12:15:08 +02:00
|
|
|
|
2021-05-11 11:45:49 +02:00
|
|
|
grep -q "(eval c)" $org
|
|
|
|
if [[ $? -eq 0 ]] ; then
|
2021-05-11 12:15:08 +02:00
|
|
|
DEPS[$c]+=" $tangled"
|
2021-05-11 13:57:23 +02:00
|
|
|
DEPS[$o]+=" $c \$(qmckl_h)"
|
2021-05-11 11:45:49 +02:00
|
|
|
C_FILES+=" $c"
|
|
|
|
C_O_FILES+=" $o"
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep -q "(eval h_func)" $org
|
|
|
|
if [[ $? -eq 0 ]] ; then
|
2021-05-11 12:15:08 +02:00
|
|
|
DEPS[$h_func]+=" $tangled"
|
2021-05-11 11:45:49 +02:00
|
|
|
H_FUNC_FILES+=" $h_func"
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep -q "(eval h_type)" $org
|
|
|
|
if [[ $? -eq 0 ]] ; then
|
2021-05-11 12:15:08 +02:00
|
|
|
DEPS[$h_type]+=" $tangled"
|
2021-05-11 11:45:49 +02:00
|
|
|
H_TYPE_FILES+=" $h_type"
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep -q "(eval h_private_type)" $org
|
|
|
|
if [[ $? -eq 0 ]] ; then
|
|
|
|
DEPS[$o]+=" $h_private_type"
|
2021-05-11 12:15:08 +02:00
|
|
|
DEPS[$h_private_type]+=" $tangled"
|
2021-05-11 11:45:49 +02:00
|
|
|
H_PRIVATE_TYPE_FILES+=" $h_private_type"
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep -q "(eval h_private_func)" $org
|
|
|
|
if [[ $? -eq 0 ]] ; then
|
|
|
|
DEPS[$o]+=" $h_private_func"
|
2021-05-11 12:15:08 +02:00
|
|
|
DEPS[$h_private_func]+=" $tangled"
|
2021-05-11 11:45:49 +02:00
|
|
|
H_PRIVATE_FUNC_FILES+=" $h_private_func"
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep -q "(eval f)" $org
|
|
|
|
if [[ $? -eq 0 ]] ; then
|
2021-05-12 01:51:26 +02:00
|
|
|
DEPS[$f90]+=" $tangled \$(src_qmckl_fo)"
|
|
|
|
DEPS[$fo]+="$f90 \$(src_qmckl_fo)"
|
2021-05-11 11:45:49 +02:00
|
|
|
F_FILES+=" $f90"
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep -q "(eval fh_func)" $org
|
|
|
|
if [[ $? -eq 0 ]] ; then
|
2021-05-11 12:15:08 +02:00
|
|
|
DEPS[$fh_func]+=" $tangled"
|
2021-05-11 11:45:49 +02:00
|
|
|
FH_FUNC_FILES+=" $fh_func"
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep -q "(eval fh_type)" $org
|
|
|
|
if [[ $? -eq 0 ]] ; then
|
2021-05-11 12:15:08 +02:00
|
|
|
DEPS[$fh_type]+=" $tangled"
|
2021-05-11 11:45:49 +02:00
|
|
|
FH_TYPE_FILES+=" $fh_type"
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep -q "(eval c_test)" $org
|
|
|
|
if [[ $? -eq 0 ]] ; then
|
2021-05-12 01:51:26 +02:00
|
|
|
DEPS_TEST["${c_test}"]=" ${tangled}"
|
2021-05-11 12:56:41 +02:00
|
|
|
C_TEST_FILES+=" ${c_test}"
|
2021-05-11 16:41:03 +02:00
|
|
|
TESTS["${c_test_x}"]+="${c_test} \$(qmckl_h)"
|
2021-05-11 11:45:49 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
grep -q "(eval f_test)" $org
|
|
|
|
if [[ $? -eq 0 ]] ; then
|
2021-05-12 01:51:26 +02:00
|
|
|
DEPS_TEST["${f_test}"]+=" ${tangled} \$(test_qmckl_fo)"
|
2021-05-11 12:56:41 +02:00
|
|
|
F_TEST_FILES+=" ${f_test}"
|
2021-05-12 01:51:26 +02:00
|
|
|
TESTS["${c_test_x}"]+=" ${f_test} \$(test_qmckl_fo)"
|
2021-05-11 11:45:49 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2021-05-11 16:41:03 +02:00
|
|
|
echo
|
|
|
|
echo "## Source files"
|
|
|
|
echo
|
|
|
|
echo "ORG_FILES=${ORG_FILES}"
|
|
|
|
echo "TANGLED_FILES=${TANGLED_FILES}"
|
2021-05-12 00:22:51 +02:00
|
|
|
echo "EXPORTED_FILES=${EXPORTED_FILES}"
|
2021-05-11 16:41:03 +02:00
|
|
|
echo "C_FILES=${C_FILES}"
|
|
|
|
echo "F_FILES=${F_FILES}"
|
|
|
|
echo "C_O_FILES=${C_O_FILES}"
|
|
|
|
echo "FH_FUNC_FILES=${FH_FUNC_FILES}"
|
|
|
|
echo "FH_TYPE_FILES=${FH_TYPE_FILES}"
|
|
|
|
echo "H_FUNC_FILES=${H_FUNC_FILES}"
|
|
|
|
echo "H_TYPE_FILES=${H_TYPE_FILES}"
|
|
|
|
echo "H_PRIVATE_FUNC_FILES=${H_PRIVATE_FUNC_FILES}"
|
|
|
|
echo "H_PRIVATE_TYPE_FILES=${H_PRIVATE_TYPE_FILES}"
|
|
|
|
echo "C_TEST_FILES=${C_TEST_FILES}"
|
|
|
|
echo "F_TEST_FILES=${F_TEST_FILES}"
|
|
|
|
echo "TESTS=${!TESTS[@]}" | sed "s|\$(srcdir)/||g"
|
2021-05-12 00:22:51 +02:00
|
|
|
echo "HTML_FILES"=${HTML[@]}
|
|
|
|
echo "TEXT_FILES"=${TEXT[@]}
|
2021-05-11 16:41:03 +02:00
|
|
|
echo
|
|
|
|
|
|
|
|
echo
|
2021-05-12 01:51:26 +02:00
|
|
|
|
2021-05-11 16:41:03 +02:00
|
|
|
echo "## Org-mode inherited dependencies"
|
|
|
|
echo
|
2021-05-12 01:51:26 +02:00
|
|
|
echo "if QMCKL_DEVEL"
|
2021-05-11 11:45:49 +02:00
|
|
|
for f in ${!DEPS_ORG[@]} ; do
|
|
|
|
echo ${DEPS_ORG[$f]}: $f
|
|
|
|
echo " \$(tangle_verbose)\$(srcdir)/tools/tangle.sh $f"
|
|
|
|
echo ""
|
2021-05-11 16:41:03 +02:00
|
|
|
done
|
2021-05-12 01:51:26 +02:00
|
|
|
echo "endif"
|
2021-05-11 16:41:03 +02:00
|
|
|
echo
|
2021-05-11 11:45:49 +02:00
|
|
|
|
2021-05-11 16:41:03 +02:00
|
|
|
echo
|
|
|
|
echo "## Source dependencies"
|
|
|
|
echo
|
2021-05-12 01:51:26 +02:00
|
|
|
echo "if QMCKL_DEVEL"
|
2021-05-11 11:45:49 +02:00
|
|
|
for f in ${!DEPS[@]} ; do
|
2021-05-12 01:51:26 +02:00
|
|
|
x="${DEPS[$f]}"
|
|
|
|
if [[ "${x%.tangled}x" != ${x}x ]] ; then
|
|
|
|
echo "${f}: ${DEPS[$f]}"
|
|
|
|
fi
|
|
|
|
done | sort
|
|
|
|
echo "endif"
|
|
|
|
echo "${src_qmckl_fo}: ${src_qmckl_f}"
|
|
|
|
for f in ${!DEPS[@]} ; do
|
|
|
|
x="${DEPS[$f]}"
|
|
|
|
if [[ "${x%.tangled}x" == ${x}x ]] ; then
|
|
|
|
echo "${f}: ${DEPS[$f]}"
|
|
|
|
fi
|
2021-05-11 16:41:03 +02:00
|
|
|
done | sort
|
2021-05-11 12:56:41 +02:00
|
|
|
|
2021-05-11 16:41:03 +02:00
|
|
|
echo
|
|
|
|
echo "## Test files"
|
|
|
|
echo
|
2021-05-12 01:51:26 +02:00
|
|
|
echo "\$(test_qmckl_fo): \$(test_qmckl_f)"
|
|
|
|
echo "if QMCKL_DEVEL"
|
2021-05-11 12:56:41 +02:00
|
|
|
for f in ${!DEPS_TEST[@]} ; do
|
2021-05-11 16:41:03 +02:00
|
|
|
echo "${f}: ${DEPS_TEST[$f]}"
|
|
|
|
done | sort
|
2021-05-12 01:51:26 +02:00
|
|
|
echo "endif"
|
2021-05-11 16:41:03 +02:00
|
|
|
echo
|
|
|
|
echo "check_PROGRAMS = \$(TESTS)"
|
|
|
|
for f in ${!TESTS[@]} ; do
|
|
|
|
echo "tests_$(basename $f)_SOURCES = ${TESTS[$f]}" #| sed "s|\$(srcdir)/||"
|
|
|
|
echo "tests_$(basename $f)_LDADD = src/libqmckl.la"
|
2021-05-12 00:22:51 +02:00
|
|
|
echo "tests_$(basename $f)_LDFLAGS = -no-install"
|
2021-05-11 16:41:03 +02:00
|
|
|
done | sort
|
2021-05-12 00:22:51 +02:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "## Documentation"
|
|
|
|
echo
|
2021-05-12 01:51:26 +02:00
|
|
|
echo "if QMCKL_DEVEL"
|
2021-05-12 00:22:51 +02:00
|
|
|
for f in ${ORG_FILES} ; do
|
|
|
|
echo "${HTML[$f]}: ${DEPS_DOC[$f]} \$(htmlize_el)"
|
|
|
|
echo "${TEXT[$f]}: ${DEPS_DOC[$f]}"
|
|
|
|
echo ""
|
|
|
|
done
|
|
|
|
for f in ${!DEPS_DOC[@]} ; do
|
|
|
|
echo "${DEPS_DOC[$f]}: $f"
|
|
|
|
echo " \$(export_verbose)\$(srcdir)/tools/build_doc.sh $f"
|
|
|
|
echo ""
|
|
|
|
done
|
2021-05-12 01:51:26 +02:00
|
|
|
echo "endif"
|
2021-05-11 11:45:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-11 16:41:03 +02:00
|
|
|
OUTPUT=${WD}/generated.mk
|
|
|
|
make_src > ${OUTPUT}
|
2021-05-11 11:45:49 +02:00
|
|
|
|