aboutsummaryrefslogtreecommitdiff
path: root/reproduce
diff options
context:
space:
mode:
Diffstat (limited to 'reproduce')
-rw-r--r--reproduce/src/make/initialize.mk68
-rw-r--r--reproduce/src/make/paper.mk55
2 files changed, 79 insertions, 44 deletions
diff --git a/reproduce/src/make/initialize.mk b/reproduce/src/make/initialize.mk
index b3180e3..ff06dcb 100644
--- a/reproduce/src/make/initialize.mk
+++ b/reproduce/src/make/initialize.mk
@@ -140,9 +140,9 @@ export CPPFLAGS := -I$(installdir)/include
# option: they add too many extra checks that make it hard to find what you
# are looking for in this pipeline.
.SUFFIXES:
-$(tikzdir): | $(texbdir); mkdir $@
$(texdir) $(lockdir): | $(BDIR); mkdir $@
$(mtexdir) $(texbdir): | $(texdir); mkdir $@
+$(tikzdir): | $(texbdir); mkdir $@ && ln -s $(tikzdir) tex/tikz
@@ -160,7 +160,7 @@ $(mtexdir) $(texbdir): | $(texdir); mkdir $@
# when no file actually differs.
packagebasename := $(shell echo paper-$$(git describe --dirty --always))
packagecontents = $(texdir)/$(packagebasename)
-.PHONY: all clean distclean clean-mmap tarball zip $(packagecontents) \
+.PHONY: all clean dist dist-zip distclean clean-mmap $(packagecontents) \
$(mtexdir)/initialize.tex
# --------- Delete for no Gnuastro ---------
@@ -206,32 +206,67 @@ $(packagecontents): | $(texdir)
rm -rf $$dir
mkdir $$dir
+ # Build a small Makefile to help in automatizing the paper building
+ # (including the bibliography).
+ m=$$dir/Makefile
+ echo "paper.pdf: paper.tex paper.bbl" > $$m
+ printf "\tpdflatex -shell-escape -halt-on-error paper\n" >> $$m
+ echo "paper.bbl: tex/src/references.tex" >> $$m
+ printf "\tpdflatex -shell-escape -halt-on-error paper\n" >> $$m
+ printf "\tbiber paper\n" >> $$m
+ echo ".PHONY: clean" >> $$m
+ echo "clean:" >> $$m
+ printf "\trm -f *.aux *.auxlock *.bbl *.bcf\n" >> $$m
+ printf "\trm -f *.blg *.log *.out *.run.xml\n" >> $$m
+
# Copy the top-level contents into it.
cp configure COPYING for-group README.md README-hacking.md $$dir/
- # Since the tarball is mainly intended for high-level building of
- # the PDF with LaTeX, we'll comment the `makepdf' LaTeX macro in
- # the paper.
- sed -e's|\\newcommand{\\makepdf}{}|%\\newcommand{\\makepdf}{}|' \
- paper.tex > $$dir/paper.tex
+ # Build the top-level directories.
+ mkdir $$dir/reproduce $$dir/tex $$dir/tex/tikz $$dir/tex/pipeline
# Copy all the `reproduce' contents except for the `build' symbolic
# link.
shopt -s extglob
- mkdir $$dir/reproduce $$dir/tex $$dir/tex/tikz
- cp tex/*.tex $$dir/tex
- cp -r reproduce/!(build) $$dir/reproduce
- cp tex/tikz/*.pdf $$dir/tex/tikz
+ cp -r tex/src $$dir/tex/src
+ cp tex/tikz/*.pdf $$dir/tex/tikz
+ cp -r reproduce/!(build) $$dir/reproduce
+ cp -r tex/pipeline/!($(packagebasename)) $$dir/tex/pipeline
+
+ # Clean up un-necessary/local files: 1) the $(texdir)/build*
+ # directories (when building in a group structure, there will be
+ # `build-user1', `build-user2' and etc), are just temporary LaTeX
+ # build files and don't have any relevant/hand-written files in
+ # them. 2) The `LOCAL.mk' and `gnuastro-local.conf' files just have
+ # this machine's local settings and are irrelevant for anyone else.
+ rm -rf $$dir/tex/pipeline/build*
+ rm $$dir/reproduce/config/pipeline/LOCAL.mk
+ rm $$dir/reproduce/config/gnuastro/gnuastro-local.conf
+
+ # PIPELINE SPECIFIC: under this comment, copy any other file for
+ # packaging, or remove any of the copied files above to suite your
+ # project.
+
+ # Since the packaging is mainly intended for high-level building of
+ # the PDF with LaTeX, we'll comment the `makepdf' LaTeX macro in
+ # the paper.
+ sed -e's|\\newcommand{\\makepdf}{}|%\\newcommand{\\makepdf}{}|' \
+ paper.tex > $$dir/paper.tex
- # PIPELINE SPECIFIC: add or remove any of the copied files above,
- # specific to your pipeline here.
+ # Just in case the package users want to rebuild some of the
+ # figures (manually un-comments the `makepdf' command we commented
+ # above), correct the TikZ external directory, so the figures can
+ # be rebuilt.
+ pgfsettings="$$dir/tex/src/preamble-pgfplots.tex"
+ sed -e's|{tikz/}|{tex/tikz/}|' $$pgfsettings > $$pgfsettings.new
+ mv $$pgfsettings.new $$pgfsettings
- # Clean all temporary files.
+ # Clean temporary (currently those ending in `~') files.
cd $(texdir)
find $(packagebasename) -name \*~ -delete
# Package into `.tar.gz'.
-tarball: $(packagecontents)
+dist: $(packagecontents)
curdir=$$(pwd)
cd $(texdir)
tar -cf $(packagebasename).tar $(packagebasename)
@@ -240,7 +275,7 @@ tarball: $(packagecontents)
mv $(texdir)/$(packagebasename).tar.gz ./
# Package into `.zip'.
-zip: $(packagecontents)
+dist-zip: $(packagecontents)
curdir=$$(pwd)
cd $(texdir)
zip -q -r $(packagebasename).zip $(packagebasename)
@@ -294,7 +329,6 @@ $(mtexdir)/initialize.tex: | $(mtexdir)
# Version of the pipeline and build directory (for LaTeX inputs).
@v=$$(git describe --dirty --always);
echo "\newcommand{\pipelineversion}{$$v}" > $@
- @echo "\newcommand{\bdir}{$(BDIR)}" >> $@
# Versions of programs (same order as 'dependency-versions.mk'),
# ordered alphabetically (by their executable name).
diff --git a/reproduce/src/make/paper.mk b/reproduce/src/make/paper.mk
index aea6c60..d148c08 100644
--- a/reproduce/src/make/paper.mk
+++ b/reproduce/src/make/paper.mk
@@ -25,17 +25,16 @@
# LaTeX macros for paper
# ----------------------
#
-# To report the input settings and results, the final report's PDF
-# (final target of this reproduction pipeline) uses macros generated
-# from various steps of the pipeline. All these macros are defined in
-# `tex/pipeline.tex'.
+# To report the input settings and results, the final report's PDF (final
+# target of this reproduction pipeline) uses macros generated from various
+# steps of the pipeline. All these macros are defined in
+# `$(mtexdir)/pipeline.tex'.
#
-# `tex/pipeline.tex' is actually just a combination of separate files
-# that keep the LaTeX macros related to each workhorse Makefile (in
-# `reproduce/src/make/*.mk'). Those individual macros are
-# pre-requisites to `tex/pipeline.tex'. The only workhorse Makefile
-# that doesn't need to produce LaTeX macros is this Makefile
-# (`reproduce/src/make/paper.mk').
+# `$(mtexdir)/pipeline.tex' is actually just a combination of separate
+# files that keep the LaTeX macros related to each workhorse Makefile (in
+# `reproduce/src/make/*.mk'). Those individual macros are pre-requisites to
+# `$(mtexdir)/pipeline.tex'. The only workhorse Makefile that doesn't need
+# to produce LaTeX macros is this Makefile (`reproduce/src/make/paper.mk').
#
# This file is thus the interface between the pipeline scripts and the
# final PDF: when we get to this point, all the processing has been
@@ -44,13 +43,21 @@
# Note that if you don't want the final PDF and just want the
# processing and file outputs, you can remove the value of
# `pdf-build-final' in `reproduce/config/pipeline/pdf-build.mk'.
-tex/pipeline.tex: $(foreach s, $(subst paper,,$(makesrc)), $(mtexdir)/$(s).tex)
+$(mtexdir)/pipeline.tex: $(foreach s, $(subst paper,,$(makesrc)), $(mtexdir)/$(s).tex)
# If no PDF is requested, or if LaTeX isn't available, don't
# continue to building the final PDF. Otherwise, merge all the TeX
# macros into one for building the PDF.
@if [ -f .local/bin/pdflatex ] && [ x"$(pdf-build-final)" != x ]; then
- cat $(mtexdir)/*.tex > $@
+
+ # First make sure the `tex/pipeline' symbolic link exists.
+ if [ ! -e tex/pipeline ]; then ln -s $(texdir) tex/pipeline; fi
+
+ # Put a LaTeX input command for all the necessary macro files.
+ rm -f $(mtexdir)/pipeline.tex
+ for t in $(subst paper,,$(makesrc)); do
+ echo "\input{tex/pipeline/macros/$$t.tex}" >> $(mtexdir)/pipeline.tex
+ done
else
echo
echo "-----"
@@ -86,15 +93,15 @@ tex/pipeline.tex: $(foreach s, $(subst paper,,$(makesrc)), $(mtexdir)/$(s).tex)
# necessary bibliography before making the final paper. So we'll first have
# one run of LaTeX (similar to the `paper.pdf' recipe), then `biber'.
#
-# NOTE: `tex/pipeline.tex' is an order-only-prerequisite for
+# NOTE: `$(mtexdir)/pipeline.tex' is an order-only-prerequisite for
# `paper.bbl'. This is because we need to run LaTeX in both the `paper.bbl'
-# recipe and the `paper.pdf' recipe. But if `tex/references.tex' hasn't
+# recipe and the `paper.pdf' recipe. But if `tex/src/references.tex' hasn't
# been modified, we don't want to re-build the bibliography, only the final
# PDF.
-$(texbdir)/paper.bbl: tex/references.tex \
- | $(tikzdir) $(texbdir) tex/pipeline.tex
- # If `tex/pipeline.tex' is empty, then the PDF must not be built.
- @macros=$$(cat tex/pipeline.tex)
+$(texbdir)/paper.bbl: tex/src/references.tex \
+ | $(tikzdir) $(texbdir) $(mtexdir)/pipeline.tex
+ # If `$(mtexdir)/pipeline.tex' is empty, don't build PDF.
+ @macros=$$(cat $(mtexdir)/pipeline.tex)
if [ x"$$macros" != x ]; then
# We'll run LaTeX first to generate the `.bcf' file (necessary
@@ -119,19 +126,13 @@ $(texbdir)/paper.bbl: tex/references.tex \
# to run everything cleanly from there, it is necessary to add the current
# directory (top reproduction pipeline directory) to the `TEXINPUTS'
# environment variable.
-paper.pdf: tex/pipeline.tex paper.tex $(texbdir)/paper.bbl \
+paper.pdf: $(mtexdir)/pipeline.tex paper.tex $(texbdir)/paper.bbl \
| $(tikzdir) $(texbdir)
- # If `tex/pipeline.tex' is empty, then the PDF must not be built.
- @macros=$$(cat tex/pipeline.tex)
+ # If `$(mtexdir)/pipeline.tex' is empty, don't build the PDF.
+ @macros=$$(cat $(mtexdir)/pipeline.tex)
if [ x"$$macros" != x ]; then
- # If it doesn't exist, make the `tex/tikz' symbolic link
- # directory. This is necessary for situations when we just want
- # TeX to use built figures instead of actually building the
- # figures.
- if [ ! -e tex/tikz ]; then ln -s $(tikzdir) tex/tikz; fi
-
# Go into the top TeX build directory and make the paper.
p=$$(pwd)
export TEXINPUTS=$$p:$$TEXINPUTS