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:
2024-07-11 10:49:57 +00:00
install -m755 dist/libmp.so $(DESTDIR)/$(PREFIX)/lib/libmp.so
mkdir -pv $(DESTDIR)/$(PREFIX)/include/libmp
2024-06-20 00:34:32 +00:00
cp $(HDRS) $(DESTDIR)/usr/include/libmp
@for po in $(PO_DIRS) ; do \
echo "installing locale: $$po/libmp.mo" ; \
2024-07-11 10:49:57 +00:00
mkdir -pv $(DESTDIR)/$(PREFIX)/share/$$po ; \
cp $$po/libmp.mo $(DESTDIR)/$(PREFIX)/share/$$po ; \
2024-06-20 00:34:32 +00:00
done
uninstall:
2024-07-11 10:49:57 +00:00
rm $(DESTDIR)/$(PREFIX)/lib/libmp.so
rm -r $(DESTDIR)/$(PREFIX)/include/libmp
2024-06-20 00:34:32 +00:00
format:
2024-07-11 10:49:57 +00:00
clang-format -i -style=file src/*.c include/*.h examples/*/*.c
2024-06-20 00:34:32 +00:00
examples:
ifeq (,$(wildcard dist/libmp.so))
@echo "!!!! you should first compile libmp !!!!"
exit 1
endif
$(MAKE) -C $@
2024-07-11 10:49:57 +00:00
.PHONY: install uninstall format examples