From 2720a126aa5a8412f8d355f8937cf6c37975be78 Mon Sep 17 00:00:00 2001 From: hachem Date: Fri, 18 Sep 2026 13:59:45 +0200 Subject: feat: add letter template --- Makefile | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 8 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4512b74..a4c3868 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,72 @@ -NAME := mktypst +BIN := mktypst +PKG := hachem VERSION := 0.1.0 +CC := clang +STD := c17 + +DEBUG ?= 1 +SANITIZE ?= 1 + +CFLAGS := -std=$(STD) \ + -Wall \ + -Wextra \ + -Wshadow \ + -Wpedantic \ + -Wconversion \ + -Wstrict-prototypes \ + -Wsign-conversion \ + -Wmissing-prototypes + +ifeq ($(DEBUG),1) +CFLAGS += -g -fno-omit-frame-pointer +else +CFLAGS += -O2 +endif + +ifeq ($(SANITIZE),1) +CFLAGS += -fsanitize=address,undefined +LDFLAGS += -fsanitize=address,undefined +endif + +PREFIX ?= /usr/local +bindir := $(DESTDIR)$(PREFIX)/bin + ifeq ($(shell uname),Darwin) DATADIR := $(HOME)/Library/Application Support else DATADIR := $(if $(XDG_DATA_HOME),$(XDG_DATA_HOME),$(HOME)/.local/share) endif +pkgdir := $(DATADIR)/typst/packages/local/$(PKG)/$(VERSION) + +all: $(BIN) + +$(BIN): mktypst.c + $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) -PKGDIR := $(DATADIR)/typst/packages/local/$(NAME)/$(VERSION) +install: install-bin install-pkg -install: - mkdir -p "$(PKGDIR)" - cp typst.toml lib.typ README.md LICENSE "$(PKGDIR)"/ - cp -r templates "$(PKGDIR)"/ +install-bin: + $(MAKE) DEBUG=0 SANITIZE=0 clean $(BIN) + install -d $(bindir) + install -m 755 $(BIN) $(bindir)/$(BIN) + +install-pkg: + mkdir -p "$(pkgdir)" + cp typst.toml lib.typ README.md LICENSE "$(pkgdir)"/ + cp -r templates "$(pkgdir)"/ uninstall: - rm -rf "$(DATADIR)/typst/packages/local/$(NAME)/$(VERSION)" + rm -f $(bindir)/$(BIN) + rm -rf "$(DATADIR)/typst/packages/local/$(PKG)/$(VERSION)" + +samples: + @for f in samples/*.typ; do \ + printf ' %s\n' "$${f%.typ}.pdf"; \ + typst compile --root . "$$f" "$${f%.typ}.pdf" || exit 1; \ + done + +clean: + rm -rf $(BIN) $(BIN).dSYM samples/*.pdf -.PHONY: install uninstall +.PHONY: all install install-bin install-pkg uninstall samples clean -- cgit v1.3