1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-11-19 12:32:40 +01:00
qmckl/tools/tangle.sh

39 lines
1.1 KiB
Bash
Raw Normal View History

2021-03-09 01:16:23 +01:00
#!/bin/bash
2021-05-10 23:56:26 +02:00
#
# This script tangles all the org-mode files in the src directory of QMCkl.
# It needs to be run from in the src directory. It uses the config_tangle.el
# Emacs configuration file, which contains information required to compute the
# current file names using for example ~(eval c)~ to get the name of the
# produced C file. The org-mode file is not tangled if the last modification
# date of the org file is older than one of the tangled files.
# The =missing= script is used to check if emacs is present on the system.
2021-03-09 01:16:23 +01:00
2021-05-10 23:56:26 +02:00
if [[ $(basename $PWD) != "src" ]] ; then
print "Error: $0 needs to be run from src directory"
exit 1
fi
2021-03-09 01:16:23 +01:00
2021-03-19 13:47:50 +01:00
2021-03-09 01:16:23 +01:00
function tangle()
{
2021-03-19 13:47:50 +01:00
local org_file=$1
local c_file=${org_file%.org}.c
local f_file=${org_file%.org}.f90
if [[ ${org_file} -ot ${c_file} ]] ; then
return
elif [[ ${org_file} -ot ${f_file} ]] ; then
return
2021-03-09 01:16:23 +01:00
fi
2021-05-10 23:56:26 +02:00
../missing \
emacs --batch ${org_file} \
--load=${top_srcdir}/tools/config_tangle.el \
-f org-babel-tangle
2021-03-09 01:16:23 +01:00
}
for i in $@
do
2021-05-10 23:56:26 +02:00
# echo "--- ${i} ----"
2021-03-19 13:47:50 +01:00
tangle ${i}
2021-03-09 01:16:23 +01:00
done