Rename Mage to mgear, a less common and thus less confusable name.
[mgear/mgear.git] / mgear.mk
similarity index 87%
rename from mage.mk
rename to mgear.mk
index d9ad5d7..22465ce 100644 (file)
--- a/mage.mk
+++ b/mgear.mk
@@ -1,8 +1,8 @@
-# Mage Build Tool by Matt McCutchen
-# http://www.kepreon.com/~matt/mage/
+# Mgear Build Tool by Matt McCutchen
+# http://www.kepreon.com/~matt/mgear/
 
 
-# Remember the original default goal so we can restore it at the end of mage.mk.
+# Remember the original default goal so we can restore it at the end of mgear.mk.
 mg-orig-default-goal:=$(.DEFAULT_GOAL)
 
 # We use second-expansion heavily to dynamically compute prerequisites when they
@@ -38,7 +38,7 @@ fmt-make-assignment=$1:=$$(empty)$(call mqas,$2)
 
 # TARGET OBFUSCATION
 
-# Mage uses two kinds of "obfuscated targets" (those that are not the simple
+# Mgear uses two kinds of "obfuscated targets" (those that are not the simple
 # names of real files):
 # - An always-exists target like /.//. is used as a prerequisite of an implicit
 #   rule.  Since it exists, make doesn't second-expand its own prerequisites
@@ -86,7 +86,7 @@ $(opfx)%: $$(empty) $$($$(oid)@opr)
 # information about how bar was generated, including the command (for rebuild on
 # command change) and the warnings (for replay).
 #
-# - bar.g's mtime is the last time Mage verified that bar was up to date.  bar
+# - bar.g's mtime is the last time mgear verified that bar was up to date.  bar
 # needs to be regenerated iff a prerequisite is newer than *bar.g* (not bar).
 # If a prerequisite changes but the command gives the same contents for bar,
 # bar.g is touched but bar itself is not touched because files that depend on it
@@ -95,13 +95,13 @@ $(opfx)%: $$(empty) $$($$(oid)@opr)
 # - If bar is newer than bar.g, the user has overridden it, and we should leave
 # the override in place but warn the user about it.
 #
-# - The user's Makefile defines Mage rules by calling mg-define-rule.  Each Mage
-# rule becomes one underlying make rule with the same target and a little extra
-# magic.  This is important so that all implicit rule competition takes place at
-# the same target.  Additionally, the prerequisites are passed to an obfuscated
-# target for bar.g to see if any are newer than bar.g.  This is done by the
-# single obfuscated implicit rule, keeping the number of implicit rules low.
-# Then the command script for bar checks for overrides, command change,
+# - The user's Makefile defines mgear rules by calling mg-define-rule.  Each
+# mgear rule becomes one underlying make rule with the same target and a little
+# extra magic.  This is important so that all implicit rule competition takes
+# place at the same target.  Additionally, the prerequisites are passed to an
+# obfuscated target for bar.g to see if any are newer than bar.g.  This is done
+# by the single obfuscated implicit rule, keeping the number of implicit rules
+# low. Then the command script for bar checks for overrides, command change,
 # prerequisite change, etc. and acts accordingly.
 #
 # Target metadata variables for bar: (* means stored in bar.g)
@@ -117,7 +117,7 @@ $(opfx)%: $$(empty) $$($$(oid)@opr)
 #     exists and empty for doesn't exist.  Later perhaps x will be the mtime.*
 #
 # bar@gloaded:=1
-#     Set if Mage has loaded bar.g and hasn't changed it since then.
+#     Set if mgear has loaded bar.g and hasn't changed it since then.
 #
 # bar@gdeps:=foo
 #     Static dependencies of bar, for checking by bar.g.
@@ -126,19 +126,19 @@ $(opfx)%: $$(empty) $$($$(oid)@opr)
 #     $? from the rule for bar.g; used by the rule for bar.
 #
 # bar@checked:=1
-#     Set when Mage determines that a file is up to date or depends on it being
+#     Set when mgear determines that a file is up to date or depends on it being
 #     so determined.  Used to decide which prerequisite to check next for a
 #     dependency-logging command.
 #
 # bar@dlc-ran:=1
-#     Indicates that Mage is in the middle of building bar using a dependency-
+#     Indicates that mgear is in the middle of building bar using a dependency-
 #     logging command.  Means that bar.g.tmp, not bar.g, is the most current
 #     genfile.
 #
 ## If the rule for bar is overridden, we clear the information from bar.g so
 ## that it is as if bar.g didn't exist. -- Not currently needed
 #
