confer/Makefile
2024-08-01 04:48:11 +03:00

67 lines
1.4 KiB
Makefile

SRCS = $(wildcard src/*.c) $(wildcard src/*/*.c)
OBJS = $(patsubst src/%.c,dist/%.o,$(SRCS))
HDRS = $(wildcard src/*.h)
PO_SRCS = $(wildcard locale/*/*/*.po)
PO_OUTS = $(patsubst locale/%.po,locale/%.mo,$(PO_SRCS))
PO_DIRS = $(wildcard locale/*/*)
CFLAGS = -O3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection
LIBS = -linih -lgit2 -lcurl -lcrypto
VERSION = 24.03
PREFIX = /usr
CC = gcc
all: dist dist/confer $(PO_OUTS)
dist:
mkdir -pv dist/cmd
dist/confer: $(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/mc.pot
cp $@ $@.old
if msgmerge $@ $^ -o $@ ; then \
rm $@.old ; \
echo "merge success: $@" ; \
else \
echo "merge failed: $@" ; \
mv $@.old $@ ; \
fi; \
locale/confer.pot: $(SRCS)
mkdir -p locale
xgettext -k_ -c $^ -o $@
install:
mkdir -pv $(DESTDIR)/$(PREFIX)/bin
install -v -m755 dist/confer $(DESTDIR)/$(PREFIX)/bin/confer
@for po in $(PO_DIRS) ; do \
echo "installing locale: $$po/mc.mo" ; \
mkdir -pv $(DESTDIR)/$(PREFIX)/share/$$po ; \
cp $$po/mc.mo $(DESTDIR)/$(PREFIX)/share/$$po ; \
done
uninstall:
rm -v $(DESTDIR)/$(PREFIX)/bin/confer
clean:
rm dist/mc
rm locale/mc.pot
@for po in $(PO_DIRS) ; do \
rm $$po/confer.mo ; \
done
format:
clang-format -i -style=file $(HDRS) $(SRCS)
.PHONY: install uninstall clean format