summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile16
-rw-r--r--automake.head.mk58
-rw-r--r--automake.tail.mk139
-rw-r--r--automake.txt105
-rw-r--r--common.bottom.mk136
-rw-r--r--common.each.head.mk16
-rw-r--r--common.each.tail.mk (renamed from common.each.mk)9
-rw-r--r--common.once.head.mk (renamed from common.once.mk)15
-rw-r--r--common.once.tail.mk19
-rw-r--r--common.top.mk49
-rw-r--r--config.mk.in (renamed from config.mk)3
-rwxr-xr-xconfigure104
-rw-r--r--modules/Makefile8
-rw-r--r--modules/blobs/Makefile.inc.mk8
-rw-r--r--modules/comments/Makefile.inc.mk4
-rw-r--r--modules/date.author/Makefile.inc.mk4
l---------modules/git-fast-import/.#parse.sh1
-rw-r--r--modules/module.mk11
-rw-r--r--modules/tags/Makefile.inc.mk4
-rw-r--r--modules/tree/Makefile.inc.mk4
-rw-r--r--wrapper/Makefile15
22 files changed, 424 insertions, 305 deletions
diff --git a/.gitignore b/.gitignore
index c455e80..2af088f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+/config.mk
/config.h
/config.sh
*.o
diff --git a/Makefile b/Makefile
index 55c26ef..1291709 100644
--- a/Makefile
+++ b/Makefile
@@ -15,16 +15,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
include $(dir $(lastword $(MAKEFILE_LIST)))/config.mk
-include $(topsrcdir)/common.top.mk
+include $(topsrcdir)/automake.head.mk
-subdirs = wrapper modules
+am_subdirs = wrapper modules
-src_files = Makefile
-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
-out_files = config.sh config.h
+makefiles = Makefile automake.head.mk automake.tail.mk automake.txt common.once.head.mk common.once.tail.mk common.each.head.mk common.each.tail.mk config.mk
+
+am_src_files = COPYING HACKING README configure config.mk.in
+am_out_files = config.sh config.h
config_vars = $(shell $(SED) -n 's/^\s*\([a-z][^ !?:=]*\).*=.*/\1/p' $(topoutdir)/config.mk) PACKAGE VERSION DESTDIR
$(outdir)/config.sh: $(outdir)/config.mk
@@ -32,4 +30,4 @@ $(outdir)/config.sh: $(outdir)/config.mk
$(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
+include $(topsrcdir)/automake.tail.mk
diff --git a/automake.head.mk b/automake.head.mk
new file mode 100644
index 0000000..ad7154c
--- /dev/null
+++ b/automake.head.mk
@@ -0,0 +1,58 @@
+# Copyright (C) 2015-2016 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/>.
+
+_am = am_
+
+_am_noslash = $(patsubst %/.,%,$(patsubst %/,%,$1))
+# These are all $(call _am_func,parent,child)
+#_am_relto = $(if $2,$(shell realpath -s --relative-to='$1' $2))
+_am_is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/.)
+_am_relto_helper = $(if $(call _am_is_subdir,$1,$2),$(patsubst $1/%,%,$(addsuffix /.,$2)),$(addprefix ../,$(call _am_relto_helper,$(patsubst %/,%,$(dir $1)),$2)))
+_am_relto = $(call _am_noslash,$(call _am_relto_helper,$(call _am_noslash,$(abspath $1)),$(call _am_noslash,$(abspath $2))))
+# Note that _am_is_subdir says that a directory is a subdirectory of
+# itself.
+_am_path = $(call _am_relto,.,$1)
+
+## Declare the default target
+all: build
+.PHONY: all
+
+## Set topoutdir, outdir, and srcdir (assumes that topsrcdir is
+## already set, and that $(topoutdir)/config.mk has been included)
+ifeq ($(topoutdir),)
+topoutdir := $(call _am_path,$(dir $(lastword $(filter %/config.mk config.mk,$(MAKEFILE_LIST)))))
+endif
+ outdir := $(call _am_path,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST)))))
+ srcdir := $(call _am_path,$(topsrcdir)/$(call _am_relto,$(topoutdir),$(outdir)))
+
+_am_included_makefiles := $(_am_included_makefiles) $(call _am_path,$(outdir)/Makefile)
+
+## Empty variables for use by each Makefile
+$(_am)subdirs =
+$(_am)depdirs =
+
+$(_am)src_files =
+$(_am)gen_files =
+$(_am)cfg_files =
+$(_am)out_files =
+$(_am)sys_files =
+
+$(_am)clean_files =
+$(_am)slow_files =
+
+ifeq ($(_am_NO_ONCE),)
+include $(topsrcdir)/common.once.head.mk
+endif
+include $(topsrcdir)/common.each.head.mk
diff --git a/automake.tail.mk b/automake.tail.mk
new file mode 100644
index 0000000..a24820b
--- /dev/null
+++ b/automake.tail.mk
@@ -0,0 +1,139 @@
+# Copyright (C) 2015-2016 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 $(topsrcdir)/common.each.tail.mk
+
+
+# Aggregate variables
+
+# Add some more defaults to the *_files variables
+$(_am)clean_files += $($(_am)gen_files) $($(_am)cfg_files) $($(_am)out_files)
+
+# Now namespace the *_files variables
+define _am_save_variables
+_am_src_files/$(outdir) = $(addprefix $(srcdir)/,$($(_am)src_files))
+_am_gen_files/$(outdir) = $(addprefix $(srcdir)/,$($(_am)gen_files))
+_am_cfg_files/$(outdir) = $(addprefix $(outdir)/,$($(_am)cfg_files))
+_am_out_files/$(outdir) = $(addprefix $(outdir)/,$($(_am)out_files))
+_am_sys_files/$(outdir) = $(addprefix $(DESTDIR),$($(_am)sys_files))
+_am_clean_files/$(outdir) = $(addprefix $(outdir)/,$($(_am)clean_files))
+_am_slow_files/$(outdir) = $(addprefix $(outdir)/,$($(_am)slow_files))
+_am_subdirs/$(outdir) = $($(_am)subdirs)
+endef
+$(eval $(_am_save_variables))
+
+# And add them to the $(parent)_*_files variables (if applicable)
+define _am_add_subdir
+_am_src_files/%(outdir) += $(_am_src_files/%(subdir))
+_am_gen_files/%(outdir) += $(_am_gen_files/%(subdir))
+_am_cfg_files/%(outdir) += $(_am_cfg_files/%(subdir))
+_am_out_files/%(outdir) += $(_am_out_files/%(subdir))
+_am_sys_files/%(outdir) += $(_am_sys_files/%(subdir))
+_am_clean_files/%(outdir) += $(_am_clean_files/%(subdir))
+_am_slow_files/%(outdir) += $(_am_slow_files/%(subdir))
+endef
+$(foreach subdir,$(call _am_path,$(addprefix $(outdir)/,$($(_am)subdirs))),$(eval $(subst %(outdir),$(outdir),$(subst %(subdir),$(subdir),$(value _am_add_subdir)))))
+
+_am_outdirs := $(_am_outdirs) $(outdir)
+
+
+# Do some per-directory magic
+
+_am_phony = build install uninstall mostlyclean clean distclean maintainer-clean check
+
+.PHONY: $(addprefix $(outdir)/,$(_am_phony))
+
+$(addprefix $(outdir)/,uninstall mostlyclean clean distclean maintainer-clean)::
+ $(RM) -- $(sort $(_am_$(@F)/$(@D)))
+ $(RMDIRS) $(sort $(dir $(_am_$(@F)/$(@D)))) 2>/dev/null || $(TRUE)
+
+# 'build' and 'install' must be defined later, because the
+# am_*_files/* variables might not be complete yet.
+
+
+# Include Makefiles from other directories
+
+define _am_nl
+
+
+endef
+
+$(foreach _am_NO_ONCE,y,\
+ $(foreach makefile,$(foreach dir,$($(_am)subdirs) $($(_am)depdirs),$(call _am_path,$(outdir)/$(dir)/Makefile)),\
+ $(eval include $(filter-out $(_am_included_makefiles),$(makefile)))))
+
+
+# This only gets evaluated once, after all of the other Makefiles are read
+ifeq ($(_am_NO_ONCE),)
+# Empty directory-level variables
+outdir = /bogus
+srcdir = /bogus
+
+$(_am)subdirs =
+$(_am)depdirs =
+
+$(_am)src_files =
+$(_am)gen_files =
+$(_am)cfg_files =
+$(_am)out_files =
+$(_am)sys_files =
+$(_am)clean_files =
+$(_am)slow_files =
+
+_am_clean_files/$(topoutdir) += $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz
+$(addprefix $(topoutdir)/,mostlyclean clean distclean maintainer-clean) ::
+ $(RM) -r -- $(topoutdir)/$(PACKAGE)-$(VERSION)
+
+define _am_directory_rules
+# Constructive phony targets
+$(outdir)/build : $(_am_out_files/%(outdir))
+$(outdir)/install: $(_am_sys_files/%(outdir))
+# Destructive phony targets
+_am_uninstall/%(outdir) = $(_am_sys_files/%(outdir))
+_am_mostlyclean/%(outdir) = $(filter-out $(_am_slow_files/%(outdir)) $(_am_cfg_files/%(outdir)) $(_am_gen_files/%(outdir)) $(_am_src_files/%(outdir)),$(_am_clean_files/%(outdir)))
+_am_clean/%(outdir) = $(filter-out $(_am_cfg_files/%(outdir)) $(_am_gen_files/%(outdir)) $(_am_src_files/%(outdir)),$(_am_clean_files/%(outdir)))
+_am_distclean/%(outdir) = $(filter-out $(_am_gen_files/%(outdir)) $(_am_src_files/%(outdir)),$(_am_clean_files/%(outdir)))
+_am_maintainer-clean/%(outdir) = $(filter-out $(_am_src_files/%(outdir)),$(_am_clean_files/%(outdir)))
+endef
+$(foreach outdir,$(_am_outdirs),$(eval $(subst %(outdir),$(outdir),$(value _am_directory_rules))))
+
+# Add the `dist` target
+.PHONY: dist
+dist: $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz
+$(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz: $(topoutdir)/$(PACKAGE)-$(VERSION)
+ $(TAR) czf $@ -C $(<D) $(<F)
+_am_copyfile = $(MKDIRS) $(dir $2) && $(CP) -T $1 $2
+_am_addfile = $(call _am_copyfile,$3,$2/$(call _am_relto,$1,$3))
+$(topoutdir)/$(PACKAGE)-$(VERSION): $(_am_src_files/$(topoutdir)) $(_am_gen_files/$(topoutdir))
+ $(RM) -r $@
+ @PS4='' && set -x && \
+ $(MKDIR) $(@D)/tmp.$(@F).$$$$ && \
+ $(foreach f,$^,$(call _am_addfile,$(topsrcdir),$(@D)/tmp.$(@F).$$$$,$f) &&) \
+ $(MV) $(@D)/tmp.$(@F).$$$$ $@ || $(RM) -r $(@D)/tmp.$(@F).$$$$
+
+include $(topsrcdir)/common.once.tail.mk
+
+# For some reason I can't explain, RM doesn't really get set with ?=
+CP ?= cp
+MKDIR ?= mkdir
+MKDIRS ?= mkdir -p
+MV ?= mv
+RM = rm -f
+RMDIRS ?= rmdir -p
+TAR ?= tar
+TRUE ?= true
+
+.PHONY: noop
+endif
diff --git a/automake.txt b/automake.txt
new file mode 100644
index 0000000..22a0b84
--- /dev/null
+++ b/automake.txt
@@ -0,0 +1,105 @@
+Luke's AutoMake
+===============
+
+Yo, this document is incomplete. It describes the magical
+automake.{head,tail}.mk Makefiles and how to use them, kinda.
+
+I wrote a "clone" of automake. I say clone, because it works
+differently. Yeah, I need a new name for it.
+
+High-level overview
+-------------------
+
+In each source directory, you write a `Makefile`, very similarly to if
+you were writing for plain GNU Make, with
+
+ # adjust the number of `../` segments as appropriate
+ include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk
+ include $(topsrcdir)/automake.head.mk
+
+ # your makefile
+
+ include $(topsrcdir)/automake.tail.mk
+
+Write your own `common.{each,once}.{head,tail}.mk` files that get
+included:
+ - `common.once.head.mk`: before parsing any of your Makefiles
+ - `common.each.head.mk`: before parsing each of your Makefiles
+ - `common.each.tail.mk`: after parsing each of your Makefiles
+ - `common.each.tail.mk`: after parsing all of your Makefiles
+
+Here is a table of all of the .PHONY targets that automake takes care
+of for you:
+
+| this | and this | are aliases for this |
+|------+------------------+--------------------------------------------------------|
+| all | build | $(outdir)/build |
+| | install | $(outdir)/install |
+| | uninstall | $(outdir)/uninstall |
+| | mostlyclean | $(outdir)/mostlyclean |
+| | clean | $(outdir)/clean |
+| | distclean | $(outdir)/distclean |
+| | maintainer-clean | $(outdir)/maintainer-clean |
+| | check | $(outdir)/check (not implemented for you) |
+| | dist | $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz (not .PHONY) |
+
+You are responsible for implementing the `$(outdir)/check` target in
+each of your Makefiles.
+
+Telling automake about your program
+-----------------------------------
+
+You tell automake what to do for you by setting some variables. They
+are all prefixed with `am_`; this prefix may be changed by editing the
+`_am` variable at the top of `automake.head.mk`.
+
+There are several commands that generate files; simply record the list
+of files that each command generates as the following variable
+variables:
+
+| Variable | Create Command | Delete Command | Description | Relative to |
+|--------------+----------------+-----------------------------+-----------------------------------+-------------|
+| am_src_files | emacs | rm -rf . | Files that the developer writes | srcdir |
+| am_gen_files | ??? | make maintainer-clean | Files the developer compiles | srcdir |
+| am_cfg_files | ./configure | make distclean | Users' compile-time configuration | outdir |
+| am_out_files | make all | make mostlyclean/make clean | Files the user compiles | outdir |
+| am_sys_files | make install | make uninstall | Files the user installs | DESTDIR |
+
+In addition, there are two more variables that control not how files
+are created, but how they are deleted:
+
+| Variable | Affected command | Description | Relative to |
+|----------------+------------------+------------------------------------------------+-------------|
+| am_clean_files | make clean | A list of things to `rm` in addition to the | outdir |
+| | | files in `$(am_out_files)`. (Example: `*.o`) | |
+|----------------+------------------+------------------------------------------------+-------------|
+| am_slow_files | make mostlyclean | A list of things that (as an exception) should | outdir |
+| | | _not_ be deleted. (otherwise, `mostlyclean` | |
+| | | is the same as `clean`) | |
+
+Finally, there are two variables that express the relationships
+between directories:
+
+| Variable | Description |
+|------------+---------------------------------------------------------|
+| am_subdirs | A list of other directories (containing Makefiles) that |
+| | may be considered "children" of this |
+| | directory/Makefile; building a phony target in this |
+| | directory should also build it in the subdirectory. |
+| | They are not necesarily actually subdirectories of this |
+| | directory in the filesystem. |
+|------------+---------------------------------------------------------|
+| am_depdirs | A list of other directories (containing Makefiles) that |
+| | contain or generate files that are dependencies of |
+| | targets in this directory. They are not necesarily |
+| | actually subdirectories of this directory in the |
+| | filesystem. Except for files that are dependencies of |
+| | files in this directory, things in the dependency |
+| | directory will not be built. |
+
+----
+Copyright (C) 2016 Luke Shumaker
+
+This documentation file is placed into the public domain. If that is
+not possible in your legal system, I grant you permission to use it in
+absolutely every way that I can legally do so.
diff --git a/common.bottom.mk b/common.bottom.mk
deleted file mode 100644
index e8b5493..0000000
--- a/common.bottom.mk
+++ /dev/null
@@ -1,136 +0,0 @@
-# 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 $(topsrcdir)/common.each.mk
-
-
-# Aggregate variables
-
-# Add some more defaults to the *_files variables
-clean_files += $(out_files)
-conf_files += Makefile $(topoutdir)/config.mk
-# Now namespace the *_files variables
-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),)
-$(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 _am_nl
-
-
-endef
-define _am_include_makefile
-ifeq ($(filter $(abspath $1),$(included_makefiles)),)
-include $(if $(call _am_is_subdir,.,$1),$(call _am_relto,.,$1),$(topoutdir)/$(call _am_relto,$(topoutdir),$1))
-endif
-endef
-$(eval \
- _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 ($(_am_NO_ONCE),)
-# Empty module-level variables
-outdir = /bogus
-srcdir = /bogus
-subdirs =
-depdirs =
-src_files =
-out_files =
-sys_files =
-clean_files =
-slow_files =
-conf_files =
-dist_files =
-
-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): $(_am_%(module)_out_files)
-install-%(module): $(_am_%(module)_sys_files)
-# Destructive phony targets
-_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 _am_module_rules))))
-
-# Alias each bare phony target to itself with the `-all` suffix
-$(foreach t,$(_am_phony),$(eval $t: $t-all))
-
-# Add the `dist` target
-.PHONY: dist
-dist: $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz
-$(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz: $(topoutdir)/$(PACKAGE)-$(VERSION)
- $(TAR) czf $@ -C $(<D) $(<F)
-_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 _am_addfile,$(topsrcdir),$(@D)/tmp.$(@F).$$$$,$f) &&) \
- $(MV) $(@D)/tmp.$(@F).$$$$ $@ || $(RM) -r $(@D)/tmp.$(@F).$$$$
-
-include $(topsrcdir)/common.once.mk
-
-endif
diff --git a/common.each.head.mk b/common.each.head.mk
new file mode 100644
index 0000000..596e4f0
--- /dev/null
+++ b/common.each.head.mk
@@ -0,0 +1,16 @@
+# Copyright (C) 2016 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/>.
+
+makefiles =
diff --git a/common.each.mk b/common.each.tail.mk
index 76c37b5..d649602 100644
--- a/common.each.mk
+++ b/common.each.tail.mk
@@ -15,7 +15,7 @@
dirs := $(dirs)
-clean_files += .*.mk *.o
+am_clean_files += .*.mk *.o
ifneq ($(AUTODEPS),)
-include $(wildcard $(outdir)/.*.mk)
endif
@@ -33,3 +33,10 @@ $(outdir)/%.o : $(srcdir)/%.c $(topoutdir)/config.mk
$(outdir)/% : $(outdir)/%.o
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+
+ifneq ($(srcdir),$(outdir))
+$(addprefix $(outdir)/,$(makefiles)): $(outdir)/%: $(srcdir)/%
+ cp -Tf -- $< $@
+endif
+am_src_files += $(makefiles)
+am_cfg_files += $(makefiles)
diff --git a/common.once.mk b/common.once.head.mk
index b929c53..d50c639 100644
--- a/common.once.mk
+++ b/common.once.head.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2015 Luke Shumaker
+# Copyright (C) 2015-2016 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
@@ -13,10 +13,9 @@
# 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/>.
-# Make directories
-dirs += $(addprefix $(DESTDIR),$(bindir) $(libexedir) $(datarootdir) $(datadir) $(sysconfdir) $(sharedstatedir) $(localstatedir) $(runstatedir) $(pkgdatadir) $(pkglibexecdir))
-$(sort $(dirs)):
- $(MKDIRS) $@
+MAKEFLAGS += -rR
+.SECONDARY:
+.DELETE_ON_ERROR:
# Have GCC generate header dependency info (pair this with `-include`
# in common.each.mk
@@ -25,8 +24,4 @@ CFLAGS += -MD -MF $(patsubst $(@D)/%.o,$(@D)/.%.mk,$@) -MP
endif
CPPFLAGS += -I$(topoutdir)
-M4FLAGS += -I$(topoutdir)
-
-MAKEFLAGS += -rR
-.SECONDARY:
-.DELETE_ON_ERROR:
+M4FLAGS += -I$(topoutdir) -I$(<D) -I$(@D)
diff --git a/common.once.tail.mk b/common.once.tail.mk
new file mode 100644
index 0000000..f326c6b
--- /dev/null
+++ b/common.once.tail.mk
@@ -0,0 +1,19 @@
+# Copyright (C) 2015-2016 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/>.
+
+# Make directories
+dirs += $(addprefix $(DESTDIR),$(bindir) $(libexedir) $(datarootdir) $(datadir) $(sysconfdir) $(sharedstatedir) $(localstatedir) $(runstatedir) $(pkgdatadir) $(pkglibexecdir))
+$(sort $(dirs)):
+ $(MKDIRS) $@
diff --git a/common.top.mk b/common.top.mk
deleted file mode 100644
index 9e57088..0000000
--- a/common.top.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-# 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/>.
-
-# Both of these have the argument order "parent,child"
-_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 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
- 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 $(outdir)/Makefile)
-
-## Set module name
-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 =
-out_files =
-sys_files =
-
-clean_files =
-
-slow_files =
-conf_files =
-dist_files =
diff --git a/config.mk b/config.mk.in
index a64243b..ca8fa7f 100644
--- a/config.mk
+++ b/config.mk.in
@@ -1,6 +1,5 @@
ifeq ($(topsrcdir),)
topsrcdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
-endif
PACKAGE = rvs
VERSION = 0.10
@@ -44,3 +43,5 @@ TRUE = true
PRINTF = printf
AUTODEPS = t
+
+endif
diff --git a/configure b/configure
index b4dece3..9683b68 100755
--- a/configure
+++ b/configure
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
-name='configure' # Luke's configureation script
+name='configure' # Luke's configuration script
#version='1.0'
-# Copyright (C) 2009 Luke Shumaker
+# Copyright (C) 2009, 2016 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
@@ -17,83 +17,47 @@ name='configure' # Luke's configureation script
# along with this program; see the file COPYING.
# If not, see <http://www.gnu.org/licenses>.
-srcdir=$(readlink -f `dirname "$0"`)
-
- _DESTDIR=''
- _prefix='/usr/local'
-_exec_prefix='$(prefix)'
- _bindir='$(exec_prefix)/bin'
- _sbindir='$(exec_prefix)/sbin'
- _libexecdir='$(exec_prefix)/libexec'
- _CONFIG="$@"
-vars='DESTDIR prefix exec_prefix bindir sbindir libexecdir CONFIG'
-if [ -f "$srcdir/config" ]; then . "$srcdir/config"; fi
+srcdir="$(dirname -- "$0")"
+outdir="."
error() {
- echo "$name: $1" >> /dev/stderr
+ echo "$name: $1" >&2
exit 1
}
-varargs=`echo "$vars " | sed -e 's/ */:,/g' -e 's/,$//'`
-args=`getopt -n "$name" -o "${sopt}" -l "${lopt}${varargs}" -- "$@"`
-if [ $? == 0 ]; then
- set -- $args
- while [ $# -gt 0 ]; do case "$1" in
+edit=(sed -E -e '')
+setvar() {
+ edit+=(-e "s@^(\s*$1\s*:?=).*@\1 $2@")
+}
+setvar topsrcdir "$srcdir"
+
+vars=($(<"$srcdir/config.mk.in" sed -n 's/^\([ a-z_-]*\)=.*/\1/p'))
+
+printf -v lopt '%s:,' "${vars[@]}"
+lopt+='enable-autodeps,disable-autodeps'
+
+sopt=''
+
+args=$(getopt -n "$name" -o "${sopt}" -l "${lopt}" -- "$@") || exit $?
+eval set -- "$args"
+while [ $# -gt 0 ]; do
+ case "$1" in
--) break;;
- --srcdir) srcdir="$2"; shift;;
- --*)
- var0="${1/--/}"
- match='false'
- for var1 in $vars; do
- if [ "$var0" == "$var1" ]; then
- match='true'
- break;
- fi
- done
- if [ "$match" == 'true' ]; then
- shift
- val="$1"
- eval _$var0=$val
- else
- error "unrecognized option \`$1'";
- fi
- :;;
+ --enable-autodeps) setvar AUTODEPS t;;
+ --disable-autodeps) setvar AUTODEPS '';;
+ --*) setvar "${1#--}" "$2" shift;;
*) error "unrecognized option \`$1'";
esac
shift
- done
-else
- error 'unable to parse command line arguments'
-fi
-
-echo '#!/bin/sed -f' > var.sed
-for var in $vars; do
- var1="_$var"
- val=${!var1}
-
- # GNU bash optimized version
- var=${var//:/\\:}
- val=${val//:/\\:}
- # POSIX version
- #var=`echo "$var" | sed 's@:@\\:@g'`
- #val=`echo "$val" | sed 's@:@\\:@g'`
-
- echo "s:@$var@:$val:g" >> var.sed
done
-Makefiles="`find "$srcdir/" -type f -name 'Makefile.in'`"
-Makefiles="`find "$srcdir/" -type f -name '*.mk.in'` $Makefiles"
-for orig in $Makefiles; do
- new=${orig/%.in/} #bashism
- new=${new/#$srcdir\//} #bashism
- path=`dirname "$orig"`
- mkdir -p `dirname "$new"`
- sed -f var.sed "${orig}" | sed \
--e "s:@srcdir@:${path//:/\\:}/:g" \
--e '19 a# DO NOT edit this file, it has been generated by configure, and will' \
--e "19 a# be overwritten. Instead, edit the file \``basename ${orig}`'" \
--e "19 a
- " > "${new}"
-done
-rm var.sed
+"${edit[@]}" < "$srcdir/config.mk.in" > "$outdir/config.mk"
+Makefiles=($(find "$srcdir/" -name 'Makefile') "$srcdir"/*.mk "$srcdir"/modules/module.mk "$srcdir"/modules/*/Makefile.inc.mk)
+for src in "${Makefiles[@]}"; do
+ out="$outdir/${src#$srcdir/}"
+ mkdir -p -- $(dirname -- "$out")
+ if ! test "$src" -ef "$out"; then
+ cp -fTv -- "$src" "$out"
+ fi
+done
diff --git a/modules/Makefile b/modules/Makefile
index 8235bf3..d9de6c0 100644
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -15,10 +15,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
include $(dir $(lastword $(MAKEFILE_LIST)))/../config.mk
-include $(topsrcdir)/common.top.mk
+include $(topsrcdir)/automake.head.mk
dirs += $(DESTDIR)$(pkglibexecdir)/modules
-src_files += Makefile module.mk
-subdirs = comments date.author blobs tags tree
+makefiles = Makefile module.mk
+am_subdirs = comments date.author blobs tags tree
-include $(topsrcdir)/common.bottom.mk
+include $(topsrcdir)/automake.tail.mk
diff --git a/modules/blobs/Makefile.inc.mk b/modules/blobs/Makefile.inc.mk
index 8fd2d6f..9f3f112 100644
--- a/modules/blobs/Makefile.inc.mk
+++ b/modules/blobs/Makefile.inc.mk
@@ -1,8 +1,8 @@
-src_files += commit.d.sh commit.f.sh commit.sh get.d.sh get.f.sh get.sh ls.sh print.sh tree.sh
-out_files += commit.d commit.f commit get.d get.f get ls print tree
+am_src_files += commit.d.sh commit.f.sh commit.sh get.d.sh get.f.sh get.sh ls.sh print.sh tree.sh
+am_out_files += commit.d commit.f commit get.d get.f get ls print tree
-src_files += _stdio.sh
-sys_files += $(pkglibexecdir)/modules/$(name)/_stdio.sh
+am_src_files += _stdio.sh
+am_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/modules/comments/Makefile.inc.mk b/modules/comments/Makefile.inc.mk
index 6816836..d5632d7 100644
--- a/modules/comments/Makefile.inc.mk
+++ b/modules/comments/Makefile.inc.mk
@@ -1,2 +1,2 @@
-src_files += comment.sh commit.sh print.sh showcomment.sh
-out_files += comment commit print showcomment
+am_src_files += comment.sh commit.sh print.sh showcomment.sh
+sm_out_files += comment commit print showcomment
diff --git a/modules/date.author/Makefile.inc.mk b/modules/date.author/Makefile.inc.mk
index c6b27a2..ac9d0df 100644
--- a/modules/date.author/Makefile.inc.mk
+++ b/modules/date.author/Makefile.inc.mk
@@ -1,2 +1,2 @@
-src_files += commit.sh
-out_files += commit
+am_src_files += commit.sh
+am_out_files += commit
diff --git a/modules/git-fast-import/.#parse.sh b/modules/git-fast-import/.#parse.sh
deleted file mode 120000
index c2c97da..0000000
--- a/modules/git-fast-import/.#parse.sh
+++ /dev/null
@@ -1 +0,0 @@
-luke@build64-par.lan.670:1436421582 \ No newline at end of file
diff --git a/modules/module.mk b/modules/module.mk
index d3d3da2..b2dbde8 100644
--- a/modules/module.mk
+++ b/modules/module.mk
@@ -15,15 +15,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk
-include $(topsrcdir)/common.top.mk
+include $(topsrcdir)/automake.head.mk
name := $(lastword $(subst /, ,$(abspath $(srcdir))))
include $(srcdir)/Makefile.inc.mk
+makefiles = Makefile 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))
+am_src_files += Module.mk
+am_sys_files += $(pkglibexecdir)/modules/$(name).mk
+am_sys_files += $(addprefix $(pkglibexecdir)/modules/$(name)/,$(am_out_files))
$(DESTDIR)$(pkglibexecdir)/modules/$(name).mk: $(srcdir)/Module.mk | $(DESTDIR)$(pkglibexecdir)/modules
$(INSTALL_DATA) $< $@
@@ -32,4 +33,4 @@ $(DESTDIR)$(pkglibexecdir)/modules/$(name)/%: $(srcdir)/% | $(DESTDIR)$(pkglibex
$(DESTDIR)$(pkglibexecdir)/modules/$(name)/%: $(outdir)/% | $(DESTDIR)$(pkglibexecdir)/modules/$(name)
$(INSTALL_PROGRAM) $< $@
-include $(topsrcdir)/common.bottom.mk
+include $(topsrcdir)/automake.tail.mk
diff --git a/modules/tags/Makefile.inc.mk b/modules/tags/Makefile.inc.mk
index 8d687a5..1ccdada 100644
--- a/modules/tags/Makefile.inc.mk
+++ b/modules/tags/Makefile.inc.mk
@@ -1,2 +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
+am_src_files += commit.sh get-tag.sh print.sh tag-id.sh tag.sh
+am_out_files += commit get-tag print tag-id tag
diff --git a/modules/tree/Makefile.inc.mk b/modules/tree/Makefile.inc.mk
index 82c0b58..c91bef2 100644
--- a/modules/tree/Makefile.inc.mk
+++ b/modules/tree/Makefile.inc.mk
@@ -1,2 +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
+am_src_files += addparent.d.sh addparent.f.sh addparent.sh commit.sh delparent.f.sh getchildren.sh getparents.sh print.sh
+am_out_files += addparent.d addparent.f addparent commit delparent.f getchildren getparents print
diff --git a/wrapper/Makefile b/wrapper/Makefile
index 22e9f46..65a6613 100644
--- a/wrapper/Makefile
+++ b/wrapper/Makefile
@@ -15,15 +15,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
include $(dir $(lastword $(MAKEFILE_LIST)))/../config.mk
-include $(topsrcdir)/common.top.mk
+include $(topsrcdir)/automake.head.mk
-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
+makefiles = Makefile
+am_src_files += outer.c inner.sh.m4 runcmd.mk
+am_out_files += outer inner
+am_clean_files += inner.sh
+am_sys_files += $(bindir)/$(PACKAGE) $(pkglibexecdir)/$(PACKAGE) $(pkglibexecdir)/runcmd.mk
$(outdir)/outer.o: $(topoutdir)/config.h
-$(outdir)/inner: $(topoutdir)/config.sh
+$(outdir)/inner.sh: $(topoutdir)/config.sh
$(DESTDIR)$(bindir)/$(PACKAGE) : $(outdir)/outer | $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) $< $@
@@ -32,4 +33,4 @@ $(DESTDIR)$(pkglibexecdir)/$(PACKAGE) : $(outdir)/inner | $(DESTDIR)$(pkglibexec
$(DESTDIR)$(pkglibexecdir)/runcmd.mk : $(srcdir)/runcmd.mk | $(DESTDIR)$(pkglibexecdir)
$(INSTALL_PROGRAM) $< $@
-include $(topsrcdir)/common.bottom.mk
+include $(topsrcdir)/automake.tail.mk