matt/Makefile
2024-08-16 03:20:24 +03:00

67 lines
1.5 KiB
Makefile

PREFIX = /usr
CC = gcc
PO_SRCS = $(wildcard locale/*/*/*.po)
PO_OUTS = $(patsubst locale/%.po,locale/%.mo,$(PO_SRCS))
PO_DIRS = $(wildcard locale/*/*)
SRCS = $(wildcard src/*.c) $(wildcard src/*/*.c)
HDRS = $(wildcard src/*.h) $(wildcard src/*/*.h)
OBJS = $(patsubst src/%.c,dist/%.o,$(SRCS))
CFLAGS = -O3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection
LIBS = -linih -lmp
VERSION = 24.01
all: dist dist/matt $(PO_OUTS)
dist:
mkdir -pv $@/cmd
dist/matt: $(OBJS)
$(CC) -o $@ $^ $(LIBS) $(CFLAGS)
dist/%.o: src/%.c
$(CC) -c -o $@ $^ $(LIBS) $(CFLAGS) -DVERSION=\"${VERSION}\"
locale/%.mo: locale/%.po
msgfmt $^ -o $@
locale/%.po: locale/matt.pot
cp $@ $@.old
if msgmerge $@ $^ -o $@ ; then \
rm $@.old ; \
echo "merge success: $@" ; \
else \
echo "merge failed: $@" ; \
mv $@.old $@ ; \
fi; \
locale/matt.pot: $(SRCS)
mkdir -p locale
xgettext -k_ -c $^ -o $@
install:
install -d -m755 $(DESTDIR)/var/lib/matt
install -m755 dist/matt $(DESTDIR)/$(PREFIX)/bin/matt
@for po in $(PO_DIRS) ; do \
echo "installing locale: $$po/matt.mo" ; \
mkdir -pv $(DESTDIR)/$(PREFIX)/share/$$po ; \
cp $$po/matt.mo $(DESTDIR)/$(PREFIX)/share/$$po ; \
done
uninstall:
rm $(DESTDIR)/$(PREFIX)/bin/matt
@for po in $(PO_DIRS) ; do \
rm $(DESTDIR)/$(PREFIX)/share/$$po/matt.mo ; \
done
format:
clang-format -i -style=file src/*.c src/*.h
config:
install -d -m755 $(DESTDIR)/etc/matt
install -m644 install/config.ini $(DESTDIR)/etc/matt/config.ini
.PHONY: install uninstall format config