From f6598f546995b025349702b0572d0308e45e78a4 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 15 Feb 2013 00:11:23 +0100 Subject: Make install, uninstall, check work from subdirs By going up to the above level if needed and having the top-level define a special variable this works. --- dotfiles.mk | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'dotfiles.mk') diff --git a/dotfiles.mk b/dotfiles.mk index 77afcee..6018dd2 100644 --- a/dotfiles.mk +++ b/dotfiles.mk @@ -28,9 +28,19 @@ check-modules=$(addprefix check-,$(modules)) $(install-objects) $(uninstall-objects) $(check-objects) \ $(install-modules) $(uninstall-modules) $(check-modules) all: $(modules) $(objects) -install: $(install-modules) $(install-objects) + +ifeq ($(MAKEROOT),y) check: $(check-modules) $(check-objects) +install: $(install-modules) $(install-objects) uninstall: $(uninstall-modules) $(uninstall-objects) +else +check: + $(MAKE) -s -C ../ check +install: + $(MAKE) -C ../ install +uninstall: + $(MAKE) -C ../ uninstall +endif $(modules): %: @echo $(MAKEFILES) @@ -56,7 +66,7 @@ $(check-objects): check-%: echo -e "$(FG_YEL)$* $(FG_RED)older$(CLR_RE).")) $(check-modules): check-%: - @$(MAKE) -C $* check + @$(MAKE) -s -C $* check $(filter %.elc,$(objects)): %.elc: %.el $(call compile,$^) -- cgit v1.2.3-54-g00ecf From 978b30e663f735176d55370b7924370ae063fa56 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 15 Feb 2013 00:31:34 +0100 Subject: Customize output Don't show any output from make itself (almost), just show what we're actually doing, and use color. --- dotfiles.mk | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'dotfiles.mk') diff --git a/dotfiles.mk b/dotfiles.mk index 6018dd2..aaabad3 100644 --- a/dotfiles.mk +++ b/dotfiles.mk @@ -35,11 +35,11 @@ install: $(install-modules) $(install-objects) uninstall: $(uninstall-modules) $(uninstall-objects) else check: - $(MAKE) -s -C ../ check + @$(MAKE) -s -C ../ check install: - $(MAKE) -C ../ install + @$(MAKE) -s -C ../ install uninstall: - $(MAKE) -C ../ uninstall + @$(MAKE) -C ../ uninstall endif $(modules): %: @@ -47,23 +47,29 @@ $(modules): %: @$(MAKE) -C $* $(install-objects): install-%: % - $(if $(call newer,$*), \ - install -pDm $(MODE) "$*" "$(DESTDIR)/$*") + @$(if $(call newer,$*), \ + echo -e "$(FG_GRE)installing $(FG_YEL)$* $(CLR_RE)to $(DESTDIR) as $(MODE)"; \ + install -pDm $(MODE) "$*" "$(DESTDIR)/$*", \ + echo -e "$(FG_RED)not installing $(FG_YEL)$*$(CLR_RE)") $(install-modules): install-%: - @$(MAKE) -C $* install + @$(MAKE) -s -C $* install $(uninstall-objects): uninstall-%: - $(if $(call newer,$*),rm -f "$(DESTDIR)/$*") + @$(if $(call older,$*), \ + echo -e "$(FG_RED)not uninstalling $(FG_YEL)$*$(CLR_RE)", \ + echo -e "$(FG_GRE)uninstalling $(FG_YEL)$*$(CLR_RE)"; \ + rm -f "$(DESTDIR)/$*") $(uninstall-modules): uninstall-%: @$(MAKE) -C $* uninstall $(check-objects): check-%: @$(if $(call newer,$*), \ - echo -e "$(FG_YEL)$* $(FG_GRE)newer$(CLR_RE)!", \ + echo -e "$(FG_YEL)$* $(FG_GRE)newer$(CLR_RE) than $(DESTDIR)$*!", \ $(if $(call older,$*), \ - echo -e "$(FG_YEL)$* $(FG_RED)older$(CLR_RE).")) + echo -e "$(FG_YEL)$* $(FG_RED)older$(CLR_RE) than $(DESTDIR)$*.", \ + echo -e "$(FG_YEL)$* $(FG_BLU)up to date$(CLR_RE) with $(DESTDIR)$*.")) $(check-modules): check-%: @$(MAKE) -s -C $* check -- cgit v1.2.3-54-g00ecf From 55e386bf0c0b6a98ce295366bb4f31c00f048e16 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 15 Feb 2013 00:47:01 +0100 Subject: Add reverse target This target takes files whose installed versions are newer than those in the current working directory and copies them there. --- dotfiles.mk | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'dotfiles.mk') diff --git a/dotfiles.mk b/dotfiles.mk index aaabad3..92e35a1 100644 --- a/dotfiles.mk +++ b/dotfiles.mk @@ -16,28 +16,34 @@ define older = $(shell if [ "$(1)" -ot "$(DESTDIR)/$(1)" ]; then echo "older"; fi) endef +check-objects=$(addprefix check-,$(objects)) install-objects=$(addprefix install-,$(objects)) +reverse-objects=$(addprefix reverse-,$(objects)) uninstall-objects=$(addprefix uninstall-,$(objects)) -check-objects=$(addprefix check-,$(objects)) +check-modules=$(addprefix check-,$(modules)) install-modules=$(addprefix install-,$(modules)) +reverse-modules=$(addprefix reverse-,$(modules)) uninstall-modules=$(addprefix uninstall-,$(modules)) -check-modules=$(addprefix check-,$(modules)) .PHONY: all install uninstall check uninstall $(modules) \ $(install-objects) $(uninstall-objects) $(check-objects) \ - $(install-modules) $(uninstall-modules) $(check-modules) + $(install-modules) $(uninstall-modules) $(check-modules) \ + $(reverse) $(reverse-objects) $(reverse-modules) all: $(modules) $(objects) ifeq ($(MAKEROOT),y) check: $(check-modules) $(check-objects) install: $(install-modules) $(install-objects) +reverse: $(reverse-modules) $(reverse-objects) uninstall: $(uninstall-modules) $(uninstall-objects) else check: @$(MAKE) -s -C ../ check install: @$(MAKE) -s -C ../ install +reverse: + @$(MAKE) -s -C ../ reverse uninstall: @$(MAKE) -C ../ uninstall endif @@ -55,6 +61,15 @@ $(install-objects): install-%: % $(install-modules): install-%: @$(MAKE) -s -C $* install +$(reverse-objects): reverse-%: + @$(if $(call older,$*), \ + echo -e "$(FG_GRE)reversing $(FG_YEL)$(DESTDIR)/$* $(CLR_RE)"; \ + cp -a "$(DESTDIR)/$*" "$*", \ + echo -e "$(FG_RED)not reversing $(FG_YEL)$*$(CLR_RE)") + +$(reverse-modules): reverse-%: + @$(MAKE) -s -C $* reverse + $(uninstall-objects): uninstall-%: @$(if $(call older,$*), \ echo -e "$(FG_RED)not uninstalling $(FG_YEL)$*$(CLR_RE)", \ -- cgit v1.2.3-54-g00ecf From db63635d096c5696ce608b77d935364267ecf123 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 15 Feb 2013 01:05:06 +0100 Subject: Show subdirectories When checking, reversing, installing or uninstalling be sure to show the subdirectories. --- dotfiles.mk | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'dotfiles.mk') diff --git a/dotfiles.mk b/dotfiles.mk index 92e35a1..94db45e 100644 --- a/dotfiles.mk +++ b/dotfiles.mk @@ -45,21 +45,20 @@ install: reverse: @$(MAKE) -s -C ../ reverse uninstall: - @$(MAKE) -C ../ uninstall + @$(MAKE) -s -C ../ uninstall endif $(modules): %: - @echo $(MAKEFILES) - @$(MAKE) -C $* + $(MAKE) -C $* $(install-objects): install-%: % @$(if $(call newer,$*), \ - echo -e "$(FG_GRE)installing $(FG_YEL)$* $(CLR_RE)to $(DESTDIR) as $(MODE)"; \ + echo -e "$(FG_GRE)installing $(FG_YEL)$(MKDPREFIX)$* $(CLR_RE)to $(DESTDIR) as $(MODE)"; \ install -pDm $(MODE) "$*" "$(DESTDIR)/$*", \ - echo -e "$(FG_RED)not installing $(FG_YEL)$*$(CLR_RE)") + echo -e "$(FG_RED)not installing $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)") $(install-modules): install-%: - @$(MAKE) -s -C $* install + @$(MAKE) -s -C $* install MKDPREFIX=$(MKDPREFIX)$*/ $(reverse-objects): reverse-%: @$(if $(call older,$*), \ @@ -68,26 +67,26 @@ $(reverse-objects): reverse-%: echo -e "$(FG_RED)not reversing $(FG_YEL)$*$(CLR_RE)") $(reverse-modules): reverse-%: - @$(MAKE) -s -C $* reverse + @$(MAKE) -s -C $* reverse MKDPREFIX=$(MKDPREFIX)$*/ $(uninstall-objects): uninstall-%: @$(if $(call older,$*), \ - echo -e "$(FG_RED)not uninstalling $(FG_YEL)$*$(CLR_RE)", \ - echo -e "$(FG_GRE)uninstalling $(FG_YEL)$*$(CLR_RE)"; \ + echo -e "$(FG_RED)not uninstalling $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \ + echo -e "$(FG_GRE)uninstalling $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"; \ rm -f "$(DESTDIR)/$*") $(uninstall-modules): uninstall-%: - @$(MAKE) -C $* uninstall + @$(MAKE) -C $* uninstall MKDPREFIX=$(MKDPREFIX)$*/ $(check-objects): check-%: @$(if $(call newer,$*), \ - echo -e "$(FG_YEL)$* $(FG_GRE)newer$(CLR_RE) than $(DESTDIR)$*!", \ + echo -e "$(FG_YEL)$(MKDPREFIX)$* $(FG_GRE)newer$(CLR_RE) than $(DESTDIR)$*!", \ $(if $(call older,$*), \ - echo -e "$(FG_YEL)$* $(FG_RED)older$(CLR_RE) than $(DESTDIR)$*.", \ - echo -e "$(FG_YEL)$* $(FG_BLU)up to date$(CLR_RE) with $(DESTDIR)$*.")) + echo -e "$(FG_YEL)$(MKDPREFIX)$* $(FG_RED)older$(CLR_RE) than $(DESTDIR)$*.", \ + echo -e "$(FG_YEL)$(MKDPREFIX)$* $(FG_BLU)up to date$(CLR_RE) with $(DESTDIR)$*.")) $(check-modules): check-%: - @$(MAKE) -s -C $* check + @$(MAKE) -s -C $* check MKDPREFIX=$(MKDPREFIX)$*/ $(filter %.elc,$(objects)): %.elc: %.el $(call compile,$^) -- cgit v1.2.3-54-g00ecf From d7b662715d3b7fb6ee99d1c8ba66a2a36086391b Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 15 Feb 2013 01:10:51 +0100 Subject: Simplify log --- dotfiles.mk | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'dotfiles.mk') diff --git a/dotfiles.mk b/dotfiles.mk index 94db45e..0d1e70b 100644 --- a/dotfiles.mk +++ b/dotfiles.mk @@ -53,26 +53,26 @@ $(modules): %: $(install-objects): install-%: % @$(if $(call newer,$*), \ - echo -e "$(FG_GRE)installing $(FG_YEL)$(MKDPREFIX)$* $(CLR_RE)to $(DESTDIR) as $(MODE)"; \ + echo -e "$(FG_GRE)+ $(FG_YEL)$(MKDPREFIX)$* $(CLR_RE)to $(DESTDIR) as $(MODE)"; \ install -pDm $(MODE) "$*" "$(DESTDIR)/$*", \ - echo -e "$(FG_RED)not installing $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)") + echo -e "$(FG_RED)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)") $(install-modules): install-%: @$(MAKE) -s -C $* install MKDPREFIX=$(MKDPREFIX)$*/ $(reverse-objects): reverse-%: @$(if $(call older,$*), \ - echo -e "$(FG_GRE)reversing $(FG_YEL)$(DESTDIR)/$* $(CLR_RE)"; \ + echo -e "$(FG_GRE)+ $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"; \ cp -a "$(DESTDIR)/$*" "$*", \ - echo -e "$(FG_RED)not reversing $(FG_YEL)$*$(CLR_RE)") + echo -e "$(FG_RED)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)") $(reverse-modules): reverse-%: @$(MAKE) -s -C $* reverse MKDPREFIX=$(MKDPREFIX)$*/ $(uninstall-objects): uninstall-%: @$(if $(call older,$*), \ - echo -e "$(FG_RED)not uninstalling $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \ - echo -e "$(FG_GRE)uninstalling $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"; \ + echo -e "$(FG_RED)+ $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \ + echo -e "$(FG_GRE)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)"; \ rm -f "$(DESTDIR)/$*") $(uninstall-modules): uninstall-%: @@ -80,10 +80,10 @@ $(uninstall-modules): uninstall-%: $(check-objects): check-%: @$(if $(call newer,$*), \ - echo -e "$(FG_YEL)$(MKDPREFIX)$* $(FG_GRE)newer$(CLR_RE) than $(DESTDIR)$*!", \ + echo -e "$(FG_GRE)+ $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \ $(if $(call older,$*), \ - echo -e "$(FG_YEL)$(MKDPREFIX)$* $(FG_RED)older$(CLR_RE) than $(DESTDIR)$*.", \ - echo -e "$(FG_YEL)$(MKDPREFIX)$* $(FG_BLU)up to date$(CLR_RE) with $(DESTDIR)$*.")) + echo -e "$(FG_RED)- $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)", \ + echo -e "$(FG_BLU)= $(FG_YEL)$(MKDPREFIX)$*$(CLR_RE)")) $(check-modules): check-%: @$(MAKE) -s -C $* check MKDPREFIX=$(MKDPREFIX)$*/ -- cgit v1.2.3-54-g00ecf