From 804e5e1093c3aa8258bf9f8c97ff661cdf8407f1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 2 Feb 2014 20:22:24 -0500 Subject: Makefiles: use .DELETE_ON_ERROR: --- common.mk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'common.mk') diff --git a/common.mk b/common.mk index ea89de1..deb64c7 100644 --- a/common.mk +++ b/common.mk @@ -81,8 +81,8 @@ build: PHONY $(build_files) ronn --html $(RONNFLAGS) < '$<' > '$@' %: %.in @echo "GEN $@" - @$(edit) <"$<" >"$@" || { rm -f -- '$@'; false; } - @chmod 755 "$@" || { rm -f -- '$@'; false; } + @$(edit) <"$<" >"$@" + @chmod 755 "$@" # Build ######################################################################## @@ -146,3 +146,5 @@ clean-hook: PHONY FORCE: PHONY PHONY: .PHONY: FORCE PHONY + +.DELETE_ON_ERROR: -- cgit v1.2.3-54-g00ecf 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 ++++++++++++++++++++++++---- src/chroot-tools/.gitignore | 3 +-- src/chroot-tools/Makefile | 24 +----------------------- src/devtools/.gitignore | 1 + 4 files changed, 27 insertions(+), 29 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 ######################################################################## diff --git a/src/chroot-tools/.gitignore b/src/chroot-tools/.gitignore index 80e1000..3f46ed2 100644 --- a/src/chroot-tools/.gitignore +++ b/src/chroot-tools/.gitignore @@ -1,5 +1,4 @@ makechrootpkg.sh* -!makechrootpkg.sh.patch - arch-nspawn* mkarchroot* +!*.patch diff --git a/src/chroot-tools/Makefile b/src/chroot-tools/Makefile index 97ca688..c49c4ac 100644 --- a/src/chroot-tools/Makefile +++ b/src/chroot-tools/Makefile @@ -9,37 +9,15 @@ libs = makechrootpkg.sh $(wildcard hooks-*.sh) pots = $(libexecs) $(libs) pkglibexecdir = $(libexecdir)/libretools/chroot -clean_files = makechrootpkg.sh.ugly* *~ include ../../common.mk -# 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 - -# makechrootpkg.sh is special, we patch it and do fancy stuff -# The flow is: -# $(devtoolsdir)/*.in -> *.sh.in + *.sh.patch -> *.sh.ugly -> *.sh - +# makechrootpkg.sh is created from a command, not a library makechrootpkg.sh.in: %.sh.in: $(devtoolsdir)/%.in cp $< $@ -makechrootpkg.sh.ugly: %.ugly: %.in %.patch Makefile - cp $*.in $@ - @echo 'PATCH $@ $*.patch'; patch $@ $*.patch -makechrootpkg.sh: %: %.ugly Makefile - @echo 'EDIT < $< > $@'; $(edit) <'$<' >'$@' - @echo 'INDENT $@'; $(call indent,$@) mkarchroot: mkarchroot.in Makefile @echo '< $< M4_EDIT | SED > $@' @<'$<' $(edit) | sed -e 's|arch-nspawn|$$(librelib chroot/&)|' -e 's/pacstrap/env -i &/' >'$@' @echo 'CHMOD $<'; chmod 755 "$@" -archroot: %: %.in Makefile - @echo "GEN $@" - @$(edit) <"$<" >"$@" - @chmod 755 "$@" - distcc-tool.pot: xgettext-keywords-sh+=--keyword=errusage diff --git a/src/devtools/.gitignore b/src/devtools/.gitignore index 097fcde..d669bbd 100644 --- a/src/devtools/.gitignore +++ b/src/devtools/.gitignore @@ -1,3 +1,4 @@ * !Makefile !.gitignore +!*.patch -- cgit v1.2.3-54-g00ecf From 69bdd4ea9459209fe1a7768344b1975bea0a0fd0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 21 Mar 2014 14:39:39 -0400 Subject: Fix a small bug in common.mk --- common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common.mk') diff --git a/common.mk b/common.mk index ea0c588..ec8135f 100644 --- a/common.mk +++ b/common.mk @@ -94,7 +94,7 @@ _do_patch = $(filter $(patsubst %.patch,%,$(wildcard *.patch)),$(patsubst %.in,% %.ugly: %.in %.patch Makefile cp $*.in $@ @echo 'PATCH $@ $*.patch'; patch $@ $*.patch -$(_do_patch): %: %.ugly Makefile +$(sort $(_do_patch)): %: %.ugly Makefile @echo 'EDIT < $< > $@'; $(edit) <'$<' >'$@' @echo 'INDENT $@'; $(call indent,$@) $(if $(filter-out %.sh,$@),chmod 755 "$@") -- cgit v1.2.3-54-g00ecf From aaae256525d07aff8d83d4b8ec6332bfd2bb21eb Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 22 Mar 2014 18:35:00 -0400 Subject: Makefiles: inhibit emacs from creating *~ files when formatting a file --- common.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'common.mk') diff --git a/common.mk b/common.mk index ec8135f..58366d7 100644 --- a/common.mk +++ b/common.mk @@ -13,6 +13,7 @@ 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 @@ -60,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 *.ugly* *~) +clean_files += $(patsubst %.in,%,$(copy_files)) $(copy_files) $(mans) $(wildcard *.pot *.ugly*) pots += $(filter-out $(no-pots) ,$(progs)) pot_files += $(addsuffix .pot,$(pots)) -- cgit v1.2.3-54-g00ecf