# Makefile for creating an ATLAS paper draft using journal classes

PDFLATEX = pdflatex
BIBTEX   = bibtex

TEXFILES = $(wildcard *.tex)

# Portable file removal: works on Linux, macOS, and Windows (cmd/PowerShell)
ifeq ($(OS),Windows_NT)
    RM_F = if exist $1 del /f /q $1
else
    RM_F = rm -f $1
endif

.PHONY: clean

all: atlas-elsevier atlas-jhep atlas-jinst atlas-revtex

atlas-elsevier: atlas-elsevier.pdf
	@echo "Made $<"

atlas-jhep: atlas-jhep.pdf
	@echo "Made $<"

atlas-jinst: atlas-jinst.pdf
	@echo "Made $<"

atlas-revtex: atlas-revtex.pdf
	@echo "Made $<"

# Standard LaTeX targets
%.pdf: %.tex *.bib
	$(PDFLATEX) $<
	-$(BIBTEX)  $(basename $<)
	$(PDFLATEX) $<
	$(PDFLATEX) $<

# Add extra extensions here if needed.
LATEX_TEMP_EXTS = .aux .log .out \
	.bcf .fdb_latexmk .fls .run.xml .synctex.gz -SAVE-ERROR \
	.bbl .blg .brf -blx.bib \
	.ind .idx .ilg .inx .lb .tdo \
	.lof .lot .toc

 # Remove *.spl *-revtexNotes.bib in addition to usual files.
clean:
	$(foreach ext, $(LATEX_TEMP_EXTS), $(call RM_F, *$(ext));)
	$(call RM_F, *.spl)
	$(call RM_F, *-revtexNotes.bib)

cleanall: clean
	$(call RM_F, *.pdf)
