Skip to content
Snippets Groups Projects
Makefile 1.38 KiB
Newer Older
Clément DURAND's avatar
Clément DURAND committed
.PHONY: package install clean cleandist

Clément DURAND's avatar
Clément DURAND committed
V:=1

ifeq ("$V","1")
define say
	@tput setaf 4
	@echo $1
	@tput sgr0
endef
else
define say
endef
endif

define installed
	@tput setaf 2
	@tput bold
	@echo "SUCCESS : installed in '"$1"'."
endef

Clément DURAND's avatar
Clément DURAND committed
PDFLATEX:=pdflatex -interaction=nonstopmode
Clément DURAND's avatar
Clément DURAND committed
MAKEINDEX:=makeindex -q -s gind.ist -o
OUTPUT:=>/dev/null 2>&1
Clément DURAND's avatar
Clément DURAND committed
PKGDIR:=$(shell kpsewhich --show-path=ls-R | tr : '\n' | grep texmf | grep local | head -n1)
POLYPKGDIR:=$(PKGDIR)/tex/latex/polytechnique
Guangshuo Chen's avatar
Guangshuo Chen committed
DTXFILES:=$(shell find . -name '*.dtx')
Clément DURAND's avatar
Clément DURAND committed
GENFILES:=$(patsubst %.dtx,%.pdf,$(DTXFILES)) $(patsubst %.dtx,%.sty,$(DTXFILES))
Clément DURAND's avatar
Clément DURAND committed

all: package

package: polytechnique.sty

%.sty: %.dtx
Clément DURAND's avatar
Clément DURAND committed
	$(call say,creating package file $@)
	@$(PDFLATEX) $*.dtx $(OUTPUT)
	@$(MAKEINDEX) $*.ind $*.idx $(OUTPUT)
	@$(PDFLATEX) $*.dtx $(OUTPUT)
Clément DURAND's avatar
Clément DURAND committed

install: package clean
Clément DURAND's avatar
Clément DURAND committed
	$(call say,creating destination $(POLYPKGDIR))
	@mkdir -p $(POLYPKGDIR)
	$(call say,copying files to $(POLYPKGDIR))
	@cp -r . $(POLYPKGDIR)
	@rm -f $(POLYPKGDIR)/Makefile
neze's avatar
neze committed
	@texhash || mktexlsr
Clément DURAND's avatar
Clément DURAND committed
	$(call installed,$(POLYPKGDIR))
Clément DURAND's avatar
Clément DURAND committed

clean:
Clément DURAND's avatar
Clément DURAND committed
	$(call say,cleaning files)
	@rm -f polytechnique.aux polytechnique.glo polytechnique.idx polytechnique.log polytechnique.out polytechnique.toc polytechnique.ind polytechnique.ilg
Clément DURAND's avatar
Clément DURAND committed

cleandist: clean
Clément DURAND's avatar
Clément DURAND committed
	$(call say,removing doc and package files)
	@rm -f $(GENFILES)
Clément DURAND's avatar
Clément DURAND committed

%.pdf: %.eps
	ps2pdf -dEPSCrop -dCompressPages=false $< - | \
		sed '/^..*g$$/ s/^./%/' > $@