libmp/Makefile

77 lines
1.8 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 = -lpthread -lcrypto -larchive -linih -lgpgme -lsqlite3
DEBUG = 0
VERSION = 24.00
all: dist dist/libmp.so $(PO_OUTS)
dist:
mkdir -p dist/ctx
mkdir -p dist/mptp
mkdir -p dist/pool
mkdir -p dist/package
mkdir -p dist/database
dist/libmp.so: $(OBJS)
$(CC) -shared -o $@ $^ $(LIBS) $(CFLAGS)
dist/%.o: src/%.c
$(CC) -c -Wall -fPIC -o $@ $^ $(LIBS) $(CFLAGS) -DLM_VERSION=\"${VERSION}\" -DLM_DEBUG=${DEBUG}
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)/$(PREFIX)/include/libmp
cp $(HDRS) $(DESTDIR)/usr/include/libmp
@for po in $(PO_DIRS) ; do \
echo "installing locale: $$po/libmp.mo" ; \
mkdir -pv $(DESTDIR)/$(PREFIX)/share/$$po ; \
cp $$po/libmp.mo $(DESTDIR)/$(PREFIX)/share/$$po ; \
done
uninstall:
rm $(DESTDIR)/$(PREFIX)/lib/libmp.so
rm -r $(DESTDIR)/$(PREFIX)/include/libmp
@for po in $(PO_DIRS) ; do \
rm $(DESTDIR)/$(PREFIX)/share/$$po/libmp.mo ; \
done
format:
clang-format -i -style=file src/*.c include/*.h examples/*/*.c
examples:
ifeq (,$(wildcard dist/libmp.so))
@echo "!!!! you should first compile libmp !!!!"
exit 1
endif
$(MAKE) -C $@
.PHONY: install uninstall format examples