# TODO ######## # Automatly detect TOC and IND (difficult) # Improve gnuplot dependencies # Justify text output # | grep "\e\[1m" to see only Makefile messages default: pdf ######################### # Delare your files here ######################### # All your documents # In case this Makefile is in a subdirectory, this is optionnal DOC := report # Latex sources report_TEX := report.tex \ AUTHORS.tex \ compile.tex #report_TEX := $(wildcard *.tex) # Extra files your document depend of report_EXT := # Hevea files (optionnal) report_HVA := report.hva # Css files (optionnal) report_CSS := report.css # Bibliography files report_BIB := report.bib # Glossary files report_GDF := #report.gdf # Images ######## # If you use his Makefile in a subdirectory containing only pictures, # only these declaration are usefull # Put source name of your pictures. # Your sources must be convertable to eps or png format. # You must use picture name whitout suffixe in your document. # Don't put additionnal files used for picture generation report_IMS := #img1.png img2.eps # img3.dia img4.plot # Subdirectories containing pictures. # These directories must contain a Makefile # Use of this variable break correct work of dependencies #report_SUBIMG := img # Compilation options ##################### # Should I generate Table Of Contents? report_TOC = yes # Should I generate Index? report_IND = # Should I use draft mode (no picture in draft mode)? # This option is global to all documents USE_DRAFT = yes # Extra declarations #################### EXTRA_CLEAN = AUTHORS.tex EXTRA_SUFFIX = EXTRA_PHONY = ############## # Extra Rules ############## AUTHORS.tex: AUTHORS Makefile grep "^\* " $< | perl -e '$$i=1; for (<>){ @e = /\(([^\s]+)\s(.*)\)/ ; print " \\and\n" if ($$i != 1); print "@e[0] \\textsc{@e[1]}"; $$i=0; }' > $@ # Add rules to generate pictures if they depend of many files #img1.eps: img1.gpl img1.dat ################# # Progams to use ################# RM = rm -f VIEWDVI = xdvi VIEWPDF = acroread #kpdf xpdf VIEWPS = gv LYNX = elinks PDFLATEX = pdflatex --interaction errorstopmode --file-line-error-style LATEX = latex --interaction errorstopmode --file-line-error-style DVIPS = dvips -z -Ppdf MAKEINDEX= makeindex HEVEA = hevea -francais # Density for vectorial to bitmap convertion DENSITY1 = 300x300 # Density for bitmap to vectorial convertion DENSITY2 = 144x144 LANGUAGE = fr_FR-lrg ####################### # End of configuration ####################### # You shouldn't modify anything after this line # Some warnings ############### ifeq ($(shell echo "$(MAKE_VERSION) >= 3.80" | bc), 0) $(error You need gmake > 3.80 to use this Makefile (Your version is $(MAKE_VERSION))) endif ifeq ($(DOC),) $(warning $$(DOC) is empty) endif # List of pictures extentions ############################# IN = png jpg bmp gif tif eps ps OUT = png jpg bmp gif tif eps # List of all files ################### DOC_IMS = $($(DOC:=_IMS)) DOC_TEX = $($(DOC:=_TEX)) DOC_BIB = $($(DOC:=_BIB)) DOC_IMG = $(basename $(DOC_IMS)) # General Rules ################ all: dvi pdf ps html txt info png pdf: $(DOC:=.pdf) ps: $(DOC:=.ps) dvi: $(DOC:=.dvi) html: $(DOC:=.html) txt: $(DOC:=.txt) info: $(DOC:=.info) png: $(DOC:=.png) jpg: $(DOC:=.jpg) bmp: $(DOC:=.bmp) tif: $(DOC:=.tif) img_png: $(DOC:=_img_png) img_jpg: $(DOC:=_img_jpg) img_bmp: $(DOC:=_img_bmp) img_tif: $(DOC:=_img_tif) img_eps: $(DOC:=_img_eps) text: txt # View and print ################ view: viewpdf viewdvi: $(DOC:=.dvi) $(VIEWDVI) $< & viewps: $(DOC:=.ps) $(VIEWPS) $< & viewpdf: $(DOC:=.pdf) $(VIEWPDF) $< & print: $(DOC:=.pdf) $(PRINT) $< # Check ####### spellcheck: $(DOC_TEX:.tex=.spell) lacheck: $(DOC:=.lacheck) check: spellcheck lacheck recheck: check_clean check check_clean: $(RM) $(DOC_TEX:.tex=.spell) $(DOC:=.lacheck) # Clean ####### img_clean: $(DOC:=_img_clean) $(RM) $(foreach s,$(OUT),$(filter-out $(DOC_IMS),$(DOC_IMG:=.$(s)))) clean: check_clean img_clean $(RM) $(EXTRA_CLEAN) *.[0-9] *~ $(DOC_BIB:.bib=.bbl) $(DOC_BIB:.bib=.blg) \ $(foreach s,.haux .aux .image.* .tex.bak,$(DOC_TEX:.tex=$(s))) \ $(foreach s,.htoc .toc .log .mtc* .out .ind .idx .lof .lot,$(DOC:=$(s))) distclean: clean $(RM) $(foreach s,.dvi .ps .pdf .txt .info .gif. jpg .bmp .pnm .tif \ .[0-9][0-9][0-9].png,$(DOC:=$(s))) *.html # Special rules ############### .SUFFIXES: .pdf .ps .dvi .txt .info .html .tex .bib \ .gpl .dot .eps .png .jpg .tif .bmp .pnm \ .toc .mtc .aux .bbl .idx .ind \ .spell .lacheck .haux .htoc $(EXTRA_SUFFIXES) .PHONY: default all clean distclean \ spellcheck lacheck check recheck \ view viewpdf viewps viewdvi print \ pdf ps dvi html txt text info \ img_eps img_png img_jpg img_bmp img_tif img_clean \ jpg tif bmp png pnm $(DOC:=_img_eps) \ $(DOC:=_img_png) $(DOC:=_img_jpg) $(DOC:=_img_bmp) \ $(DOC:=_img_tif) $(DOC:=_img_clean) $(EXTRA_PHONY) ################### # Rules generation ################### # For each document ################### define DOCtemplate ifdef $(1)_BIB $(1)_BBL = $($(1)_BIB:.bib=.bbl) endif ifdef $(1)_TOC $(1)_TOC = $(1).toc endif ifdef $(1)_IND $(1)_IND = $(1).ind endif ifdef $(1)_GDF $(1)_GLX = $(1).glx endif $(1)_IMG = $(basename $($(1)_IMS)) $(1).toc: $($(1)_TEX) $($(1)_EXT) $$($(1)_IMG:=.png) \ $(if '$($(1)_SUBIMG)' '',,$(1)_img_png) | $$($(1)_BBL) $$($(1)_GLX) $$($(1)_IND) $(1).glx: $($(1)_TEX) $($(1)_EXT) $$($(1)_IMG:=.png) $$($(1)_GDF) \ $(if '$($(1)_SUBIMG)' '',,$(1)_img_png) | $$($(1)_BBL) $(1).ind: $($(1)_TEX) $($(1)_EXT) $$($(1)_IMG:=.png) \ $(if '$($(1)_SUBIMG)' '',,$(1)_img_png) | $$($(1)_BBL) $(1).bbl: $($(1)_TEX) $($(1)_EXT) $$($(1)_IMG:=.png) \ $(if '$($(1)_SUBIMG)' '',,$(1)_img_png) $$($(1)_BIB) $(1).dvi: $($(1)_TEX) $($(1)_EXT) $$($(1)_IMG:=.eps) \ $(if '$($(1)_SUBIMG)' '',,$(1)_img_eps) $$($(1)_BBL) $$($(1)_GLX) $$($(1)_IND) $$($(1)_TOC) $(1).pdf: $($(1)_TEX) $($(1)_EXT) $$($(1)_IMG:=.png) \ $(if '$($(1)_SUBIMG)' '',,$(1)_img_png) $$($(1)_BBL) $$($(1)_GLX) $$($(1)_IND) $$($(1)_TOC) $(1).html: $($(1)_TEX) $($(1)_EXT) $$($(1)_IMG:=.eps) \ $(if '$($(1)_SUBIMG)' '',,$(1)_img_eps) $$($(1)_BBL) $$($(1)_GLX) $$($(1)_IND) $$($(1)_TOC) $($(1)_HVA) $(1).info: $($(1)_TEX) $($(1)_EXT) \ $$($(1)_BBL) $$($(1)_GLX) $$($(1)_IND) $$($(1)_TOC) $($(1)_HVA) $(1).txt: $($(1)_CSS) $$($(1)_IMG:=.png) \ $(if '$($(1)_SUBIMG)' '',,$(1)_img_png) $(1)_img_png: $$($(1)_IMG:=.png) $(foreach r,$($(1)_SUBIMG),make DOC=$(1) -C $(r) img_png; ) $(1)_img_eps: $$($(1)_IMG:=.eps) $(foreach r,$($(1)_SUBIMG),make DOC=$(1) -C $(r) img_eps; ) $(1)_img_jpg: $$($(1)_IMG:=.jpg) $(foreach r,$($(1)_SUBIMG),make DOC=$(1) -C $(r) img_jpg; ) $(1)_img_bmp: $$($(1)_IMG:=.bmp) $(foreach r,$($(1)_SUBIMG),make DOC=$(1) -C $(r) img_bmp; ) $(1)_img_tif: $$($(1)_IMG:=.tif) $(foreach r,$($(1)_SUBIMG),make DOC=$(1) -C $(r) img_tif; ) $(1)_img_clean: $(foreach r,$($(1)_SUBIMG),make DOC=$(1) -C $(r) img_clean; ) endef $(foreach prog,$(DOC),$(eval $(call DOCtemplate,$(prog)))) # For each picture ################## define IMGtemplate ifneq ($(1),) $(addsuffix .$(2),$(basename $(1))): %.$(2): %.$(3) @echo -e "\e[1mConversion of $$< to $$@\e[0m" ifeq ($(3),eps) convert -density $(DENSITY1) $$< $$@ else ifeq ($(3),ps) file=`echo $$@ | sed 's/\(.*\)\.\(png\|bmp\|pnm\|jpg\|tif\)/\1/'`; \ suf=`echo $$@ | sed 's/\(.*\)\.\(png\|bmp\|pnm\|jpg\|tif\)/\2/'`; \ rm -f $$@.[0-9] $$@ $$$$file-[0-9].$$$$suf convert -density 144x144 $$< $$@ if [ -f $$@.0 ]; then \ for i in $$@.[0-9]; do \ mv $$$$i `echo $$$$i | sed 's/\(.*\)\.\(png\|bmp\|pnm\|jpg\|tif\)\.\([0-9]\)/\1-\3.\2/'`; \ done; \ ln -s `echo $$@ | sed 's/\(.*\)\.\(png\|bmp\|pnm\|jpg\|tif\)/\1-0.\2/'` $$@; \ fi else ifeq ($(2),eps) convert -density $(DENSITY2) $$< $$@ else convert $$< $$@ endif endif endif endif endef $(foreach in,$(IN),$(foreach out,$(filter-out $(in),$(OUT)),$(eval $(call IMGtemplate,$(filter %.$(in), $(DOC_IMS)),$(out),$(in))))) # General rules ############### # Common targets .tex.bbl: ifndef USE_DRAFT @echo -e "\e[1mCreation of $@ from $<\e[0m" $(PDFLATEX) $< else @echo -e "\e[1mCreation of $@ from $< (draft mode)\e[0m" $(PDFLATEX) '\def\draft{1}\input $<' endif $(RM) $(<:.tex=.toc) bibtex $(<:.tex=) .tex.glx: ifndef USE_DRAFT @echo -e "\e[1mCreation of $@ from $<\e[0m" $(PDFLATEX) $< else @echo -e "\e[1mCreation of $@ from $< (draft mode)\e[0m" $(PDFLATEX) '\def\draft{1}\input $<' endif glosstex $< $($(<:.tex=)_GDF) $(MAKEFINDEX) $(<:.tex=.gxs) -o $(<:.tex=.glx) -s glosstex.ist .tex.ind: ifndef USE_DRAFT @echo -e "\e[1mCreation of $@ from $<\e[0m" $(PDFLATEX) $< else @echo -e "\e[1mCreation of $@ from $< (draft mode)\e[0m" $(PDFLATEX) '\def\draft{1}\input $<' endif $(MAKEINDEX) $(<:.tex=) .tex.toc: ifndef USE_DRAFT @echo -e "\e[1mCreation of $@ from $<\e[0m" $(PDFLATEX) $< else @echo -e "\e[1mCreation of $@ from $< (draft mode)\e[0m" $(PDFLATEX) '\def\draft{1}\input $<' endif .tex.pdf: @echo -e "\e[1mCreation of $@ from $<\e[0m" $(PDFLATEX) $< '$($(<:.tex=)_TOC)' [ "$($(<:.tex=)_TOC)" ] && touch $(<:.tex=.toc) $@ || true .tex.dvi: @echo -e "\e[1mCreation of $@ from $<\e[0m" $(LATEX) $< [ "$($(<:.tex=)_TOC)" ] && touch $(<:.tex=.toc) $@ || true .dvi.ps: dvips $< # Html, Info and Text .tex.info: $(RM) *.haux *.htoc hevea -fix -info $($(@:.info=)_HVA) $< .tex.html: $(RM) *.haux *.htoc hevea -fix $($(@:.html=)_HVA) $< tidy -ib -wrap 60 -m $@ .html.txt: $(LYNX) -dump -dump-width 80 -dump-charset UTF-8 $(@:.txt=.html) > $@ # Check .tex.spell: aspell check --lang=$(LANGUAGE) $< touch $@ .tex.lacheck: @if which chktex; then \ chktex $<; \ else \ echo -e "\e[1mTry to install chktex for better results\e[0m"; \ if which lacheck; then \ lacheck $<; \ fi \ fi # Pictures .plot.eps .gpl.eps: @echo -e "\e[1mCreation of $@ from $<\e[0m" gnuplot $< > $@ .dot.png: @echo -e "\e[1mCreation of $@ from $<\e[0m" dot -Tpng $< > $@ .dot.eps: @echo -e "\e[1mCreation of $@ from $<\e[0m" dot -Teps $< > $@ .dia.png: @echo -e "\e[1mCreation of $@ from $<\e[0m" dia -n -t png $< .dia.eps: @echo -e "\e[1mCreation of $@ from $<\e[0m" dia -n -t eps $< .ps.png .ps.jpg .ps.bmp .ps.tif: file=`echo $@ | sed 's/\(.*\)\.\(png\|bmp\|pnm\|jpg\|tif\)/\1/'`; \ suf=`echo $@ | sed 's/\(.*\)\.\(png\|bmp\|pnm\|jpg\|tif\)/\2/'`; \ rm -f $@.[0-9] $@ $$file-[0-9].$$suf convert -density 144x144 $< $@ if [ -f $@.0 ]; then \ for i in $@.[0-9]; do \ mv $$i `echo $$i | sed 's/\(.*\)\.\(png\|bmp\|pnm\|jpg\|tif\)\.\([0-9]\)/\1-\3.\2/'`; \ done; \ ln -s `echo $@ | sed 's/\(.*\)\.\(png\|bmp\|pnm\|jpg\|tif\)/\1-0.\2/'` $@; \ fi