-# Some make features with which Mage's compatibility has not been investigated:
+# Some make features with which mgear's compatibility has not been investigated:
 # - Command-line options (especially --dry-run, --question, --touch,
 #   --always-make, --keep-going, --jobs, --assume-old, and --assume-new)
 # - Static pattern rules
@@ -164,7 +164,7 @@ mg-scout-oid:=$(newoid)
 $(mg-genfile-oid)@opr=$($(otgt:.g=)@gdeps) $(if $(wildcard $(otgt:.g=)),$(mg-scout-oid)$(aname)$(otgt:.g=),)
 $(mg-genfile-oid)@ocmd=$(eval $(otgt:.g=)@gq:=$?)
 
-# Mage-ized automatic variables.
+# Mgear-ized automatic variables.
 # $@: needs no translation
 # NOTE: $(mg@) is *eventual* target.  Commands must write to temp file, $t .
 # $%: haven't thought about it much, but probably needs no translation
@@ -176,7 +176,7 @@ mg+ = $(filter-out MG-% $(opfx)%,$+)
 # $*: needs no translation
 
 # $(call mg-translate-cmd,cat $$< >$$t)
-# Replaces references to automatic variables with references to their Mage-ized
+# Replaces references to automatic variables with references to their mgear-ized
 # counterparts.  There might be false matches, e.g., $$@ => $$(mg@) ;
 # to prevent that, write $$$(empty)@ instead.  (c.f. autoconf empty quadrigraph)
 mg-translate-cmd=$(subst $$t,$$@.tmp,$(subst $$?,$$(mg?),$(subst $$<,$$(mg<),$(subst $$^,$$(mg^),$(subst $$+,$$(mg+),$1)))))
@@ -200,7 +200,7 @@ MG-FORCE:
 
 # $(call mg-define-rule,target,prerequisites,cmd)
 # Defines a rule.  cmd is expanded again when it is run, at which time
-# Mage-ized automatic variables are available.
+# Mgear-ized automatic variables are available.
 #
 # I eradicated the target-specific variables because they fail when there are
 # multiple implicit rules with the same target pattern.
@@ -240,7 +240,7 @@ endef
 # HMMM .tmp in displayed command looks ugly
 define mg-rule-cmd
        $(if $(filter $(mg-scout-oid)$(aname)$@,$($@@gq)),\
-               $(info Mage: warning: Manually created/modified file at $@ overrides rule.)\
+               $(info mgear: warning: Manually created/modified file at $@ overrides rule.)\
        ,$(call gload,$@)$(if $($@@gq)$(if $(wildcard $@),,TARGET-DNE)$(mg-check-cmd),\
                $(eval $@@gloaded:=)$(info $1)\
                @trap 'rm -f $@.tmp $@.g.tmp' EXIT &&\
@@ -250,7 +250,7 @@ define mg-rule-cmd
                $(mg-maybe-move-target) &&\
                mv -f $@.g.tmp $@.g\
        ,$(if $($@@warnings),\
-               $(info $($@@cmd) # Mage warning replay$(nl)$($@@warnings))\
+               $(info $($@@cmd) # mgear warning replay$(nl)$($@@warnings))\
        )))
 endef
 
@@ -259,16 +259,16 @@ mg-check-cmd=$(if $(call streq,$1,$($@@cmd)),,COMMAND-CHANGED)
 
 # Pieces of mg-generate that I factored out to make mg-generate more readable.
 mg-assign-cmd=echo $(call sq,$(call fmt-make-assignment,$@@cmd,$1))
-mg-run-cmd={ ($1) 2>&1 && { [ -r $@.tmp ] || { echo 'Mage: error: Command for $@ succeeded without creating it!'; false; }; }; }
+mg-run-cmd={ ($1) 2>&1 && { [ -r $@.tmp ] || { echo 'mgear: error: Command for $@ succeeded without creating it!'; false; }; }; }
 mg-wrap-warnings=sed -re '1s/^/$@@warnings:=$$(empty)/; 1!s/^/$@@warnings+=$$(nl)/'
 # Drat bash's lack of precedence between || and &&.  Extra braces necessary.
 mg-maybe-move-target={ cmp -s $@ $@.tmp || { echo >$@.g && mv -f $@.tmp $@; }; }
 
 # Just add additional prerequisites.  This cannot add prerequisite patterns to
 # an implicit rule, but it can add specific prerequisites to an individual use
-# of an implicit rule.  Currently, Mage picks up the target's prerequisites from
-# make, so this just attaches the given prerequisites to the target, but the
-# implementation might change in the future.
+# of an implicit rule.  Currently, mgear picks up the target's prerequisites
+# from make, so this just attaches the given prerequisites to the target, but
+# the implementation might change in the future.
 mg-define-prereq=$(eval $1: $2)