summaryrefslogtreecommitdiff
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
parent8cbd5fc2e616785d97e84f7e17b845b74a6ccfd1 (diff)
Generalize the patching mechanism in the build system.
-rw-r--r--common.mk28
-rw-r--r--src/chroot-tools/.gitignore3
-rw-r--r--src/chroot-tools/Makefile24
-rw-r--r--src/devtools/.gitignore1
4 files changed, 27 insertions, 29 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 ########################################################################
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