Skip to content

Commit

Permalink
improve build system
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyxi committed Oct 3, 2024
1 parent a2505cd commit 912c806
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# WARNING: target end with `!` will modify source code
PACKAGE = useclass
PACKAGE := useclass
EXT := sty
SOURCE := $(PACKAGE).dtx

TAG ?= $(shell git describe --tags --abbrev=0)

TEX = tex -interaction=nonstopmode -shell-escape
LATEX = pdflatex -interaction=nonstopmode -shell-escape
LATEXMK = latexmk -pdf -quiet -outdir=. -auxdir=.
L3BUILD = l3build
ZIP = zip
TEX := tex -interaction=nonstopmode -shell-escape
LATEX := pdflatex -interaction=nonstopmode -shell-escape
LATEXMK := latexmk -pdf -quiet -outdir=. -auxdir=.
L3BUILD := l3build
ZIP := zip
GIT := git

ifeq ($(OS), Windows_NT)
RM = cmd //C del //Q //F
RRM = cmd //C rmdir //Q //S
RM := cmd //C del //Q //F
RRM := cmd //C rmdir //Q //S
else
RM = rm -f
RRM = rm -r -f
RM := rm -f
RRM := rm -r -f
endif

%.ins %.$(EXT): %.dtx
Expand Down Expand Up @@ -46,13 +48,24 @@ doc: $(PACKAGE).pdf


tag!: # `make tag! TAG=1.0.0` [WARN: WILL MODIFY SOURCE CODE]
@if ! $(GIT) diff --quiet $(SOURCE); then \
echo "Error: Unstaged changes in $(SOURCE)"; \
exit 1; \
fi

@if ! $(GIT) diff --staged --quiet $(SOURCE); then \
echo "Error: Uncommitted changes in $(SOURCE)"; \
exit 1; \
fi

$(L3BUILD) tag $(TAG)

ctan!: tag! build # CTAN currently requires that the .tds.zip file be excluded
ctan: tag! build # CTAN currently requires that the .tds.zip file be excluded
$(L3BUILD) ctan
$(ZIP) -d $(PACKAGE)-ctan.zip $(PACKAGE).tds.zip
$(GIT) restore $(SOURCE)

release!: tag! build doc ctan! # release to GitHub
release!: tag! build ctan # release to GitHub


clean:
Expand Down

0 comments on commit 912c806

Please sign in to comment.