Skip to content
Snippets Groups Projects
Makefile 2 KiB
Newer Older
  • Learn to ignore specific revisions
  • Jan Wille's avatar
    Jan Wille committed
    # Makefile for Latex project
    NAME = test
    
    Jan Wille's avatar
    Jan Wille committed
    LATEX = latex
    PDFLATEX = pdflatex
    
    BIBTEX = biber
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    # OUTDIR needs to be at least this, can not be empty:
    OUTDIR = .
    AUXDIR = .aux
    IGNORE = src/%
    
    Jan Wille's avatar
    Jan Wille committed
    GARBAGE_PATTERNS = *.aux *.bbl *.bcf *.blg *.idx *.ind *.lof *.lot *.log *.xml *.toc *.synctex(busy) *.synctex.gz(busy)
    
    # comment this out to get all outputs:
    QUIET = -quiet
    TEX_FLAGS = -file-line-error -interaction=nonstopmode -aux-directory=$(dir $@)$(OUTDIR)/$(AUXDIR) -output-directory=$(dir $@)$(OUTDIR)
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    # this grabs all subfiles it can find
    SUB_TEX_FILES = $(filter-out $(IGNORE),$(wildcard **/*.tex))
    SUB_SVG_FILES = $(filter-out $(IGNORE),$(wildcard **/*.svg))
    # and makes a big list of prerequisits
    SUB_FILES = $(SUB_TEX_FILES:tex=pdf) $(SUB_SVG_FILES:svg=pdf_tex)
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    
    # get src folder on include path
    
    export TEXINPUTS:=$(CURDIR)\src
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    
    all: pdf bib
    
    Jan Wille's avatar
    Jan Wille committed
    	$(PDFLATEX) $(TEX_FLAGS) $(QUIET) $(NAME).tex
    	$(PDFLATEX) -synctex=1 $(TEX_FLAGS) $(QUIET) $(NAME).tex
    
    
    Jan Wille's avatar
    Jan Wille committed
    src: src/HsH-article.cls src/HsH-report.cls src/HsH-standalone.cls
    src/HsH-article.cls src/HsH-report.cls src/HsH-standalone.cls &: HsH-Classes.ins HsH-Classes.dtx
    
    Jan Wille's avatar
    Jan Wille committed
    	$(LATEX) -output-directory=src HsH-Classes.ins
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    pdf: $(SUB_FILES) $(OUTDIR)/$(NAME).pdf
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    bib: $(OUTDIR)/$(AUXDIR)/$(NAME).bcf
    	$(BIBTEX) -output-directory=$(OUTDIR)/$(AUXDIR) $(QUIET) $(NAME)
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    # generel latex call
    %.pdf: %.tex
    
    Jan Wille's avatar
    Jan Wille committed
    	$(PDFLATEX) $(TEX_FLAGS) $(QUIET) $*.tex
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    # generell inkscape call
    %.pdf_tex: %.svg
    	inkscape -C --export-latex $*.svg -o $*.pdf
    
    # little hack if temp files are not present
    %.bcf: $(NAME).tex
    	if exist $(NAME).pdf del $(NAME).pdf
    	$(MAKE) pdf
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    Jan Wille's avatar
    Jan Wille committed
    
    
    # These are NOT portable!!
    
    Jan Wille's avatar
    Jan Wille committed
    clean: tidy
    
    	for %%a in ($(subst /,\,$(SUB_FILES) $(SUB_SVG_FILES:svg=pdf))) do if exist %%~a del /s/q %%~a
    	if exist $(OUTDIR)\$(NAME).synctex.gz del $(OUTDIR)\$(NAME).synctex.gz
    	if exist $(OUTDIR)\$(NAME).pdf del $(OUTDIR)\$(NAME).pdf
    
    Jan Wille's avatar
    Jan Wille committed
    
    tidy:
    
    	for %%a in ($(OUTDIR)\$(AUXDIR) $(subst /,\,$(wildcard **/$(AUXDIR)))) do if exist %%~a rmdir /s/q %%~a
    	for %%a in ("$(wildcard $(GARBAGE_PATTERNS))") do if exist %%~a del /s/q %%~a