summaryrefslogtreecommitdiff
path: root/common.mk
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-03-20 16:27:41 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-03-20 16:27:41 -0400
commit089c60a05e95bee1ab3c506069f8e0e75eb43657 (patch)
tree186245d8ac5dc1ea64ebb37b8e77a045953cc391 /common.mk
parent8cbd5fc2e616785d97e84f7e17b845b74a6ccfd1 (diff)
Generalize the patching mechanism in the build system.
Diffstat (limited to 'common.mk')
-rw-r--r--common.mk28
1 files changed, 24 insertions, 4 deletions
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 <INPUT $(pofmt) >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 ########################################################################