commit 82b50b80039c170ef62bce5fb835f187b170cd7d
parent b9294d551a74f0aeee1c4b9c7a6ae61de239127c
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 14 Oct 2022 09:57:52 +0200
Add Makefile target "pdf"
It builds the pdf from noweb sources. Note that we are using a handmade
noweave backend to allow the \input Latex directive in noweb sources.
Diffstat:
6 files changed, 94 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -7,3 +7,10 @@ tmp
tags
.config
sgs
+*.aux
+*.bbl
+*.blg
+*.log
+*.tex
+weave*
+*.pdf
diff --git a/Makefile b/Makefile
@@ -34,9 +34,18 @@ SRC =\
src/sgs_log.c\
src/sgs_main.c
+DOC = sgs_compute_sensitivity_translation
+
+NOWEB=\
+ src/$(DOC).nw
+
OBJ = $(SRC:.c=.o)
DEP = $(SRC:.c=.d)
+TEX = $(NOWEB:.nw=.tex)
+################################################################################
+# Program
+################################################################################
build_executable: .config $(DEP)
@$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) sgs
@@ -67,6 +76,25 @@ sgs: $(OBJ)
@echo "CC $@"
@$(CC) $(CFLAGS) -c $< -o $@
+################################################################################
+# Latex
+################################################################################
+pdf: $(DOC).pdf
+
+$(DOC).pdf: $(TEX) $(DOC).bbl
+ $(LATEX) src/$(DOC).tex && $(LATEX) src/$(DOC).tex
+
+$(DOC).bbl: $(TEX) src/biblio.bib
+ $(LATEX) src/$(DOC).tex && rm -f $(DOC).pdf && $(BIBTEX) $(DOC)
+
+$(TEX): weave.all
+
+weave.all: $(NOWEB) noweave_backend.sh config.mk
+ noweave $(NOWEAVE_OPTS) -backend "sh noweave_backend.sh" $(NOWEB)
+
+################################################################################
+# Miscellaneous targets
+################################################################################
install: build_executable
mkdir -p $(DESTDIR)$(PREFIX)/bin
mkdir -p $(DESTDIR)$(PREFIX)/share/doc/star-gs
@@ -79,7 +107,9 @@ uninstall:
rm -f $(DESTDIR)$(PREFIX)/share/doc/star-gs/README.md
clean:
- @rm -f $(OBJ) sgs .config
+ @rm -f $(OBJ) $(TEX) sgs .config ./*.aux ./*.bbl ./*.idx ./*.log ./*.dvi \
+ ./*.glo ./*.lof ./*.toc ./*.out ./*.blg ./*.bbl ./*.nav ./*.snm ./*.vrb \
+ weave* $(DOC).pdf
distclean: clean
@rm -f $(DEP)
diff --git a/config.mk b/config.mk
@@ -1,9 +1,19 @@
VERSION = 0.0.0
PREFIX = /usr/local
+
PKG_CONFIG = pkg-config
################################################################################
+# Noweb & latex
+################################################################################
+NOTANGLE_OPTS = #-L
+NOWEAVE_OPTS = -index -delay -v
+
+BIBTEX = bibtex
+LATEX = pdflatex
+
+################################################################################
# Dependencies
################################################################################
RSYS_VERSION = 0.12
diff --git a/noweave_backend.sh b/noweave_backend.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# Copyright (C) 2021
+# CNRS/RAPSODEE,
+# CNRS/LMAP,
+# |Meso|Star> (contact@meso-star.com),
+# UPS/Laplace.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+cd "$(dirname "$0")"
+
+noweave=$(command -v noweave)
+nolib_path=$(sed -n 's/^LIB=\(.*\)$/\1/1p' "${noweave}")
+
+cat - > weave.all
+count=$(grep -c '^@file ' weave.all)
+
+if [ "${count}" -le 1 ]; then
+ csplit -s -f weave -n 1 weave.all %^@file\ %
+else
+ # shellcheck disable=SC1083
+ csplit -s -f weave -n 1 weave.all %^@file\ % /^@file\ / {$((count - 2))}
+fi
+
+i=0
+while [ "${i}" -lt "${count}" ]; do
+ tex=$(head -1 "weave${i}" | sed -n 's/@file\ \(.*\).nw/\1.tex/p')
+ "${nolib_path}/totex" -delay < "weave${i}" | cpif "src/${tex##*/}"
+ i=$((i + 1))
+done
diff --git a/src/biblio.bib b/src/biblio.bib
diff --git a/src/sgs_compute_sensitivity_translation.nw b/src/sgs_compute_sensitivity_translation.nw
@@ -39,7 +39,6 @@
%\def\nwendcode{\endtrivlist \endgroup \vfil\penalty10\vfilneg}
%\let\nwdocspar=\smallbreak
-
%Math et symboles
\newcommand{\PI}{\ddot \pi}
@@ -588,5 +587,8 @@ L(\vec{x},\vec{\omega}_{spec},\PI) \\
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
@
+\bibliographystyle{apalike}
+\bibliography{biblio}
+
\end{document}
\nwfilename{test}