From 089c60a05e95bee1ab3c506069f8e0e75eb43657 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 20 Mar 2014 16:27:41 -0400 Subject: Generalize the patching mechanism in the build system. --- common.mk | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'common.mk') diff --git a/common.mk b/common.mk index deb64c7..ea0c588 100644 --- a/common.mk +++ b/common.mk @@ -10,6 +10,13 @@ pkglibexecdir ?= $(libexecdir)/libretools # This is used when using sources grabbed from devtools edit = sed -e 's|m4_include(lib/\(.*\))|. $$(librelib \1)|' +# Usage: $(call indent,FILENAME) +# Command to auto-indent a file. +indent = emacs --batch $1 \ + --eval '(setq sh-basic-offset 8)' \ + --eval '(indent-region (point-min) (point-max) nil)' \ + -f save-buffer &>/dev/null + # Usage OUTPUT # Normalize a .po(t) file pofmt = msguniq -Fi @@ -53,7 +60,7 @@ install_files += $(addprefix $(DESTDIR)$(bindir)/,$(progs)) \ $(addprefix $(DESTDIR)$(mandir)/man6/,$(filter %.6,$(mans))) \ $(addprefix $(DESTDIR)$(mandir)/man7/,$(filter %.7,$(mans))) \ $(addprefix $(DESTDIR)$(mandir)/man8/,$(filter %.8,$(mans))) -clean_files += $(patsubst %.in,%,$(copy_files)) $(copy_files) $(mans) $(wildcard *.pot) +clean_files += $(patsubst %.in,%,$(copy_files)) $(copy_files) $(mans) $(wildcard *.pot *.ugly* *~) pots += $(filter-out $(no-pots) ,$(progs)) pot_files += $(addsuffix .pot,$(pots)) @@ -79,10 +86,23 @@ build: PHONY $(build_files) ronn --roff $(RONNFLAGS) < '$<' > '$@' %.html: %.ronn ronn --html $(RONNFLAGS) < '$<' > '$@' + + +# If we have a .patch file, the flow is: +# $(devtoolsdir)/%.in -> %.in + %.patch -> %.ugly -> % +_do_patch = $(filter $(patsubst %.patch,%,$(wildcard *.patch)),$(patsubst %.in,%,$(copy_files))) +%.ugly: %.in %.patch Makefile + cp $*.in $@ + @echo 'PATCH $@ $*.patch'; patch $@ $*.patch +$(_do_patch): %: %.ugly Makefile + @echo 'EDIT < $< > $@'; $(edit) <'$<' >'$@' + @echo 'INDENT $@'; $(call indent,$@) + $(if $(filter-out %.sh,$@),chmod 755 "$@") +# Otherwise, the flow is just +# $(devtoolsdir)/%.in -> %.in -> % %: %.in - @echo "GEN $@" - @$(edit) <"$<" >"$@" - @chmod 755 "$@" + @echo 'EDIT < $< > $@'; $(edit) <"$<" >"$@" + $(if $(filter-out %.sh,$@),chmod 755 "$@") # Build ######################################################################## -- cgit v1.2.2