From c88950e788e17f8213330624b0d44c83344c2f1e Mon Sep 17 00:00:00 2001
From: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Date: Mon, 16 Sep 2019 00:55:07 +0100
Subject: Distribution tarball now builds in arXiv

`./project make dist' will package all the LaTeX-specific files (and
analysis source files) into one `tar.gz' file that is ready to upload to
servers like arXiv. However, it wasn't updated for some time, so running it
would complain about not having a `configure' script in the top of the
project.

With this commit, it now works with the new file-structure of the project
and also copies all the BibLaTeX source files and `paper.bbl' into the top
tarball directory, which allows arXiv to build the paper as intended.

The output of `./project make dist' has been uploaded and tested on arXiv
and it is built by arXiv perfectly.

Also, a short description of all the special `make' targets was added to
the output of `./project --help'.
---
 reproduce/analysis/make/initialize.mk | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

(limited to 'reproduce')

diff --git a/reproduce/analysis/make/initialize.mk b/reproduce/analysis/make/initialize.mk
index 644efe4..94008f2 100644
--- a/reproduce/analysis/make/initialize.mk
+++ b/reproduce/analysis/make/initialize.mk
@@ -228,7 +228,7 @@ distclean: clean
 # that is ready for building the final PDF with LaTeX. This is useful for
 # collaborators who only want to contribute to the text of your project,
 # without having to worry about the technicalities of the analysis.
-$(packagecontents): | $(texdir)
+$(packagecontents): paper.pdf | $(texdir)
 
         # Set up the output directory, delete it if it exists and remake it
         # to fill with new contents.
@@ -250,7 +250,7 @@ $(packagecontents): | $(texdir)
 	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/
+	cp COPYING project README.md README-hacking.md $$dir/
 
         # Build the top-level directories.
 	mkdir $$dir/reproduce $$dir/tex $$dir/tex/tikz $$dir/tex/build
@@ -259,7 +259,7 @@ $(packagecontents): | $(texdir)
 	shopt -s extglob
 	cp -r tex/src                            $$dir/tex/src
 	cp tex/tikz/*.pdf                        $$dir/tex/tikz
-	cp -r reproduce/                         $$dir/reproduce
+	cp -r reproduce/*                        $$dir/reproduce
 	cp -r tex/build/!($(packagebasename))    $$dir/tex/build
 
         # Clean up un-necessary/local files: 1) the $(texdir)/build*
@@ -272,18 +272,35 @@ $(packagecontents): | $(texdir)
 	rm $$dir/reproduce/software/config/installation/LOCAL.mk
 	rm $$dir/reproduce/software/config/gnuastro/gnuastro-local.conf
 
-        # PROJECT SPECIFIC: under this comment, copy any other file for
-        # packaging, or remove any of the copied files above to suite your
-        # project.
+        # When submitting to places like arXiv, they will just run LaTeX
+        # once and won't run `biber'. So we need to also keep the `.bbl'
+        # file into the distributing tarball. However, BibLaTeX is
+        # particularly sensitive to versioning (a `.bbl' file has to be
+        # read by the same BibLaTeX version that created it). This is hard
+        # to do with non-up-to-date places like arXiv. Therefore, we thus
+        # just copy the whole of BibLaTeX's source (the version we are
+        # using) into the top tarball directory. In this way, arXiv's LaTeX
+        # engine will use the same BibLaTeX version to interpret the `.bbl'
+        # file. TIP: you can use the same strategy for other LaTeX packages
+        # that may cause problems on the arXiv server.
+	cp tex/build/build/paper.bbl $$dir/
+	tltopdir=.local/texlive/2019/texmf-dist/tex/latex
+	find $$tltopdir/biblatex/ -maxdepth 1 -type f -print0 \
+	     | xargs -0 cp -t $$dir
+
+        # PROJECT SPECIFIC
+        # ----------------
+        # Put any project specific distribution steps here.
+        # ----------------
 
         # 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.
+        # the paper. This will disable usage of TiKZ.
 	sed -e's|\\newcommand{\\makepdf}{}|%\\newcommand{\\makepdf}{}|' \
 	    paper.tex > $$dir/paper.tex
 
         # Just in case the package users want to rebuild some of the
-        # figures (manually un-comments the `makepdf' command we commented
+        # figures (manually un-comment the `makepdf' command we commented
         # above), correct the TikZ external directory, so the figures can
         # be rebuilt.
 	pgfsettings="$$dir/tex/src/preamble-pgfplots.tex"
-- 
cgit v1.2.1