HEADERS = $(wildcard src/*.h) $(wildcard src/*/*.h) CSRCS = $(wildcard src/*.c) $(wildcard src/*/*.c) CMDS = mc-pull mc-gen PO_SRCS = $(wildcard locale/*/*/*.po) PO_OUTS = $(patsubst locale/%.po,locale/%.mo,$(PO_SRCS)) PO_DIRS = $(wildcard locale/*/*) VERSION = 24.01 prefix = /usr CC = gcc all: dist/mc $(PO_OUTS) dist/mc: $(CSRCS) $(HEADERS) mkdir -p dist $(CC) $(CFLAGS) $(CSRCS) -o $@ -DVERSION=\"${VERSION}\" -linih -lgit2 -lcrypto locale/%.mo: locale/%.po msgfmt $^ -o $@ locale/%.po: locale/mc.pot cp $@ $@.old if msgmerge $@ $^ -o $@ ; then \ rm $@.old ; \ echo "merge success: $@" ; \ else \ echo "merge failed: $@" ; \ mv $@.old $@ ; \ fi; \ locale/mc.pot: $(CSRCS) mkdir -p locale xgettext -k_ -c $^ -o $@ install: mkdir -pv $(DESTDIR)$(prefix)/bin install -v -m755 dist/mc $(DESTDIR)$(prefix)/bin/mc @for cmd in $(CMDS) ; do \ ln -sfv mc $(DESTDIR)$(prefix)/bin/$$cmd ; \ done @for po in $(PO_DIRS) ; do \ echo "installing locale: $$po/mc.mo" ; \ mkdir -pv $(DESTDIR)/usr/share/$$po ; \ cp $$po/mc.mo $(DESTDIR)/usr/share/$$po ; \ done uninstall: rm -v $(DESTDIR)$(prefix)/bin/mc @for cmd in $(CMDS) ; do \ unlink $(DESTDIR)$(prefix)/bin/$$cmd ; \ done clean: rm dist/mc rm locale/mc.pot @for po in $(PO_DIRS) ; do \ rm $$po/mc.mo ; \ done format: clang-format -i -style=file $(HEADERS) $(CSRCS) .PHONY: install defcfg uninstall clean