The current Makefile build system has a critical flaw where make distclean removes PDF files that are actually required dependencies for LaTeX compilation, not just generated outputs.
Steps to Reproduce
- Modify a shared style file (e.g.,
shared/styles/custom.sty)
- Run
make all in any topic directory (e.g., neural-networks/)
- Get "Nothing to be done for 'all'" because PDFs exist and are newer than .tex files
- Run
make distclean to force rebuild
- Run
make all again
- ERROR: Compilation fails because required
*-notes.pdf files are missing
Root Cause
The distclean target indiscriminately removes all PDF files:
distclean: clean
cd $(SLIDES_DIR) && rm -f *.pdf
This removes two different types of PDFs:
- Generated PDFs (should be deleted):
autograd.pdf, cnn.pdf, etc.
- Source PDFs (should NOT be deleted):
autograd-notes.pdf, cnn-notes.pdf, etc.
Current Affected Files
Files that include external PDF dependencies:
neural-networks/slides/autograd.tex → autograd-notes.pdf
neural-networks/slides/cnn.tex → cnn-notes.pdf
neural-networks/slides/mlp.tex → mlp-notes.pdf
neural-networks/slides/cnn-1d.tex → cnn-notes.pdf
neural-networks/slides/next-token-prediction.tex → next-token-notes.pdf
maths/slides/constrained-1.tex → constrained-1-notes.pdf
maths/slides/constrained-2.tex → constrained-2-notes.pdf
- And others...
Proposed Solutions
Option 1: Smarter distclean
Only remove PDFs that correspond to existing .tex files:
distclean: clean
cd $(SLIDES_DIR) && for tex in *.tex; do rm -f "$${tex%.tex}.pdf"; done
Option 2: Separate directories
- Move source PDFs to
assets/ directory
- Update
\includepdf paths accordingly
- Keep only generated PDFs in
slides/
Option 3: Dependency tracking
In each of the Makefiles, instead of
# Rule to compile LaTeX to PDF
$(SLIDES_DIR)/%.pdf: $(SLIDES_DIR)/%.tex
@echo "Compiling $< to $@"
cd $(SLIDES_DIR) && pdflatex -interaction=nonstopmode $(notdir $<)
cd $(SLIDES_DIR) && pdflatex -interaction=nonstopmode $(notdir $<)
Add dependency tracking for style files:
# Rule to compile LaTeX to PDF
$(SLIDES_DIR)/%.pdf: $(SLIDES_DIR)/%.tex $(SHARED_DIR)/styles/*.sty
@echo "Compiling $< to $@"
cd $(SLIDES_DIR) && pdflatex -interaction=nonstopmode $(notdir $<)
cd $(SLIDES_DIR) && pdflatex -interaction=nonstopmode $(notdir $<)
The current Makefile build system has a critical flaw where
make distcleanremoves PDF files that are actually required dependencies for LaTeX compilation, not just generated outputs.Steps to Reproduce
shared/styles/custom.sty)make allin any topic directory (e.g.,neural-networks/)make distcleanto force rebuildmake allagain*-notes.pdffiles are missingRoot Cause
The
distcleantarget indiscriminately removes all PDF files:This removes two different types of PDFs:
autograd.pdf,cnn.pdf, etc.autograd-notes.pdf,cnn-notes.pdf, etc.Current Affected Files
Files that include external PDF dependencies:
neural-networks/slides/autograd.tex→autograd-notes.pdfneural-networks/slides/cnn.tex→cnn-notes.pdfneural-networks/slides/mlp.tex→mlp-notes.pdfneural-networks/slides/cnn-1d.tex→cnn-notes.pdfneural-networks/slides/next-token-prediction.tex→next-token-notes.pdfmaths/slides/constrained-1.tex→constrained-1-notes.pdfmaths/slides/constrained-2.tex→constrained-2-notes.pdfProposed Solutions
Option 1: Smarter distclean
Only remove PDFs that correspond to existing .tex files:
Option 2: Separate directories
assets/directory\includepdfpaths accordinglyslides/Option 3: Dependency tracking
In each of the Makefiles, instead of
Add dependency tracking for style files: