Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
216 views
ubuntu2404
# Aerospace Engineering CFD LaTeX Template Makefile
# Supports PythonTeX compilation for embedded Python code

# Main document name (without extension)
MAIN = main

# LaTeX compiler
LATEX = pdflatex
PYTHONTEX = pythontex

# Compilation flags
LATEX_FLAGS = -shell-escape -interaction=nonstopmode -file-line-error
PYTHONTEX_FLAGS = --verbose

# Default target
all: $(MAIN).pdf

# Main compilation with PythonTeX
$(MAIN).pdf: $(MAIN).tex
	@echo "=== Compiling Aerospace Engineering CFD Template ==="
	@echo "Step 1: Initial LaTeX compilation..."
	$(LATEX) $(LATEX_FLAGS) $(MAIN).tex
	@echo "Step 2: Running PythonTeX for Python code execution..."
	$(PYTHONTEX) $(PYTHONTEX_FLAGS) $(MAIN).tex
	@echo "Step 3: Final LaTeX compilation..."
	$(LATEX) $(LATEX_FLAGS) $(MAIN).tex
	@echo "Step 4: Second final pass to resolve all references..."
	$(LATEX) $(LATEX_FLAGS) $(MAIN).tex
	@echo "=== Compilation complete! ==="
	@echo "Generated files:"
	@ls -la $(MAIN).pdf *.png *.pdf 2>/dev/null || true

# Quick compilation (without PythonTeX)
quick: $(MAIN).tex
	@echo "=== Quick compilation (no Python execution) ==="
	$(LATEX) $(LATEX_FLAGS) $(MAIN).tex
	$(LATEX) $(LATEX_FLAGS) $(MAIN).tex

# Clean auxiliary files
clean:
	@echo "=== Cleaning auxiliary files ==="
	rm -f *.aux *.log *.out *.toc *.fls *.fdb_latexmk *.synctex.gz
	rm -f *.pytxcode *.pytxmcr *.pytxpyg
	rm -f pythontex-files-$(MAIN)/*
	rmdir pythontex-files-$(MAIN) 2>/dev/null || true
	@echo "Auxiliary files cleaned."

# Clean all generated files including PDF and figures
distclean: clean
	@echo "=== Cleaning all generated files ==="
	rm -f $(MAIN).pdf
	rm -f *.png *.pdf naca*.pdf turbojet*.pdf flight*.pdf heat*.pdf
	@echo "All generated files cleaned."

# Continuous compilation (watches for file changes)
watch:
	@echo "=== Watching for changes (press Ctrl+C to stop) ==="
	while true; do \
		inotifywait -e modify $(MAIN).tex 2>/dev/null && \
		make all; \
	done

# Check LaTeX dependencies
check-deps:
	@echo "=== Checking LaTeX dependencies ==="
	@command -v pdflatex >/dev/null 2>&1 || echo "WARNING: pdflatex not found"
	@command -v pythontex >/dev/null 2>&1 || echo "WARNING: pythontex not found"
	@python3 -c "import numpy, matplotlib, pandas" 2>/dev/null || echo "WARNING: Python packages missing"
	@echo "Dependency check complete."

# Show compilation help
help:
	@echo "Aerospace Engineering CFD LaTeX Template Makefile"
	@echo "=================================================="
	@echo "Targets:"
	@echo "  all       - Full compilation with PythonTeX (default)"
	@echo "  quick     - Quick compilation without Python execution"
	@echo "  clean     - Remove auxiliary files"
	@echo "  distclean - Remove all generated files including PDF"
	@echo "  watch     - Continuous compilation on file changes"
	@echo "  check-deps- Check for required dependencies"
	@echo "  help      - Show this help message"
	@echo ""
	@echo "Requirements:"
	@echo "  - pdflatex with -shell-escape support"
	@echo "  - pythontex package"
	@echo "  - Python 3 with numpy, matplotlib, pandas"

# Force targets (don't check file timestamps)
.PHONY: all quick clean distclean watch check-deps help