summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-07-01 23:22:00 -0600
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-07-01 23:22:00 -0600
commit504d11ded8c1e9a0757332f2a10ed7d86dd5fc70 (patch)
treea3bba73ac491feaaecddca3345d8a54c5673bf72
parent04b12bbea2be03a988e773afcd014a74d37ddca5 (diff)
A whole bunch of stuff
-rw-r--r--.gitignore1
-rw-r--r--Makefile15
-rw-r--r--common.bottom.mk116
-rw-r--r--common.each.mk18
-rw-r--r--common.once.mk7
-rw-r--r--common.top.mk22
-rw-r--r--modules/.gitignore5
-rw-r--r--modules/Makefile24
l---------modules/comments/Makefile1
-rw-r--r--modules/comments/Makefile.inc.mk2
-rw-r--r--modules/comments/Module.mk (renamed from plugins/comments/dep)0
-rw-r--r--modules/comments/comment.sh (renamed from plugins/comments/bin/comment.sh)0
-rw-r--r--modules/comments/commit.sh (renamed from plugins/comments/bin/commit.sh)0
-rw-r--r--modules/comments/print.sh (renamed from plugins/comments/bin/print.sh)0
-rw-r--r--modules/comments/showcomment.sh (renamed from plugins/comments/bin/showcomment.sh)0
l---------modules/date.author/Makefile1
-rw-r--r--modules/date.author/Makefile.inc.mk2
-rw-r--r--modules/date.author/Module.mk (renamed from plugins/date.author/dep)0
-rw-r--r--modules/date.author/commit.sh (renamed from plugins/date.author/bin/commit.sh)0
l---------modules/files/Makefile1
-rw-r--r--modules/files/Makefile.inc.mk8
-rw-r--r--modules/files/Module.mk (renamed from plugins/files/dep)0
-rw-r--r--modules/files/_stdio.sh (renamed from plugins/files/lib/stdio.sh)0
-rw-r--r--modules/files/blob-gethash.sh (renamed from plugins/files/bin/blob-gethash.sh)0
-rw-r--r--modules/files/blob-gettype.sh (renamed from plugins/files/bin/blob-gettype.sh)0
-rw-r--r--modules/files/commit.d.sh (renamed from plugins/files/bin/commit.d.sh)0
-rw-r--r--modules/files/commit.f.sh (renamed from plugins/files/bin/commit.f.sh)0
-rw-r--r--modules/files/commit.sh (renamed from plugins/files/bin/commit.sh)0
-rw-r--r--modules/files/file-gettype.sh (renamed from plugins/files/bin/file-gettype.sh)0
-rw-r--r--modules/files/get.d.sh (renamed from plugins/files/bin/get.d.sh)0
-rw-r--r--modules/files/get.f.sh (renamed from plugins/files/bin/get.f.sh)0
-rw-r--r--modules/files/get.sh (renamed from plugins/files/bin/get.sh)0
-rw-r--r--modules/files/ls.sh (renamed from plugins/files/bin/ls.sh)0
-rw-r--r--modules/files/print.sh (renamed from plugins/files/bin/print.sh)0
-rw-r--r--modules/files/tree.sh (renamed from plugins/files/bin/tree.sh)0
-rw-r--r--modules/module.mk35
l---------modules/tags/Makefile1
-rw-r--r--modules/tags/Makefile.inc.mk2
-rw-r--r--modules/tags/Module.mk (renamed from plugins/tags/dep)0
-rw-r--r--modules/tags/commit.sh (renamed from plugins/tags/bin/commit.sh)0
-rw-r--r--modules/tags/get-tag.sh (renamed from plugins/tags/bin/get-tag.sh)0
-rw-r--r--modules/tags/print.sh (renamed from plugins/tags/bin/print.sh)0
-rw-r--r--modules/tags/tag-id.sh (renamed from plugins/tags/bin/tag-id.sh)0
-rw-r--r--modules/tags/tag.sh (renamed from plugins/tags/bin/tag.sh)0
l---------modules/tree/Makefile1
-rw-r--r--modules/tree/Makefile.inc.mk2
-rw-r--r--modules/tree/Module.mk (renamed from plugins/tree/dep)0
-rw-r--r--modules/tree/addparent.d.sh (renamed from plugins/tree/bin/addparent.d.sh)0
-rw-r--r--modules/tree/addparent.f.sh (renamed from plugins/tree/bin/addparent.f.sh)0
-rw-r--r--modules/tree/addparent.sh (renamed from plugins/tree/bin/addparent.sh)0
-rw-r--r--modules/tree/commit.sh (renamed from plugins/tree/bin/commit.sh)0
-rw-r--r--modules/tree/delparent.f.sh (renamed from plugins/tree/bin/delparent.f.sh)0
-rw-r--r--modules/tree/getchildren.sh (renamed from plugins/tree/bin/getchildren.sh)0
-rw-r--r--modules/tree/getparents.sh (renamed from plugins/tree/bin/getparents.sh)0
-rw-r--r--modules/tree/print.sh (renamed from plugins/tree/bin/print.sh)0
-rw-r--r--plugins/comments/info.mk.in3
-rw-r--r--plugins/date.author/info.mk.in3
-rw-r--r--plugins/files/etc/3-d.sh3
-rw-r--r--plugins/files/etc/5-f.sh3
-rw-r--r--plugins/files/info.mk.in3
-rw-r--r--plugins/main.mk.in56
-rw-r--r--plugins/plugin.mk.in90
-rw-r--r--plugins/tags/info.mk.in3
-rw-r--r--plugins/tree/info.mk.in3
-rw-r--r--wrapper/.gitignore3
-rw-r--r--wrapper/Makefile17
-rw-r--r--wrapper/inner.sh.m4 (renamed from wrapper/inner.sh)65
-rw-r--r--wrapper/runcmd.mk15
68 files changed, 253 insertions, 278 deletions
diff --git a/.gitignore b/.gitignore
index 3fab36d..c455e80 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
.*.mk
/*.tar.*
/*-[0-9]*/
+tmp.*
diff --git a/Makefile b/Makefile
index 57993c8..479eb88 100644
--- a/Makefile
+++ b/Makefile
@@ -17,18 +17,19 @@
include $(dir $(lastword $(MAKEFILE_LIST)))/config.mk
include $(topsrcdir)/common.top.mk
-#subdirs = wrapper plugins
-subdirs = wrapper
+subdirs = wrapper modules
src_files = Makefile
-src_files += common.top.mk common.bottom.mk config.mk configure
+src_files += common.top.mk common.bottom.mk
+src_files += common.each.mk common.once.mk
+src_files += config.mk configure
src_files += COPYING HACKING README
-obj_files = config.sh config.h
+out_files = config.sh config.h
-config_vars = $(shell $(SED) -n 's/^\s*\([a-z][^ !?:=]*\).*=.*/\1/p' $(topobjdir)/config.mk) PACKAGE VERSION DESTDIR
-$(objdir)/config.sh: $(objdir)/config.mk
+config_vars = $(shell $(SED) -n 's/^\s*\([a-z][^ !?:=]*\).*=.*/\1/p' $(topoutdir)/config.mk) PACKAGE VERSION DESTDIR
+$(outdir)/config.sh: $(outdir)/config.mk
$(PRINTF) '%s=%s\n' $(foreach v,$(config_vars),$v $($v)) | LC_ALL=C $(SORT) > $@
-$(objdir)/config.h: $(objdir)/config.sh
+$(outdir)/config.h: $(outdir)/config.sh
. $(abspath $<) && $(PRINTF) '#define %s "%s"\n' $(foreach v,$(config_vars),$v '$($v)') PACKAGE_UPPER $${PACKAGE^^} | LC_ALL=C $(SORT) > $@
include $(topsrcdir)/common.bottom.mk
diff --git a/common.bottom.mk b/common.bottom.mk
index 2d56297..4a5833c 100644
--- a/common.bottom.mk
+++ b/common.bottom.mk
@@ -19,98 +19,116 @@ include $(topsrcdir)/common.each.mk
# Aggregate variables
# Add some more defaults to the *_files variables
-clean_files += $(obj_files)
-conf_files += Makefile $(topobjdir)/config.mk
+clean_files += $(out_files)
+conf_files += Makefile $(topoutdir)/config.mk
# Now namespace the *_files variables
-$(module)_src_files := $(addprefix $(srcdir)/,$(src_files))
-$(module)_obj_files := $(addprefix $(objdir)/,$(obj_files))
-$(module)_sys_files := $(addprefix $(DESTDIR)/,$(sys_files))
-$(module)_clean_files := $(addprefix $(objdir)/,$(clean_files))
-$(module)_slow_files := $(addprefix $(objdir)/,$(slow_files))
-$(module)_conf_files := $(addprefix $(objdir)/,$(conf_files))
-$(module)_dist_files := $(addprefix $(srcdir)/,$(dist_files))
+define _am_add_to_module
+_am_$(module)_src_files = $(addprefix $(srcdir)/,$(src_files))
+_am_$(module)_out_files = $(addprefix $(outdir)/,$(out_files))
+_am_$(module)_sys_files = $(addprefix $(DESTDIR),$(sys_files))
+_am_$(module)_clean_files = $(addprefix $(outdir)/,$(clean_files))
+_am_$(module)_slow_files = $(addprefix $(outdir)/,$(slow_files))
+_am_$(module)_conf_files = $(addprefix $(outdir)/,$(conf_files))
+_am_$(module)_dist_files = $(addprefix $(srcdir)/,$(dist_files))
+endef
+$(eval $(_am_add_to_module))
# And add them to the $(parent)_*_files variables (if applicable)
+define _am_add_to_parent
+_am_%(parent)_src_files += $(_am_%(module)_src_files)
+_am_%(parent)_out_files += $(_am_%(module)_out_files)
+_am_%(parent)_sys_files += $(_am_%(module)_sys_files)
+_am_%(parent)_clean_files += $(_am_%(module)_clean_files)
+_am_%(parent)_slow_files += $(_am_%(module)_slow_files)
+_am_%(parent)_conf_files += $(_am_%(module)_conf_files)
+_am_%(parent)_dist_files += $(_am_%(module)_dist_files)
+endef
ifneq ($(parent),)
-$(parent)_src_files := $($(parent)_src_files) $($(module)_src_files)
-$(parent)_obj_files := $($(parent)_obj_files) $($(module)_obj_files)
-$(parent)_sys_files := $($(parent)_sys_files) $($(module)_sys_files)
-$(parent)_clean_files := $($(parent)_clean_files) $($(module)_clean_files)
-$(parent)_slow_files := $($(parent)_slow_files) $($(module)_slow_files)
-$(parent)_conf_files := $($(parent)_conf_files) $($(module)_conf_files)
-$(parent)_dist_files := $($(parent)_dist_files) $($(module)_dist_files)
+$(eval $(subst %(parent),$(parent),$(subst %(module),$(module),$(value _am_add_to_parent))))
endif
modules := $(modules) $(module)
+# Do some per-module magic
+
+_am_phony = build install uninstall mostlyclean clean distclean maintainer-clean check
+
+.PHONY: $(addsuffix -%(module),$(_am_phony))
+
+$(addsuffix -$(module),uninstall mostlyclean clean distclean maintainer-clean) ::
+ $(RM) -- $(sort $(_am_$@))
+ $(RMDIRS) $(sort $(dir $(_am_$@))) 2>/dev/null || $(TRUE)
+
+
# Include Makefiles from other directories
-define _nl
+define _am_nl
endef
-define _include_makefile
+define _am_include_makefile
ifeq ($(filter $(abspath $1),$(included_makefiles)),)
-include $(if $(call _is_subdir,.,$1),$(call _relto,.,$1),$(topobjdir)/$(call _relto,$(topobjdir),$1))
+include $(if $(call _am_is_subdir,.,$1),$(call _am_relto,.,$1),$(topoutdir)/$(call _am_relto,$(topoutdir),$1))
endif
endef
$(eval \
- _COMMON_MK_NOONCE = n$(_nl)\
- $(foreach dir,$(subdirs),parent=$(module)$(_nl)$(call _include_makefile,$(objdir)/$(dir)/Makefile)$(_nl))\
- parent=dep$(_nl)\
- $(call _include_makefile,$(topobjdir)/$(dir)/Makefile)$(_nl)\
- _COMMON_MK_NOONCE = $(_COMMON_MK_NOONCE))
+ _am_NO_ONCE = y$(_am_nl)\
+ $(foreach dir,$(subdirs),parent=$(module)$(_am_nl)$(call _am_include_makefile,$(outdir)/$(dir)/Makefile)$(_am_nl))\
+ parent=dep$(_am_nl)\
+ $(call _am_include_makefile,$(topoutdir)/$(dir)/Makefile)$(_am_nl)\
+ _am_NO_ONCE = $(_am_NO_ONCE))
# This only gets evaluated once, after all of the other Makefiles are read
-ifeq ($(_COMMON_MK_NOONCE),)
+ifeq ($(_am_NO_ONCE),)
# Empty module-level variables
-objdir = /bogus
+outdir = /bogus
srcdir = /bogus
subdirs =
depdirs =
src_files =
-obj_files =
+out_files =
sys_files =
clean_files =
slow_files =
conf_files =
dist_files =
-# Declare phony targets
-.phony = build install uninstall mostlyclean clean distclean maintainer-clean check
-define module_rules
-.PHONY: $(addsuffix -%(module),$(.phony))
+ifeq ($(abspath .),$(abspath $(topoutdir)))
+_am_all_clean_files += $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz
+$(addsuffix -all,mostlyclean clean distclean maintainer-clean) ::
+ $(RM) -r -- $(topoutdir)/$(PACKAGE)-$(VERSION)
+endif
+
+define _am_module_rules
# Constructive phony targets
-build-%(module): $(%(module)_obj_files)
-install-%(module): $(%(module)_sys_files)
+build-%(module): $(_am_%(module)_out_files)
+install-%(module): $(_am_%(module)_sys_files)
# Destructive phony targets
-_%(module)_uninstall = $(%(module)_sys_files))
-_%(module)_mostlyclean = $(filter-out $(%(module)_slow_files) $(%(module)_conf_files) $(%(module)_dist_files),$(%(module)_clean_files))
-_%(module)_clean = $(filter-out $(%(module)_conf_files) $(%(module)_dist_files),$(%(module)_clean_files))
-_%(module)_distclean = $(filter-out $(%(module)_dist_files),$(%(module)_clean_files))
-_%(module)_maintainer-clean = $(%(module)_clean_files)
-uninstall-%(module) mostlyclean-%(module) clean-%(module) distclean-%(module) maintainer-clean-%(module): %-%(module):
- $(RM) -- $(sort $(_%(module)_$*))
- $(RMDIRS) $(sort $(dir $(_%(module)_$*))) 2>/dev/null || $(TRUE)
+_am_uninstall-%(module) = $(_am_%(module)_sys_files))
+_am_mostlyclean-%(module) = $(filter-out $(_am_%(module)_slow_files) $(_am_%(module)_conf_files) $(_am_%(module)_dist_files),$(_am_%(module)_clean_files))
+_am_clean-%(module) = $(filter-out $(_am_%(module)_conf_files) $(_am_%(module)_dist_files),$(_am_%(module)_clean_files))
+_am_distclean-%(module) = $(filter-out $(_am_%(module)_dist_files),$(_am_%(module)_clean_files))
+_am_maintainer-clean-%(module) = $(_am_%(module)_clean_files)
endef
-$(foreach module,$(modules),$(eval $(subst %(module),$(module),$(value module_rules))))
+$(foreach module,$(modules),$(eval $(subst %(module),$(module),$(value _am_module_rules))))
# Alias each bare phony target to itself with the `-all` suffix
-$(foreach t,$(.phony),$(eval $t: $t-all))
+$(foreach t,$(_am_phony),$(eval $t: $t-all))
# Add the `dist` target
.PHONY: dist
-dist: $(topobjdir)/$(PACKAGE)-$(VERSION).tar.gz
-$(topobjdir)/$(PACKAGE)-$(VERSION).tar.gz: $(topobjdir)/$(PACKAGE)-$(VERSION)
+dist: $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz
+$(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz: $(topoutdir)/$(PACKAGE)-$(VERSION)
$(TAR) czf $@ -C $(<D) $(<F)
-_copyfile = $(MKDIRS) $(dir $2) && $(CP) $1 $2
-_addfile = $(call _copyfile,$3,$2/$(call _relto,$1,$3))
-$(topobjdir)/$(PACKAGE)-$(VERSION): $(all_src_files) $(dep_src_files) $(all_dist_files) $(dep_dist_files)
+_am_copyfile = $(MKDIRS) $(dir $2) && $(CP) $1 $2
+_am_addfile = $(call _am_copyfile,$3,$2/$(call _am_relto,$1,$3))
+$(topoutdir)/$(PACKAGE)-$(VERSION): $(_am_all_src_files) $(_am_dep_src_files) $(_am_all_dist_files) $(_am_dep_dist_files)
$(RM) -r $@
+ @PS4='' && set -x && \
$(MKDIR) $(@D)/tmp.$(@F).$$$$ && \
- $(foreach f,$^,$(call _addfile,$(topsrcdir),$(@D)/tmp.$(@F).$$$$,$f) &&) \
+ $(foreach f,$^,$(call _am_addfile,$(topsrcdir),$(@D)/tmp.$(@F).$$$$,$f) &&) \
$(MV) $(@D)/tmp.$(@F).$$$$ $@ || $(RM) -r $(@D)/tmp.$(@F).$$$$
include $(topsrcdir)/common.once.mk
diff --git a/common.each.mk b/common.each.mk
index a02f6e5..05f1045 100644
--- a/common.each.mk
+++ b/common.each.mk
@@ -13,15 +13,23 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+dirs := $(dirs)
+
clean_files += .*.mk *.o
ifneq ($(AUTODEPS),)
--include $(wildcard $(objdir)/.*.mk)
+-include $(wildcard $(outdir)/.*.mk)
endif
-$(objdir)/% : $(srcdir)/%.sh
- $(M4) -P $(M4FLAGS) $< | $(INSTALL_PROGRAM) /dev/stdin $@
+$(outdir)/% : $(srcdir)/%.m4
+ $(M4) -P $(M4FLAGS) $< > $@
+
+$(outdir)/% : $(srcdir)/%.sh
+ $(INSTALL_PROGRAM) $< $@
+$(outdir)/% : $(outdir)/%.sh
+ $(INSTALL_PROGRAM) $< $@
-$(objdir)/%.o : $(srcdir)/%.c $(topobjdir)/config.mk
+$(outdir)/%.o : $(srcdir)/%.c $(topoutdir)/config.mk
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
-$(objdir)/%: $(objdir)/%.o
+
+$(outdir)/% : $(outdir)/%.o
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
diff --git a/common.once.mk b/common.once.mk
index 0603822..38a8df1 100644
--- a/common.once.mk
+++ b/common.once.mk
@@ -24,8 +24,9 @@ ifneq ($(AUTODEPS),)
CFLAGS += -MD -MF $(patsubst $(@D)/%.o,$(@D)/.%.mk,$@) -MP
endif
-CPPFLAGS += -I$(topobjdir)
-M4FLAGS += -I$(topobjdir)
+CPPFLAGS += -I$(topoutdir)
+M4FLAGS += -I$(topoutdir)
-# Should be on by default
+MAKEFLAGS += -rR
+.SECONDARY:
.DELETE_ON_ERROR:
diff --git a/common.top.mk b/common.top.mk
index a83abb6..9a2fa0a 100644
--- a/common.top.mk
+++ b/common.top.mk
@@ -14,32 +14,32 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Both of these have the argument order "parent,child"
-_noslash = $(patsubst %/,%,$1)
-_relto = $(call _noslash,$(patsubst $(abspath $1)/%,%,$(abspath $2)/))
-_is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/)
+_am_noslash = $(patsubst %/,%,$1)
+_am_relto = $(call _am_noslash,$(patsubst $(abspath $1)/%,%,$(abspath $2)/))
+_am_is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/)
## Declare the standard targets
all: build
.PHONY: all
-## Set topobjdir, objdir, and srcdir (assumes that topsrcdir is already set)
-ifeq ($(topobjdir),)
-topobjdir := $(call _noslash,$(dir $(lastword $(filter %/config.mk config.mk,$(MAKEFILE_LIST)))))
+## Set topoutdir, outdir, and srcdir (assumes that topsrcdir is already set)
+ifeq ($(topoutdir),)
+topoutdir := $(call _am_noslash,$(dir $(lastword $(filter %/config.mk config.mk,$(MAKEFILE_LIST)))))
endif
- objdir := $(call _noslash,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST)))))
- srcdir := $(firstword $(call _relto,., $(topsrcdir)/$(call _relto,$(topobjdir),$(objdir)) ) .)
+ outdir := $(call _am_noslash,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST)))))
+ srcdir := $(firstword $(call _am_relto,., $(topsrcdir)/$(call _am_relto,$(topoutdir),$(outdir)) ) .)
-included_makefiles := $(included_makefiles) $(abspath $(objdir)/Makefile)
+included_makefiles := $(included_makefiles) $(abspath $(outdir)/Makefile)
## Set module name
-module := $(subst /,_,$(if $(call _is_subdir,.,$(objdir)),$(firstword $(call _relto,.,$(objdir)) all),dep-$(firstword $(call _relto,$(topobjdir),$(objdir)) top)))
+module := $(subst /,_,$(if $(call _am_is_subdir,.,$(outdir)),$(firstword $(call _am_relto,.,$(outdir)) all),dep-$(firstword $(call _am_relto,$(topoutdir),$(outdir)) top)))
## Empty variables for use by the module
subdirs =
depdirs =
src_files =
-obj_files =
+out_files =
sys_files =
clean_files =
diff --git a/modules/.gitignore b/modules/.gitignore
new file mode 100644
index 0000000..3c197bc
--- /dev/null
+++ b/modules/.gitignore
@@ -0,0 +1,5 @@
+*/*
+!*/Makefile
+!*/.gitignore
+!*/*.mk
+!*/*.sh
diff --git a/modules/Makefile b/modules/Makefile
new file mode 100644
index 0000000..9830a8e
--- /dev/null
+++ b/modules/Makefile
@@ -0,0 +1,24 @@
+#!/usr/bin/make -f
+# Copyright (C) 2015 Luke Shumaker
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+include $(dir $(lastword $(MAKEFILE_LIST)))/../config.mk
+include $(topsrcdir)/common.top.mk
+
+dirs += $(DESTDIR)$(pkglibexecdir)/modules
+src_files += Makefile module.mk
+subdirs = comments date.author files tags tree
+
+include $(topsrcdir)/common.bottom.mk
diff --git a/modules/comments/Makefile b/modules/comments/Makefile
new file mode 120000
index 0000000..fa7273c
--- /dev/null
+++ b/modules/comments/Makefile
@@ -0,0 +1 @@
+../module.mk \ No newline at end of file
diff --git a/modules/comments/Makefile.inc.mk b/modules/comments/Makefile.inc.mk
new file mode 100644
index 0000000..6816836
--- /dev/null
+++ b/modules/comments/Makefile.inc.mk
@@ -0,0 +1,2 @@
+src_files += comment.sh commit.sh print.sh showcomment.sh
+out_files += comment commit print showcomment
diff --git a/plugins/comments/dep b/modules/comments/Module.mk
index a5bbb81..a5bbb81 100644
--- a/plugins/comments/dep
+++ b/modules/comments/Module.mk
diff --git a/plugins/comments/bin/comment.sh b/modules/comments/comment.sh
index 0be99e5..0be99e5 100644
--- a/plugins/comments/bin/comment.sh
+++ b/modules/comments/comment.sh
diff --git a/plugins/comments/bin/commit.sh b/modules/comments/commit.sh
index d13d754..d13d754 100644
--- a/plugins/comments/bin/commit.sh
+++ b/modules/comments/commit.sh
diff --git a/plugins/comments/bin/print.sh b/modules/comments/print.sh
index b04a9cc..b04a9cc 100644
--- a/plugins/comments/bin/print.sh
+++ b/modules/comments/print.sh
diff --git a/plugins/comments/bin/showcomment.sh b/modules/comments/showcomment.sh
index efbc00a..efbc00a 100644
--- a/plugins/comments/bin/showcomment.sh
+++ b/modules/comments/showcomment.sh
diff --git a/modules/date.author/Makefile b/modules/date.author/Makefile
new file mode 120000
index 0000000..fa7273c
--- /dev/null
+++ b/modules/date.author/Makefile
@@ -0,0 +1 @@
+../module.mk \ No newline at end of file
diff --git a/modules/date.author/Makefile.inc.mk b/modules/date.author/Makefile.inc.mk
new file mode 100644
index 0000000..c6b27a2
--- /dev/null
+++ b/modules/date.author/Makefile.inc.mk
@@ -0,0 +1,2 @@
+src_files += commit.sh
+out_files += commit
diff --git a/plugins/date.author/dep b/modules/date.author/Module.mk
index 3284d55..3284d55 100644
--- a/plugins/date.author/dep
+++ b/modules/date.author/Module.mk
diff --git a/plugins/date.author/bin/commit.sh b/modules/date.author/commit.sh
index c05f77b..c05f77b 100644
--- a/plugins/date.author/bin/commit.sh
+++ b/modules/date.author/commit.sh
diff --git a/modules/files/Makefile b/modules/files/Makefile
new file mode 120000
index 0000000..fa7273c
--- /dev/null
+++ b/modules/files/Makefile
@@ -0,0 +1 @@
+../module.mk \ No newline at end of file
diff --git a/modules/files/Makefile.inc.mk b/modules/files/Makefile.inc.mk
new file mode 100644
index 0000000..99c739e
--- /dev/null
+++ b/modules/files/Makefile.inc.mk
@@ -0,0 +1,8 @@
+src_files += blob-gethash.sh blob-gettype.sh commit.d.sh commit.f.sh commit.sh file-gettype.sh get.d.sh get.f.sh get.sh ls.sh print.sh tree.sh
+out_files += blob-gethash blob-gettype commit.d commit.f commit file-gettype get.d get.f get ls print tree
+
+src_files += _stdio.sh
+sys_files += $(pkglibexecdir)/modules/$(name)/_stdio.sh
+
+$(DESTDIR)$(pkglibexecdir)/modules/$(name)/_stdio.sh: $(srcdir)/_stdio.sh | $(DESTDIR)$(pkglibexecdir)/modules/$(name)
+ $(INSTALL_DATA) $< $@
diff --git a/plugins/files/dep b/modules/files/Module.mk
index e69de29..e69de29 100644
--- a/plugins/files/dep
+++ b/modules/files/Module.mk
diff --git a/plugins/files/lib/stdio.sh b/modules/files/_stdio.sh
index 974e98e..974e98e 100644
--- a/plugins/files/lib/stdio.sh
+++ b/modules/files/_stdio.sh
diff --git a/plugins/files/bin/blob-gethash.sh b/modules/files/blob-gethash.sh
index 74defbc..74defbc 100644
--- a/plugins/files/bin/blob-gethash.sh
+++ b/modules/files/blob-gethash.sh
diff --git a/plugins/files/bin/blob-gettype.sh b/modules/files/blob-gettype.sh
index da3ee2a..da3ee2a 100644
--- a/plugins/files/bin/blob-gettype.sh
+++ b/modules/files/blob-gettype.sh
diff --git a/plugins/files/bin/commit.d.sh b/modules/files/commit.d.sh
index d7e48f9..d7e48f9 100644
--- a/plugins/files/bin/commit.d.sh
+++ b/modules/files/commit.d.sh
diff --git a/plugins/files/bin/commit.f.sh b/modules/files/commit.f.sh
index e0df1b2..e0df1b2 100644
--- a/plugins/files/bin/commit.f.sh
+++ b/modules/files/commit.f.sh
diff --git a/plugins/files/bin/commit.sh b/modules/files/commit.sh
index 0bb8233..0bb8233 100644
--- a/plugins/files/bin/commit.sh
+++ b/modules/files/commit.sh
diff --git a/plugins/files/bin/file-gettype.sh b/modules/files/file-gettype.sh
index 2a1e0ca..2a1e0ca 100644
--- a/plugins/files/bin/file-gettype.sh
+++ b/modules/files/file-gettype.sh
diff --git a/plugins/files/bin/get.d.sh b/modules/files/get.d.sh
index 646e29d..646e29d 100644
--- a/plugins/files/bin/get.d.sh
+++ b/modules/files/get.d.sh
diff --git a/plugins/files/bin/get.f.sh b/modules/files/get.f.sh
index e3d5edc..e3d5edc 100644
--- a/plugins/files/bin/get.f.sh
+++ b/modules/files/get.f.sh
diff --git a/plugins/files/bin/get.sh b/modules/files/get.sh
index 639ac57..639ac57 100644
--- a/plugins/files/bin/get.sh
+++ b/modules/files/get.sh
diff --git a/plugins/files/bin/ls.sh b/modules/files/ls.sh
index 9e586eb..9e586eb 100644
--- a/plugins/files/bin/ls.sh
+++ b/modules/files/ls.sh
diff --git a/plugins/files/bin/print.sh b/modules/files/print.sh
index 3657d2f..3657d2f 100644
--- a/plugins/files/bin/print.sh
+++ b/modules/files/print.sh
diff --git a/plugins/files/bin/tree.sh b/modules/files/tree.sh
index 6164d94..6164d94 100644
--- a/plugins/files/bin/tree.sh
+++ b/modules/files/tree.sh
diff --git a/modules/module.mk b/modules/module.mk
new file mode 100644
index 0000000..c6e577d
--- /dev/null
+++ b/modules/module.mk
@@ -0,0 +1,35 @@
+#!/usr/bin/make -f
+# Copyright (C) 2009, 2015 Luke Shumaker
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk
+include $(topsrcdir)/common.top.mk
+
+name := $(lastword $(subst /, ,$(srcdir)))
+include $(srcdir)/Makefile.inc.mk
+
+dirs += $(DESTDIR)$(pkglibexecdir)/modules/$(name)
+src_files += Makefile Makefile.inc.mk Module.mk
+sys_files += $(pkglibexecdir)/modules/$(name).mk
+sys_files += $(addprefix $(pkglibexecdir)/modules/$(name)/,$(out_files))
+
+$(DESTDIR)$(pkglibexecdir)/modules/$(name).mk: $(srcdir)/Module.mk | $(DESTDIR)$(pkglibexecdir)/modules
+ $(INSTALL_DATA) $< $@
+$(DESTDIR)$(pkglibexecdir)/modules/$(name)/%: $(srcdir)/% | $(DESTDIR)$(pkglibexecdir)/modules/$(name)
+ $(INSTALL_PROGRAM) $< $@
+$(DESTDIR)$(pkglibexecdir)/modules/$(name)/%: $(outdir)/% | $(DESTDIR)$(pkglibexecdir)/modules/$(name)
+ $(INSTALL_PROGRAM) $< $@
+
+include $(topsrcdir)/common.bottom.mk
diff --git a/modules/tags/Makefile b/modules/tags/Makefile
new file mode 120000
index 0000000..fa7273c
--- /dev/null
+++ b/modules/tags/Makefile
@@ -0,0 +1 @@
+../module.mk \ No newline at end of file
diff --git a/modules/tags/Makefile.inc.mk b/modules/tags/Makefile.inc.mk
new file mode 100644
index 0000000..8d687a5
--- /dev/null
+++ b/modules/tags/Makefile.inc.mk
@@ -0,0 +1,2 @@
+src_files += commit.sh get-tag.sh print.sh tag-id.sh tag.sh
+out_files += commit get-tag print tag-id tag
diff --git a/plugins/tags/dep b/modules/tags/Module.mk
index fd9e5f7..fd9e5f7 100644
--- a/plugins/tags/dep
+++ b/modules/tags/Module.mk
diff --git a/plugins/tags/bin/commit.sh b/modules/tags/commit.sh
index 9282a11..9282a11 100644
--- a/plugins/tags/bin/commit.sh
+++ b/modules/tags/commit.sh
diff --git a/plugins/tags/bin/get-tag.sh b/modules/tags/get-tag.sh
index fa7895b..fa7895b 100644
--- a/plugins/tags/bin/get-tag.sh
+++ b/modules/tags/get-tag.sh
diff --git a/plugins/tags/bin/print.sh b/modules/tags/print.sh
index b7bc1c5..b7bc1c5 100644
--- a/plugins/tags/bin/print.sh
+++ b/modules/tags/print.sh
diff --git a/plugins/tags/bin/tag-id.sh b/modules/tags/tag-id.sh
index ef95f69..ef95f69 100644
--- a/plugins/tags/bin/tag-id.sh
+++ b/modules/tags/tag-id.sh
diff --git a/plugins/tags/bin/tag.sh b/modules/tags/tag.sh
index bc3f546..bc3f546 100644
--- a/plugins/tags/bin/tag.sh
+++ b/modules/tags/tag.sh
diff --git a/modules/tree/Makefile b/modules/tree/Makefile
new file mode 120000
index 0000000..fa7273c
--- /dev/null
+++ b/modules/tree/Makefile
@@ -0,0 +1 @@
+../module.mk \ No newline at end of file
diff --git a/modules/tree/Makefile.inc.mk b/modules/tree/Makefile.inc.mk
new file mode 100644
index 0000000..82c0b58
--- /dev/null
+++ b/modules/tree/Makefile.inc.mk
@@ -0,0 +1,2 @@
+src_files += addparent.d.sh addparent.f.sh addparent.sh commit.sh delparent.f.sh getchildren.sh getparents.sh print.sh
+out_files += addparent.d addparent.f addparent commit delparent.f getchildren getparents print
diff --git a/plugins/tree/dep b/modules/tree/Module.mk
index 2485770..2485770 100644
--- a/plugins/tree/dep
+++ b/modules/tree/Module.mk
diff --git a/plugins/tree/bin/addparent.d.sh b/modules/tree/addparent.d.sh
index db43dd2..db43dd2 100644
--- a/plugins/tree/bin/addparent.d.sh
+++ b/modules/tree/addparent.d.sh
diff --git a/plugins/tree/bin/addparent.f.sh b/modules/tree/addparent.f.sh
index 61b4f92..61b4f92 100644
--- a/plugins/tree/bin/addparent.f.sh
+++ b/modules/tree/addparent.f.sh
diff --git a/plugins/tree/bin/addparent.sh b/modules/tree/addparent.sh
index 6759bcb..6759bcb 100644
--- a/plugins/tree/bin/addparent.sh
+++ b/modules/tree/addparent.sh
diff --git a/plugins/tree/bin/commit.sh b/modules/tree/commit.sh
index 89b1bf6..89b1bf6 100644
--- a/plugins/tree/bin/commit.sh
+++ b/modules/tree/commit.sh
diff --git a/plugins/tree/bin/delparent.f.sh b/modules/tree/delparent.f.sh
index e53df9b..e53df9b 100644
--- a/plugins/tree/bin/delparent.f.sh
+++ b/modules/tree/delparent.f.sh
diff --git a/plugins/tree/bin/getchildren.sh b/modules/tree/getchildren.sh
index 952522c..952522c 100644
--- a/plugins/tree/bin/getchildren.sh
+++ b/modules/tree/getchildren.sh
diff --git a/plugins/tree/bin/getparents.sh b/modules/tree/getparents.sh
index 6e3edbd..6e3edbd 100644
--- a/plugins/tree/bin/getparents.sh
+++ b/modules/tree/getparents.sh
diff --git a/plugins/tree/bin/print.sh b/modules/tree/print.sh
index 0ebf8fd..0ebf8fd 100644
--- a/plugins/tree/bin/print.sh
+++ b/modules/tree/print.sh
diff --git a/plugins/comments/info.mk.in b/plugins/comments/info.mk.in
deleted file mode 100644
index ad2539d..0000000
--- a/plugins/comments/info.mk.in
+++ /dev/null
@@ -1,3 +0,0 @@
-name = comments
-ver = 0.1
-
diff --git a/plugins/date.author/info.mk.in b/plugins/date.author/info.mk.in
deleted file mode 100644
index 852203d..0000000
--- a/plugins/date.author/info.mk.in
+++ /dev/null
@@ -1,3 +0,0 @@
-name = date.author
-ver = 0.9
-
diff --git a/plugins/files/etc/3-d.sh b/plugins/files/etc/3-d.sh
deleted file mode 100644
index f169cae..0000000
--- a/plugins/files/etc/3-d.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-if [ -d "$1" ]; then echo 'd'; fi
-
diff --git a/plugins/files/etc/5-f.sh b/plugins/files/etc/5-f.sh
deleted file mode 100644
index 0506894..0000000
--- a/plugins/files/etc/5-f.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-if [ -f "$1" ]; then echo 'f'; fi
-
diff --git a/plugins/files/info.mk.in b/plugins/files/info.mk.in
deleted file mode 100644
index 78a0580..0000000
--- a/plugins/files/info.mk.in
+++ /dev/null
@@ -1,3 +0,0 @@
-name = files
-ver = 0.9
-
diff --git a/plugins/main.mk.in b/plugins/main.mk.in
deleted file mode 100644
index 774e4ac..0000000
--- a/plugins/main.mk.in
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/make -f
-#name=rvs plugins
-#version='1.0'
-# Copyright (C) 2009 Luke Shumaker
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; see the file COPYING.
-# If not, see <http://www.gnu.org/licenses>.
-
-sysconfdir = @sysconfdir@
-BINDIR = @BINDIR@
-TMPDIR = @TMPDIR@
-LIBDIR = @LIBDIR@
-ETCDIR = @ETCDIR@
-dirs += $(sysconfdir) $(BINDIR) $(TMPDIR) $(LIBDIR) $(ETCDIR)
-
-mods = files tags
-mods-build = $(addprefix build-,$(mods))
-mods-install = $(addprefix install-,$(mods))
-mods-uninstall = $(addprefix uninstall-,$(mods))
-mods-clean = $(addprefix clean-,$(mods))
-mods-distclean = $(addprefix distclean-,$(mods))
-
-.PHONY : all
-all : build
-
-.PHONY : build install clean distclean
-# $(mods-build) $(mods-install) $(mods-clean) $(mods-distclean)
-build : $(mods-build)
-install : $(mods-install)
-uninstall : $(mods-uninstall)
-clean : $(mods-clean)
-distclean : $(mods-distclean)
- $(RM) Makefile *.mk
-
-.SECONDARY:
-
-%/main.mk : plugin.mk %/; cp $< $@
-
-complete-% : %/ %/main.mk; :
-build-% : %/ complete-% %/main.mk; $(MAKE) -C $<
-install-% : %/ complete-% %/main.mk; $(MAKE) -C $< install
-uninstall-% : %/ complete-% %/main.mk; $(MAKE) -C $< uninstall
-clean-% : %/ complete-% %/main.mk; -$(MAKE) -C $< clean
-distclean-% : %/ complete-% %/main.mk; $(MAKE) -C $< distclean
-
diff --git a/plugins/plugin.mk.in b/plugins/plugin.mk.in
deleted file mode 100644
index d631e4e..0000000
--- a/plugins/plugin.mk.in
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/make -f
-#name=rvs plugin Makefile
-#ver=0.9
-include info.mk # this contains the actuall name/version for the plugin
-# Copyright (C) 2009 Luke Shumaker
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; see the file COPYING.
-# If not, see <http://www.gnu.org/licenses>.
-
-sysconfdir = @sysconfdir@
-BINDIR = @BINDIR@
-TMPDIR = @TMPDIR@
-LIBDIR = @LIBDIR@
-ETCDIR = @ETCDIR@
-DEPDIR = @DEPDIR@
-dirs += $(sysconfdir) $(BINDIR) $(TMPDIR) $(LIBDIR) $(ETCDIR) $(DEPDIR)
-
-rvs = @rvs@
-RVS = @RVS@
-
-id = $(name)
-
-# phony targets ####################################################
-all : $(name)
-.PHONY : $(name) install uninstall clean distclean
-.SUFFIXES :
-
-# build ############################################################
-srcFiles = $(filter-out %/Makefile.in,$(shell find $(srcdir)/ -type f))
-
-shSrcFiles = $(filter %.sh,$(srcFiles))
-shOutFiles = $(patsubst $(srcdir)/%,%,$(basename $(shSrcFiles)))
-
-outFiles = $(shOutFiles)
-outBin = $(addprefix $(BINDIR)/$(name)/,$(notdir $(filter bin/%,$(outFiles))))
-outEtc = $(addprefix $(ETCDIR)/$(name)/,$(notdir $(filter etc/%,$(outFiles))))
-outLib = $(addprefix $(LIBDIR)/$(name)/,$(notdir $(filter lib/%,$(outFiles))))
-
-$(name) : $(myoutdir) $(shOutFiles)
-
-# (un)install ######################################################
-
-install : $(outBin) $(outEtc) $(outLib)
-
-$(outBin) : $(BINDIR)/$(name)/% : bin/%
- $(MKDIR) $(dir $@)
- $(INSTALL_PROGRAM) $< $@
-
-$(outEtc) : $(ETCDIR)/$(name)/% : etc/%
- $(MKDIR) $(dir $@)
- $(INSTALL_PROGRAM) $< $@
-
-$(outLib) : $(LIBDIR)/$(name)/% : lib/%
- $(MKDIR) $(dir $@)
- $(INSTALL_DATA) $< $@
-
-uninstall : $(addprefix un,$(outBin))
- $(RM) -r $(ETCDIR)/$(name)
- $(RM) -r $(LIBDIR)/$(name)
-
-# clean ############################################################
-
-clean :
-
-distclean : clean
- find ./ -name Makefile -exec $(RM) '{}' \;
- find ./ -name '*.mk' -exec $(RM) '{}' \;
-
-# implicit rules ###################################################
-
-b := @
-# build shell scripts
-$(shOutFiles) : % : %.sh
- $(INSTALL_PROGRAM) $< $@
- $(SED) -i \
- -e 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' \
- -e 's/$bID@/$(subst /,\/,$(id))/g' \
- $@
-
diff --git a/plugins/tags/info.mk.in b/plugins/tags/info.mk.in
deleted file mode 100644
index 3f08f99..0000000
--- a/plugins/tags/info.mk.in
+++ /dev/null
@@ -1,3 +0,0 @@
-name = tags
-ver = 0.1
-
diff --git a/plugins/tree/info.mk.in b/plugins/tree/info.mk.in
deleted file mode 100644
index b947f3d..0000000
--- a/plugins/tree/info.mk.in
+++ /dev/null
@@ -1,3 +0,0 @@
-name = tree
-ver = 0.1
-
diff --git a/wrapper/.gitignore b/wrapper/.gitignore
index 6141a28..0c3c90a 100644
--- a/wrapper/.gitignore
+++ b/wrapper/.gitignore
@@ -1,2 +1,3 @@
/outer
-/inner \ No newline at end of file
+/inner
+/inner.sh
diff --git a/wrapper/Makefile b/wrapper/Makefile
index f316cc0..54047d2 100644
--- a/wrapper/Makefile
+++ b/wrapper/Makefile
@@ -17,16 +17,19 @@
include $(dir $(lastword $(MAKEFILE_LIST)))/../config.mk
include $(topsrcdir)/common.top.mk
-src_files += Makefile outer.c inner.sh
-obj_files += outer inner
-install_files += $(bindir)/$(PACKAGE) $(pkglibexecdir)/$(PACKAGE)
+src_files += Makefile outer.c inner.sh.m4 runcmd.mk
+out_files += outer inner
+clean_files += inner.sh
+sys_files += $(bindir)/$(PACKAGE) $(pkglibexecdir)/$(PACKAGE) $(pkglibexecdir)/runcmd.mk
-$(objdir)/outer.o: $(topobjdir)/config.h
-$(objdir)/inner: $(topobjdir)/config.sh
+$(outdir)/outer.o: $(topoutdir)/config.h
+$(outdir)/inner: $(topoutdir)/config.sh
-$(DESTDIR)$(bindir)/$(PACKAGE) : $(objdir)/outer | $(DESTDIR)$(bindir)
+$(DESTDIR)$(bindir)/$(PACKAGE) : $(outdir)/outer | $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) $< $@
-$(DESTDIR)$(pkglibexecdir)/$(PACKAGE) : $(objdir)/inner | $(DESTDIR)$(bindir)
+$(DESTDIR)$(pkglibexecdir)/$(PACKAGE) : $(outdir)/inner | $(DESTDIR)$(pkglibexecdir)
+ $(INSTALL_PROGRAM) $< $@
+$(DESTDIR)$(pkglibexecdir)/runcmd.mk : $(srcdir)/runcmd.mk | $(DESTDIR)$(pkglibexecdir)
$(INSTALL_PROGRAM) $< $@
include $(topsrcdir)/common.bottom.mk
diff --git a/wrapper/inner.sh b/wrapper/inner.sh.m4
index b1dc718..8444bd6 100644
--- a/wrapper/inner.sh
+++ b/wrapper/inner.sh.m4
@@ -54,44 +54,53 @@ install_sighandlers() {
# Like GLibC's error(3), but call gettext on the format string
error() {
- >&2 printf "%s: $(_ "$2")\n" "$RVS" "${@:3}"
+ >&2 printf "%s: $(_ "$2")\n" "$program_name" "${@:3}"
+ [[ $1 -eq 0 ]] || exit $1
+}
+
+errusage() {
+ >&2 printf "$(_ "$2")\n" "$program_name" "${@:3}"
[[ $1 -eq 0 ]] || exit $1
}
_runcmd() {
- [[ $# -ge 1 ]] || error 1 'Usage: %s <command> [<args>]' "$program_name"
- local cmd=$1
-
+ [[ $# -ge 1 ]] || errusage 1 'Usage: %q <command> [<args>]'
+ local cmd=$1; shift
+ local args_str=''
+ [[ $# -eq 0 ]] || printf -v args_str '%q ' "$@"
+
local exec_path="${!varname_EXEC_PATH:-$pkglibexecdir}"
- if [ ! -e "$exec_path/$cmd" ] || [ "$cmd" = "${PACKAGE}" ]; then
+ shopt -s nullglob
+ local files=("${exec_path}"/modules/*/"$cmd")
+ if [[ ${#files[@]} -eq 0 ]]; then
error 127 '%s: Not a %s command' "$cmd" "$PACKAGE"
- else
- trap '[ -z "${TMPDIR:-}" ] || rm -rf -- "$TMPDIR"' EXIT
- export TMPDIR="$(mktemp -dt "${PACKAGE}.XXXXXXXXXX")"
-
- repo="$(_repo)"
- export "$varname_REPO=$repo"
-
- set -o pipefail
-
- if [ -f "$exec_path/$cmd" ]; then
- "$exec_path/$cmd" "$@" | tee -- "$TMPDIR/$cmd"
- elif [ -d "$exec_path/$cmd" ]; then
- mkdir -p -- "$TMPDIR/$cmd"
- local file
- for file in "$exec_path/$command"/*; do
- "$file" "$@" | tee -- "$TMPDIR/$command/${file##*/}" ||
- error 127 'Aborting: error encountered while running: %s' "$file"
- done
- else
- error 127 '%s: Could not execute' "$exec_path/$cmd"
- fi
fi
+ files=("${files[@]#"${exec_path/modules/}"}")
+
+ local output_dir
+ trap '[ -z "${output_dir:-}" ] || rm -rf -- "$TMPDIR"' EXIT
+ output_dir="$(mktemp -dt "${PACKAGE}.XXXXXXXXXX")"
+
+ local repo
+ repo="$(_repo)"
+ export "${varname_REPO}=${repo}"
+
+ local cwd
+ printf -v cwd '%q' "$PWD"
+
+ make -j1 \
+ -f "$exec_path/runcmd.mk" \
+ -C "$output_dir" \
+ ARGS="$args_str" \
+ EXEC_PATH="$exec_path" \
+ CWD="$cwd" \
+ -- "${files[@]}"
+ exit $?
}
_repo() {
- [[ $# -ne 0 ]] || error 1 'Usage: %s repo' "$program_name"
+ [[ $# -ne 0 ]] || errusage 1 'Usage: %q repo'
if [ -z "${!varname_REPO:-}" ]; then # we aren't getting a value from then env
local repo=".${PACKAGE,,}"
@@ -113,7 +122,7 @@ _repo() {
}
_init() {
- [[ $# -gt 1 ]] || error 1 'Usage: %s init [directory]' "$program_name"
+ [[ $# -gt 1 ]] || errusage 1 'Usage: %q init [directory]'
local dir="${1:-$PWD}"
mkdir -p -- "$dir"
cd "$dir"
diff --git a/wrapper/runcmd.mk b/wrapper/runcmd.mk
new file mode 100644
index 0000000..7cadb43
--- /dev/null
+++ b/wrapper/runcmd.mk
@@ -0,0 +1,15 @@
+#!/usr/bin/make -f
+
+# Environment/command line variables:
+# - ARGS
+# - EXEC_DIR
+# - CWD
+
+SHELL = bash -o pipefail
+
+export OUTPUT_DIR := $(realpath .)
+
+% : $(EXEC_PATH)/modules/%
+ cd $(CWD) && '$<' $(ARGS) | tee -- '$@'
+
+include $(wildcard $(EXEC_PATH)/modules/*.mk)