libmp/Makefile
2024-06-21 04:42:51 +03:00

68 lines
1.6 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 -march=native -fstack-protector-strong -fcf-protection=full -fstack-clash-protection
LIBS = -larchive -linih -lgpgme
VERSION = 24.00
all: dist/libmp.so $(PO_OUTS)
dist/libmp.so: $(OBJS)
mkdir -p dist
$(CC) -shared -o $@ $^ $(LIBS) $(CFLAGS)
dist/%.o: src/%.c
mkdir -p dist
$(CC) -c -Wall -fPIC -o $@ $^ $(LIBS) $(CFLAGS) -DVERSION=\"${VERSION}\"
locale/%.mo: locale/%.po
msgfmt $^ -o $@
locale/%.po: locale/libmp.pot
cp $@ $@.old
if msgmerge $@ $^ -o $@ ; then \
rm $@.old ; \
echo "merge success: $@" ; \
else \
echo "merge failed: $@" ; \
mv $@.old $@ ; \
fi; \
locale/libmp.pot: $(SRCS)
mkdir -p locale
xgettext -k_ -c $^ -o $@
install:
install -m755 dist/libmp.so $(DESTDIR)$(PREFIX)/lib/libmp.so
mkdir -pv $(DESTDIR)/usr/include/libmp
cp $(HDRS) $(DESTDIR)/usr/include/libmp
@for po in $(PO_DIRS) ; do \
echo "installing locale: $$po/libmp.mo" ; \
mkdir -pv $(DESTDIR)/usr/share/$$po ; \
cp $$po/libmp.mo $(DESTDIR)/usr/share/$$po ; \
done
uninstall:
rm $(DESTDIR)$(PREFIX)/lib/libmp.so
rm -r $(DESTDIR)/usr/include/libmp
format:
clang-format -i -style=file src/*.c src/*.c include/*.h examples/*/*.c
examples:
ifeq (,$(wildcard dist/libmp.so))
@echo "!!!! you should first compile libmp !!!!"
exit 1
endif
$(MAKE) -C $@
.PHONY: test install uninstall format examples