Skip to content
Snippets Groups Projects
Makefile 1.47 KiB
Newer Older
  • Learn to ignore specific revisions
  • Jan Wille's avatar
    Jan Wille committed
    # Makefile for Latex project
    NAME = test
    
    LATEX = pdflatex
    BIBTEX = biber
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    SUBDIRS= img plt
    
    Jan Wille's avatar
    Jan Wille committed
    OUTDIR = test
    
    TEX_FLAGS = -file-line-error -interaction=nonstopmode
    
    Jan Wille's avatar
    Jan Wille committed
    COM_FLAGS = -output-directory=$(OUTDIR) -quiet
    
    Jan Wille's avatar
    Jan Wille committed
    GARBAGE_PATTERNS = *.aux *.bbl *.bcf *.blg *.idx *.ind *.lof *.lot *.log *.xml *.toc
    
    
    SUB_TEX_FILES = $(foreach D,$(SUBDIRS),$(wildcard $(D)/*.tex))
    SUB_PDF_FILES = $(join $(dir $(SUB_TEX_FILES)),$(addprefix $(OUTDIR)/,$(notdir $(SUB_TEX_FILES:tex=pdf))))
    
    Jan Wille's avatar
    Jan Wille committed
    GARBAGE = $(foreach D,. $(SUBDIRS), $(wildcard $(addprefix $(D)/$(OUTDIR)/,$(GARBAGE_PATTERNS))))
    
    
    export TEXINPUTS:=$(CURDIR)\src
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    Jan Wille's avatar
    Jan Wille committed
    std: all tidy
    
    
    all: bib
    
    	$(LATEX) $(TEX_FLAGS) $(COM_FLAGS) $(NAME).tex
    	$(LATEX) -synctex=1 $(TEX_FLAGS) $(COM_FLAGS) $(NAME).tex
    	copy /Y $(OUTDIR)\$(NAME).pdf .\
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    pdf: $(SUB_PDF_FILES)
    
    	$(LATEX) -synctex=1 $(TEX_FLAGS) $(COM_FLAGS) $(NAME).tex
    
    
    bib: pdf $(OUTDIR)\$(NAME).bcf
    
    	$(BIBTEX) $(COM_FLAGS) $(NAME)
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    $(SUB_PDF_FILES): $(SUB_TEX_FILES)
    
    Jan Wille's avatar
    Jan Wille committed
    	cd $(subst $(OUTDIR)/,,$(dir $@)) && $(LATEX) $(TEX_FLAGS) $(COM_FLAGS) $(notdir $(@:pdf=tex))
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    Jan Wille's avatar
    Jan Wille committed
    clean: tidy
    
    Jan Wille's avatar
    Jan Wille committed
    	for %%a in ($(foreach D,$(subst /,\,$(SUB_PDF_FILES)) $(subst .pdf,.synctex.gz,$(subst /,\,$(SUB_PDF_FILES))) $(OUTDIR)\$(NAME).pdf $(OUTDIR)\$(NAME).synctex.gz, "$(D)")) do if exist %%~a del /q %%~a
    	for %%a in ($(foreach D,. $(SUBDIRS),"$(D)\$(if $(subst .,,$(OUTDIR)),$(OUTDIR),build)")) do if exist %%~a rmdir /q %%~a
    #	if exist $(NAME).pdf del $(NAME).pdf
    
    Jan Wille's avatar
    Jan Wille committed
    
    tidy:
    
    Jan Wille's avatar
    Jan Wille committed
    	if exist $(or $(word 1, $(subst /,\,$(GARBAGE))), false) del /q $(subst /,\,$(GARBAGE))