+# Compile any source-to-source languages before executing the majority of make
+define PREMAKE_SOURCE_COMPILER =
+# Find the sources for each source-to-source language
+$(foreach slang,$(SLANGS),
+$(eval SLANG_SRC := $(patsubst ./%,%,$(shell find -name "*.$(slang)")))
+# Foreach target type in the source-to-source language, add this source's
+# targets to the list of the current source-to-source language targets
+$(foreach trg,$($(slang)_TRG),
+$(eval SLANG_TRG += $(SLANG_SRC:%.$(slang)=%.$($(slang)_STEM:%=%.)$(trg))))
+# Stat the source file's last-modified time to the var SRC_TIME
+$(foreach src,$(SLANG_SRC),
+$(eval SRC_TIME := $(shell stat -c %Y $(src)))
+# For each of the targets created by this source language, evaluate the
+# last-modified times of each potential target. If the file does not exist, set
+# the time to '0', otherwise set it to the -c %Y result from statting the file.
+$(foreach srctrg,$(filter $(basename $(src))%, $(SLANG_TRG)),
+$(eval TRG_TIMES += $(if $(wildcard $(srctrg)),$(shell stat -c %Y $(srctrg)),0)==$(srctrg)))
+# Sort TRG_TIMES, which will produce a list of oldest-first files and timestamps
+# of the form [last-modified-deltatime]==[filename]
+$(eval TRG_TIMES := $(shell echo $(sort $(TRG_TIMES)) | $(call AWK_REVERSE_SQUASH)))
+# Evaluate the newest time from our ordered list by splitting the word up by its
+# '==' connectors and looking at the first word
+$(eval NEWEST_TRG_TIME := $(word 1,$(subst ==, ,$(TRG_TIMES))))
+# Find the older of the two times (between SRC_TIME and NEWEST_TRG_TIME)
+$(eval OLDER_TIME := $(firstword $(sort $(NEWEST_TRG_TIME) $(SRC_TIME))))
+# If the older of the two times is the newest target time found, then we need to
+# rebuild, but only if our build rule intends to actually make something
+$(if $(MAKECMDGOALS),
+$(eval BUILDGOALS := $(filter-out clean scrub purge uninstall,$(MAKECMDGOALS))),
+$(eval BUILDGOALS := all))
+$(if $(and $(BUILDGOALS),$(filter $(OLDER_TIME),$(NEWEST_TRG_TIME))),
+$(eval SHELL_CMD := cd $(dir $(src)) && $($(slang)_C) $($(slang)_FLAGS) $(notdir $(src)))
+$(info $(SHELL_CMD) $(shell $(SHELL_CMD)))
+)
+# Put these targets on the MAKE_TARGETS list to be removed during "clean",
+# regardless of whether or not they were built just now.
+$(eval MAKE_TARGETS += $(SLANG_TRG))
+))
+endef
+# Compile a source language to a language that compiles to binary, but only if
+# our build rule intends to build some kind of target
+$(eval $(call PREMAKE_SOURCE_COMPILER,))
+
+
+# Backup the CVS password and CVSROOT environment vars in case we change them
+$(if $(wildcard ~/.cvspass),\
+$(eval CVSPASS_BAK := $(file <~/.cvspass)))
+$(if $(CVSROOT),\
+$(eval CVSROOT_BAK := $(CVSROOT)))
+
+# A long function definition to grab deps from the source's compiler and route
+# errors to /dev/null if the rule generator expresses bogus errors
+define SRC_LANG_FLAGS_OPT_DEPS =
+$(filter-out \ %:,$(shell $($2_C) $3 $4 -MG $1 2> /dev/null))
+endef
+