blind

suckless command-line video editing utility
git clone git://git.suckless.org/blind
Log | Files | Refs | README | LICENSE

commit d0c94265c042fe419926ee3e42fe4821c5e464cb
parent 6cde3f62419e656ae874a2d2b43c0a91da8a43e8
Author: Mattias Andrée <maandree@kth.se>
Date:   Sat, 15 Jul 2017 21:56:07 +0200

Add multi-call binary installation

Signed-off-by: Mattias Andrée <maandree@kth.se>

Diffstat:
MMakefile | 44+++++++++++++++++++++++++++++++++++++++++++-
Mconfig.mk | 3+++
2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile @@ -151,6 +151,7 @@ MAN7 = blind.7 all: $(BIN) +mcb: blind-mcb %: %.o $(COMMON_OBJ) $(CC) -o $@ $^ $(LDFLAGS) @@ -158,6 +159,26 @@ all: $(BIN) %.o: src/%.c src/*.h src/*/*.h platform.h $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< +%.mcb.o: src/%.c src/*.h src/*/*.h platform.h + $(CC) $(CFLAGS) $(CPPFLAGS) -Dmain="$$(printf 'main_%s\n' $* | tr -- - _)" -c -o $@ $< + +blind-mcb.c: Makefile + printf '#include <%s.h>\n' stdio string > blind-mcb.c + printf 'int main_%s(int argc, char *argv[]);\n' $(BIN) | tr -- - _ >> blind-mcb.c + printf 'int main(int argc, char *argv[]) {\n' >> blind-mcb.c + printf 'char *cmd = strrchr(*argv, '"'/'"');\n' >> blind-mcb.c + printf 'cmd = cmd ? cmd + 1 : *argv;\n' >> blind-mcb.c + for c in $(BIN); do \ + printf 'if (!strcmp(cmd, "%s"))\n\treturn main_%s(argc, argv);\n' "$$c" "$$c" | \ + sed '/^\t/s/-/_/g'; \ + done >> blind-mcb.c + printf 'fprintf(stderr, "Invalid command: %%s\\n", cmd);\n' >> blind-mcb.c + printf 'return 1;\n' >> blind-mcb.c + printf '}\n' >> blind-mcb.c + +blind-mcb: blind-mcb.o $(BIN:=.mcb.o) $(COMMON_OBJ) + $(CC) -o $@ $^ $(LDFLAGS) + generate-macros: src/generate-macros.c $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $< $(LDFLAGS) @@ -181,6 +202,26 @@ install: all done cd -- "$(DESTDIR)$(MANPREFIX)/man7" && chmod 644 $(MAN7) +install-mcb: mcb + mkdir -p -- "$(DESTDIR)$(PREFIX)/bin" + for c in $(BIN); do \ + $(LN) -f -- blind-single-colour "$(DESTDIR)$(PREFIX)/bin/$$c"; done + rm -f -- "$(DESTDIR)$(PREFIX)/bin/blind-single-colour" + cp -f -- blind-mcb "$(DESTDIR)$(PREFIX)/bin/blind-single-colour" + chmod 755 -- "$(DESTDIR)$(PREFIX)/bin/blind-single-colour" + mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1" + set -e && for m in $(MAN1); do \ + sed '1s/ blind$$/ " blind $(VERSION)"/g' \ + < "man/$$m" > "$(DESTDIR)$(MANPREFIX)/man1/$$m"; \ + done + cd -- "$(DESTDIR)$(MANPREFIX)/man1" && chmod 644 $(MAN1) + mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man7" + set -e && for m in $(MAN7); do \ + sed '1s/ blind$$/ " blind $(VERSION)"/g' \ + < "man/$$m" > "$(DESTDIR)$(MANPREFIX)/man7/$$m"; \ + done + cd -- "$(DESTDIR)$(MANPREFIX)/man7" && chmod 644 $(MAN7) + uninstall: cd -- "$(DESTDIR)$(PREFIX)/bin" && rm -f $(BIN) cd -- "$(DESTDIR)$(MANPREFIX)/man1" && rm -f $(MAN1) @@ -203,8 +244,9 @@ dist: clean: -rm -f $(BIN) *.o blind-$(VERSION).tar.gz platform.h generate-macros + -rm -f blind-mcb.c blind-mcb.o blind-mcb -rm -rf "blind-$(VERSION)" -.PHONY: all install uninstall dist clean +.PHONY: all mcb install install-mcb uninstall dist clean .PRECIOUS: $(COMMON_OBJ) platform.h diff --git a/config.mk b/config.mk @@ -5,6 +5,9 @@ VERSION = 1.1 PREFIX = /usr/local MANPREFIX = $(PREFIX)/share/man +# Commands +LN = ln -s + # You may want to remove -DHAVE_PRCTL, -DHAVE_EPOLL, and # -DHAVE_SENDFILE from CPPFLAGS if you are not using Linux. CFLAGS = -std=c11 -Wall -pedantic -O2