summaryrefslogtreecommitdiff
path: root/Makefile
blob: 2cd24056411a583bbbd47e1ca680eec3b62d6216 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
CC = cc
CFLAGS = -Wall -Wextra -Wpedantic -std=c23 \
	-I$$(brew --prefix gettext)/include \
	-L$$(brew --prefix gettext)/lib \
	-lintl

PREFIX = /usr/local
DPREFIX = $(DESTDIR)$(PREFIX)
PODIR = $(DPREFIX)/share/locale

all: tiktok

tiktok: main.c
	$(CC) $(CFLAGS) -DPODIR='"$(PODIR)"' -o $@ $<

extract:
	xgettext --from-code=UTF-8 -k_ -o po/tiktok.pot main.c
	find po -name '*.po' -exec msgmerge {} po/tiktok.pot -o {} \;

translations:
	find po -name '*.po' | \
		while read -r file; do msgfmt "$$file" -o "$${file%po}mo"; done

install:
	mkdir -p "$(DPREFIX)/bin" "$(DPREFIX)/share/man/man1"
	find po -type d -maxdepth 2 -mindepth 2 | while read -r path;               \
	do                                                                          \
		mkdir -p "$(PODIR)/$${path#*/}";                                        \
		msgfmt "$$path/tiktok.po" -o "$(PODIR)/$${path#*/}/tiktok.mo";          \
	done
	cp tiktok "$(DPREFIX)/bin"

clean:
	rm tiktok
	find po -name '*.mo' -delete