Skip to content

[BUG] Build System Issue: make distclean Removes Required PDF Dependencies #62

@guntas-13

Description

@guntas-13

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

  1. Modify a shared style file (e.g., shared/styles/custom.sty)
  2. Run make all in any topic directory (e.g., neural-networks/)
  3. Get "Nothing to be done for 'all'" because PDFs exist and are newer than .tex files
  4. Run make distclean to force rebuild
  5. Run make all again
  6. 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:

  1. Generated PDFs (should be deleted): autograd.pdf, cnn.pdf, etc.
  2. 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.texautograd-notes.pdf
  • neural-networks/slides/cnn.texcnn-notes.pdf
  • neural-networks/slides/mlp.texmlp-notes.pdf
  • neural-networks/slides/cnn-1d.texcnn-notes.pdf
  • neural-networks/slides/next-token-prediction.texnext-token-notes.pdf
  • maths/slides/constrained-1.texconstrained-1-notes.pdf
  • maths/slides/constrained-2.texconstrained-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 $<)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions