pooler/Makefile

64 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)
OBJS = $(patsubst src/%.c,dist/%.o,$(SRCS))
HDRS = $(wildcard include/*.h)
CFLAGS = -O3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection
LIBS = -linih -lmp
VERSION = 24.01
all: dist dist/pooler $(PO_OUTS)
dist:
mkdir -pv $@
dist/pooler: $(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/pooler.pot
cp $@ $@.old
if msgmerge $@ $^ -o $@ ; then \
rm $@.old ; \
echo "merge success: $@" ; \
else \
echo "merge failed: $@" ; \
mv $@.old $@ ; \
fi; \
locale/pooler.pot: $(SRCS)
mkdir -p locale
xgettext -k_ -c $^ -o $@
install:
install -d -m700 $(DESTDIR)/etc/pooler
install -Dm755 dist/pooler $(DESTDIR)/$(PREFIX)/bin/pooler
install -Dm600 install/config.ini $(DESTDIR)/etc/pooler/config.ini
@for po in $(PO_DIRS) ; do \
echo "installing locale: $$po/pooler.mo" ; \
mkdir -pv $(DESTDIR)/$(PREFIX)/share/$$po ; \
cp $$po/pooler.mo $(DESTDIR)/$(PREFIX)/share/$$po ; \
done
uninstall:
rm $(DESTDIR)/$(PREFIX)/bin/pooler
@for po in $(PO_DIRS) ; do \
rm $(DESTDIR)/$(PREFIX)/share/$$po/pooler.mo ; \
done
format:
clang-format -i -style=file src/*.c src/*.h
.PHONY: install uninstall format