# # Makefile # # This makefile helps you building the document and testing the sources. # ## ## Commands ## # # The latex compiler # LATEX=$(shell which pdflatex) export LATEX # # The output command # ECHO_CMD=$(shell which echo) # # The command to remove something # RM_CMD=$(shell which rm) # The svgbob compiler SVGBOBC=$(shell which svgbob) # Inkscape path to compile svg to tex INKSCAPEC=$(shell which inkscape) # Graphviz compiler GRAPHVIZC=$(shell which dot) ## ## Flags ## # # Flags for subdirectories # MAKE_FLAGS=--no-print-directory export MAKE_FLAGS # # Flags for the latex compilre # LATEX_FLAGS=-halt-on-error -shell-escape export LATEX_FLAGS # # Output flags # ECHO_FLAGS=-e export ECHO_FLAGS # # The remove flags # RM_FLAGS=-f # Inkscape flags INKSCAPE_FLAGS=-D -o # Graphviz flags GRAPHVIZ_FLAGS=-Tpng ## ## Standard commands ## # # The command for printing something # ECHO=$(ECHO_CMD) $(ECHO_FLAGS) export ECHO RM=$(RM_CMD) $(RM_FLAGS) export RM SVGBOB=$(SVGBOBC) INKSCAPE=$(INKSCAPEC) $(INKSCAPE_FLAGS) GRAPHVIZ=$(GRAPHVIZC) $(GRAPHVIZ_FLAGS) ## ## Files ## # # The PDF file we want # PDF_FILE=main.pdf # # The latex source file # LATEX_MAIN_SOURCE=main.tex # # The main.aux file # AUX_FILE=main.aux # # .ist file # IST_FILE=main.ist # # Destination of the log from the make files # MAKELOG=make.log export MAKELOG # All svgbob files SVGBOB_ALL_SOURCES=$(shell find gen -name *.bob -type f) SVGBOB_FILES=$(patsubst gen/%.bob,%,$(SVGBOB_ALL_SOURCES)) # All Graphviz files GRAPHVIZ_ALL_SOURCES=$(shell find gen -name *.dot -type f) GRAPHVIZ_FILES=$(patsubst gen/%.dot,%,$(GRAPHVIZ_ALL_SOURCES)) ## ## Directories ## # # The directory where scripts are located # SCRIPTS=scripts export SCRIPTS # # The directory where are the generator scripts # GEN_DIR=gen export GEN_DIR ## ## Misc vars ## # Avoid strange shell setups, as proposed by the GNU coding standards SHELL = /bin/sh # # removeable latex temporary files # LATEX_TMPFILES_FLAT=log nav out snm toc vrb bbl blg idx lof lot glg glo gls ist glsdefs LATEX_TMPFILES_RECURSIVE=aux ## ## High level tasks ## # # The standard task, compiling the latex source to a # pdf document. # # We compile the sources three times, to be sure everything compiled correctly # all: $(PDF_FILE) # # Testing task. Not meant to produce a pdf but to check for flaws in the source # files # test one_time: $(AUX_FILE) gen_tex: $(SVGBOB_FILES) $(GRAPHVIZ_FILES) # Generate pictures with svgbob $(SVGBOB_FILES): %: $(SVGBOB_ALL_SOURCES) @$(ECHO) "\t[SVGBOB]\t$@\t$(GEN_DIR)/$@.svg" @$(SVGBOB) $(GEN_DIR)/$@.bob -o $(GEN_DIR)/$@.svg @$(ECHO) "\t[INKSCAPE]\t$@.svg\t$(GEN_DIR)/$@.png" @$(INKSCAPEC) $(INKSCAPE_FLAGS) $(GEN_DIR)/$@.png $(GEN_DIR)/$@.svg 2> /dev/null $(GRAPHVIZ_FILES): %: $(GRAPHVIZ_ALL_SOURCES) @$(ECHO) "\t[GRAPHVIZ]\t$@\t$(GEN_DIR)/$@.png" @$(GRAPHVIZ) $(GEN_DIR)/$@.dot -o $(GEN_DIR)/$@.png ## ## Generation tasks ## # # Generate main.aux from TeX sources # $(AUX_FILE): $(LATEX_MAIN_SOURCE) gen_tex @$(ECHO) "\t[LATEX]" @$(LATEX) $(LATEX_FLAGS) -draftmode $< >> $(MAKELOG) # # "Generate" .ist and .glo file simply by depending on the auxilary file # $(IST_FILE): $(AUX_FILE) # # Generate the PDF TODO: use stamp file and [[ -nt ]] or [[ -ot ]] (maybe in script) # $(PDF_FILE): $(AUX_FILE) @$(ECHO) "\t[LATEX]" @$(LATEX) $(LATEX_FLAGS) $(LATEX_MAIN_SOURCE) >> $(MAKELOG) @$(ECHO) "\t[LATEX]" @$(LATEX) $(LATEX_FLAGS) $(LATEX_MAIN_SOURCE) >> $(MAKELOG) ## ## Clean tasks ## # # Clean everything # clean: nearly_clean @$(ECHO) "\t[RM] *.pdf" @$(RM) "*.pdf" # # Remove everything except the target pdf file # nearly_clean: @for tmp in $(LATEX_TMPFILES_FLAT);do \ $(ECHO) "\t[RM]\t*.$$tmp"; \ $(RM) *.$$tmp; \ done @for tmp in $(LATEX_TMPFILES_RECURSIVE);do \ $(ECHO) "\t[RM]\t*.$$tmp"; \ $(RM) $$(find -name *.$$tmp -type f); \ done @$(ECHO) "\t[RM]\t$(MAKELOG)" @$(RM) $(MAKELOG)