diff options
Diffstat (limited to 'common.mk')
-rw-r--r-- | common.mk | 31 |
1 files changed, 27 insertions, 4 deletions
@@ -10,6 +10,14 @@ 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 make-backup-files nil)' \ + --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 +61,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 +87,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 +$(sort $(_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) <"$<" >"$@" || { rm -f -- '$@'; false; } - @chmod 755 "$@" || { rm -f -- '$@'; false; } + @echo 'EDIT < $< > $@'; $(edit) <"$<" >"$@" + $(if $(filter-out %.sh,$@),chmod 755 "$@") # Build ######################################################################## @@ -146,3 +167,5 @@ clean-hook: PHONY FORCE: PHONY PHONY: .PHONY: FORCE PHONY + +.DELETE_ON_ERROR: |