libmp/Makefile

74 lines
1.7 KiB
Makefile
Raw Normal View History

2024-06-20 00:34:32 +00:00
PREFIX = /usr
CC = gcc
PO_SRCS = $(wildcard locale/*/*/*.po)
PO_OUTS = $(patsubst locale/%.po,locale/%.mo,$(PO_SRCS))
PO_DIRS = $(wildcard locale/*/*)
2024-07-06 00:48:23 +00:00
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
2024-07-11 04:52:00 +00:00
LIBS = -lpthread -lcrypto -larchive -linih -lgpgme -lsqlite3
2024-06-20 00:34:32 +00:00
DEBUG = 0
2024-06-20 00:34:32 +00:00
VERSION = 24.00
2024-07-06 00:48:23 +00:00
all: dist dist/libmp.so $(PO_OUTS)
2024-06-20 00:34:32 +00:00
2024-07-06 00:48:23 +00:00
dist:
mkdir -p dist/ctx
mkdir -p dist/mptp
mkdir -p dist/pool
mkdir -p dist/package
2024-07-02 01:44:07 +00:00
mkdir -p dist/database
2024-07-06 00:48:23 +00:00
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}
2024-06-20 00:34:32 +00:00
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