From 099638eb844d4da0ffba1c238ed3904d90a622bc Mon Sep 17 00:00:00 2001 From: Matt McCutchen Date: Wed, 13 Jun 2007 16:08:32 -0400 Subject: [PATCH] Rename Mage to mgear, a less common and thus less confusable name. --- demo/Makefile | 4 +-- demo/Makefile.plain | 2 -- experiments/bigint-mage-Makefile | 2 +- experiments/genrecord | 2 +- mage.mk => mgear.mk | 50 ++++++++++++++++---------------- testsuite | 32 ++++++++++---------- 6 files changed, 45 insertions(+), 47 deletions(-) rename mage.mk => mgear.mk (87%) diff --git a/demo/Makefile b/demo/Makefile index b8a7ab7..75eaf85 100644 --- a/demo/Makefile +++ b/demo/Makefile @@ -1,6 +1,6 @@ -# Very simple Mage example +# Very simple mgear example -include mage.mk +include mgear.mk .SECONDARY: diff --git a/demo/Makefile.plain b/demo/Makefile.plain index 75cdb7a..d9971b5 100644 --- a/demo/Makefile.plain +++ b/demo/Makefile.plain @@ -1,5 +1,3 @@ -# Very simple Mage example - .SECONDARY: foo.x.h: diff --git a/experiments/bigint-mage-Makefile b/experiments/bigint-mage-Makefile index d012c7e..8cdb964 100644 --- a/experiments/bigint-mage-Makefile +++ b/experiments/bigint-mage-Makefile @@ -2,7 +2,7 @@ # Matt McCutchen's Big Integer Library # -include mage.mk +include mgear.mk # Mention default target. all : diff --git a/experiments/genrecord b/experiments/genrecord index 9d86947..295c491 100755 --- a/experiments/genrecord +++ b/experiments/genrecord @@ -1,6 +1,6 @@ #!/usr/bin/perl # FIX: Should use perl from path -# genrecord: make a Mage genfile +# genrecord: make an mgear genfile # { gcc prog.c -o prog.tmp; echo $?; } 2>&1 | genrecord prog 'gcc prog.c -o prog.tmp' sub mqas($) { diff --git a/mage.mk b/mgear.mk similarity index 87% rename from mage.mk rename to mgear.mk index d9ad5d7..22465ce 100644 --- 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) diff --git a/testsuite b/testsuite index 3329a66..210274e 100755 --- a/testsuite +++ b/testsuite @@ -1,7 +1,7 @@ #!/bin/bash -# Test suite for Mage. +# Test suite for mgear. -echo "Test suite for Mage" +echo "Test suite for mgear" cd "$(dirname "$0")" Z=test-zone @@ -18,7 +18,7 @@ section=Initialization trap 'echo; echo "TEST SUITE FAILED in section $section!" >&2' ERR #set -x -ln -s ../mage.mk mage.mk +ln -s ../mgear.mk . function fail { false @@ -30,9 +30,9 @@ function start_section { echo "SECTION: $1" } -function do_mage { +function do_mgear { echo "Running: make $*" - make "$@" 2>&1 | tee mage.log + make "$@" 2>&1 | tee mgear.log } function assert_contents { @@ -46,20 +46,20 @@ function assert_contents { # Options can be passed to grep: assert_saw -i override function assert_saw { - if grep -q "$@" mage.log; then + if grep -q "$@" mgear.log; then echo "Good, saw '${@:$#}' in build log." else echo "Expected '${@:$#}' in build log but didn't see it! Log:" - cat mage.log + cat mgear.log fail fi } function assert_not_saw { - if ! grep -q "$@" mage.log; then + if ! grep -q "$@" mgear.log; then echo "Good, saw '${@:$#}' in build log." else echo "Did not expect '${@:$#}' in build log but saw it! Log:" - cat mage.log + cat mgear.log fail fi } @@ -105,7 +105,7 @@ function assert_not_touched { # Tests an implicit rule and two competing explicit rules. # Watch those dollar signs! cat >Makefile <<'EOF' -include mage.mk +include mgear.mk .SECONDARY: include hc-rule.mk $(call mg-define-rule,%,%.ssc,sleep 1 && grep 'warn' $$< && sed -e 's_//.*$$$$__' $$< >$$t) @@ -136,7 +136,7 @@ EOF # Run and make sure the files were compiled correctly. start_section "Initial full build" -do_mage foo bar index +do_mgear foo bar index assert_contents foo <<'EOF' This is the foo file. @@ -166,7 +166,7 @@ assert_saw sort index.in >index.tmp # to bar.g accidentally being too old. start_section "Replay bar warning" -do_mage foo bar index +do_mgear foo bar index assert_uptodate foo assert_uptodate bar @@ -179,7 +179,7 @@ assert_not_saw -i overrid start_section "Override bar" sleep 1 # No racy cleanliness echo NEWCONTENT >bar -do_mage bar +do_mgear bar assert_saw -i overrid assert_contents bar <<>foo.hc -do_mage index foo +do_mgear index foo assert_uptodate index assert_generated foo @@ -208,7 +208,7 @@ start_section "Command change for % <- %.hc" cat >hc-rule.mk <<'EOF' $(call mg-define-rule,%,%.hc,sed -e 's_ *#.*$$$$__' $$< >$$t) EOF -do_mage foo +do_mgear foo assert_generated foo assert_contents foo <<'EOF' @@ -226,7 +226,7 @@ start_section "Inconsequential change to foo.hc" sleep 1 # No racy cleanliness remember_mtime foo foo.g sed -e '$s/look: /look:/' -i foo.hc -do_mage foo +do_mgear foo assert_generated foo assert_touched foo.g -- 2.34.1