From: Gustav Eek Date: Wed, 21 Aug 2024 18:07:42 +0000 (+0200) Subject: Add a general package Makefile X-Git-Url: https://git.g-eek.se/?a=commitdiff_plain;h=c519c8d8343b739d888190068f1a7f9c69db8bc4;p=guitarsections.git Add a general package Makefile --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8799646 --- /dev/null +++ b/Makefile @@ -0,0 +1,76 @@ +PKG = guitarsections +AUTHOR = Gustav Eek +LICENSE = gpl +SRC = $(PKG) + +.PHONY: all test install + +DTX = $(addsuffix .dtx, $(PKG)) +INS = $(addsuffix .ins, $(PKG)) +PDF = $(addsuffix .pdf, $(PKG)) +STY = $(addsuffix .sty, $(PKG)) + +all: $(DTX) $(INS) $(PDF) $(STY) + +# Generate package using makedtx and pdflatex + +$(DTX) $(INS): doc/$(PKG).tex tmp.sty + makedtx -author "$(AUTHOR)" -license $(LICENSE) \ + -src "tmp.sty=>$(STY)" -doc $< $(PKG) + +tmp.sty: $(addprefix tex/, $(addsuffix .sty, $(SRC))) + mkdir -p $(dir $@) + cat $^ | bash sh/macrocode.sh > $@ + +# Compilation for installation + +LTX_ENV = TEXINPUTS=".:tex:" + +%.sty: %.ins %.dtx + $(LTX_ENV) pdflatex $< + +%.pdf: %.dtx %.ins + $(LTX_ENV) pdflatex $< + +# Installation + +TEXMF ?= $(HOME)/texmf +DST_STY := $(TEXMF)/tex/latex/$(PKG) +DST_PDF := $(TEXMF)/doc + +install: \ + $(addprefix $(DST_STY)/, $(STY)) \ + $(addprefix $(DST_PDF)/, $(PDF)) + make -C tools $@ + +$(DST_STY)/%.sty: %.sty + mkdir -p $(dir $@) + cp $< $@ + texhash $(TEXMF) + +$(DST_PDF)/%.pdf: %.pdf + mkdir -p $(dir $@) + cp $< $@ + texhash $(TEXMF) + +uninstall: + make -C tools $@ + rm -f $(DST_STY)/* $(DST_PDF)/$(PKG).pdf + texhash $(TEXMF) + rmdir --ignore-fail-on-non-empty -p $(DST_STY) $(DST_PDF) + + +# Testing + +test: + make -C tex test + make -C tools test + +# Clean + +clean: + make -C tools $@ + rm -f *.aux *.hd *.log *.out + rm -f *.dtx *.ins *.pdf *.sty + rm -f *~ tex/*~ doc/*~ + rm -fr tmp