diff options
author | Mohammad Akhlaghi <mohammad@akhlaghi.org> | 2018-02-14 15:46:15 +0100 |
---|---|---|
committer | Mohammad Akhlaghi <mohammad@akhlaghi.org> | 2018-02-14 15:46:15 +0100 |
commit | 3d216bd6797bc4bf0d02cd43adf37706b057c580 (patch) | |
tree | 5f3be80a234172f63df65790507fe38f09edb37f | |
parent | d26535d6665879f77d39e790b4aa9ee0dcb63dcf (diff) |
Symbolic link to build directory now permanently added
Managing this symbolic link as a prerequisite that may or maynot be defined
just made the code too dirty. It is almost always needed, so it is now a
super-high-level prerequisite (first dependency of the `all' target, even
before the final PDF). In this way, we can be sure it is always built and
that nothing else depends on it.
If the user doesn't want it, they can simply remove it from the top
`Makefile'.
-rw-r--r-- | Makefile | 33 | ||||
-rw-r--r-- | reproduce/src/make/initialize.mk | 45 |
2 files changed, 32 insertions, 46 deletions
@@ -27,12 +27,14 @@ # # The final paper (in PDF format) is the main target of this whole # reproduction pipeline. So as defined in the Make paradigm, we are -# defining it as the first target. +# defining it here. But since we also want easy access to the build +# directory during processing (before the PDF is build), that is placed as +# the first prerequisite. # # Note that if you don't have LaTeX to build the PDF or generally are just -# interested in the processing, you can avoid the skip to create the final -# PDF, see `reproduce/config/pipeline/pdf.mk'. -all: paper.pdf +# interested in the processing, you can skip create the final PDF creation +# with `BUILD-FINAL-PDF' of `reproduce/config/pipeline/LOCAL.mk'. +all: reproduce/build paper.pdf @@ -79,33 +81,20 @@ include $(foreach f, initialize download paper, reproduce/src/make/$(f).mk) # `reproduce/src/make/paper.mk'). This enables a clear demonstration of the # top-level dependencies clearly. # -# The symbolic link to the build directory (`bdirsym') is also placed here -# as a dependency if the pipeline is to be created. It is very important -# that it be an "order-only prerequisite" (after a `|', otherwise, it will -# try to be remade on every call and `ln' will complain and abort). -# # Note that if you don't want the final PDF and just want the processing # and file outputs, you can remove the value of the `BUILD-FINAL-PDF' # variable in `reproduce/config/LOCAL.mk'. -tex/pipeline.tex: $(foreach f, initialize download, $(mtexdir)/$(f).tex) \ - | $(bdirsym) +tex/pipeline.tex: $(foreach f, initialize download, $(mtexdir)/$(f).tex) # If no PDF is requested, then just exit here. ifeq ($(BUILD-FINAL-PDF),) - @echo; + @echo @echo "Everything is OK until this point, but not building PDF." @echo "To do so, give a value to the 'BUILD-FINAL-PDF' variable." @echo "It is defined in 'reproduce/config/pipeline/LOCAL.mk'." - @echo; + @echo @exit 1 endif - # Read all the separate files and put them into the final TeX - # macros file. Since `bdirsym' maybe empty, we can't use the - # `filter-out' function generically. We'll have to check `bdirsym' - # first. -ifeq ($(bdirsym),) - cat $^ > $@ -else - cat $(filter-out $(bdirsym),$^) > $@ -endif + # Merge all the TeX macros that are prepared for building the PDF. + @cat $(mtexdir)/*.tex > $@ diff --git a/reproduce/src/make/initialize.mk b/reproduce/src/make/initialize.mk index 927c292..7c272d5 100644 --- a/reproduce/src/make/initialize.mk +++ b/reproduce/src/make/initialize.mk @@ -36,7 +36,6 @@ texdir = $(BDIR)/tex srcdir = reproduce/src lockdir = $(BDIR)/locks -bdirsym = reproduce/build mtexdir = $(texdir)/macros gconfdir = reproduce/config/gnuastro pconfdir = reproduce/config/pipeline @@ -100,6 +99,26 @@ $(texdir) $(lockdir): | $(BDIR); mkdir $@ +# Symbolic link to build directory +# -------------------------------- +# +# Besides $(BDIR), we are also making a symbolic link to it for easy +# access. Recall that it is recommended that the actual build directory be +# in a completely separate part of the file system (a place that may easily +# be completely deleted). +# +# Note that $(BDIR) might not be an absolute path and this will complicate +# the symbolic link creation. To be generic, we'll first call `readlink' to +# make sure we have an absolute address, then we'll make a symbolic link to +# that. +reproduce/build: | $(BDIR) + absbdir=$$(readlink -f $(BDIR)); \ + ln -s $$absbdir $@ + + + + + # High-level Makefile management # ------------------------------ # @@ -115,7 +134,7 @@ clean: ifeq ($(configure-run),yes) rm -rf $(BDIR) endif - rm -f $(bdirsym) $(gconfdir)/mmap* *.pdf *.log *.out *.aux *.auxlock + rm -f reproduce/build $(gconfdir)/mmap* *.pdf *.log *.out *.aux *.auxlock @@ -140,25 +159,3 @@ $(mtexdir)/initialize.tex: | $(mtexdir) # Location of the build directory (for LaTeX inputs). @echo "\newcommand{\bdir}{$(BDIR)}" >> $@ - - - - - -# Symbolic link to build directory -# -------------------------------- -# -# Besides $(BDIR), we are also making a symbolic link to it if $(bdirsym) -# is not empty. In case this symbolic link is not needed, simply remove its -# value from the definitions above. In that case, it will be read as a -# blank (non-existant). -# -# Note that $(BDIR) might not be an absolute path and this will complicate -# the symbolic link creation. To be generic, we'll first call `readlink' to -# make sure we have an absolute address, then we'll make a symbolic link to -# that. -ifneq ($(bdirsym),) -$(bdirsym): | $(BDIR) - absbdir=$$(readlink -f $(BDIR)); \ - ln -s $$absbdir $(bdirsym) -endif |