Move some configuration from main.mk to config.mk

When dumping make configuration (dump-many-var, dump-var-*), we only
load config.mk, not main.mk. One of the first things that main.mk does
is to include config.mk, so these moves are safe.

Turning off the implicit rules and other make configuration / sanity
checks should happen in all cases, so move them to config.mk

Move dont_bother_rules to config.mk so that it can be used by the ninja
configuration (which is moving in a later change). Move dont_bother into
the kati section, since it's not used elsewhere.

Test: m clean
Test: get_build_var dont_bother_goals
Change-Id: Ib3ec8aa8eebcaf743d2cdcc31f89827c4e8470a1
diff --git a/core/config.mk b/core/config.mk
index 3119281..fa8c582 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -31,6 +31,37 @@
 backslash := \a
 backslash := $(patsubst %a,%,$(backslash))
 
+# this turns off the suffix rules built into make
+.SUFFIXES:
+
+# this turns off the RCS / SCCS implicit rules of GNU Make
+% : RCS/%,v
+% : RCS/%
+% : %,v
+% : s.%
+% : SCCS/s.%
+
+# If a rule fails, delete $@.
+.DELETE_ON_ERROR:
+
+# Check for broken versions of make.
+ifndef KATI
+ifneq (1,$(strip $(shell expr $(MAKE_VERSION) \>= 3.81)))
+$(warning ********************************************************************************)
+$(warning *  You are using version $(MAKE_VERSION) of make.)
+$(warning *  Android can only be built by versions 3.81 and higher.)
+$(warning *  see https://source.android.com/source/download.html)
+$(warning ********************************************************************************)
+$(error stopping)
+endif
+endif
+
+# Used to force goals to build.  Only use for conditionally defined goals.
+.PHONY: FORCE
+FORCE:
+
+ORIGINAL_MAKECMDGOALS := $(MAKECMDGOALS)
+
 # Tell python not to spam the source tree with .pyc files.  This
 # only has an effect on python 2.6 and above.
 export PYTHONDONTWRITEBYTECODE := 1
@@ -811,4 +842,21 @@
     $(filter $(ANDROID_WARNING_ALLOWED_PROJECTS),$(1)/)
 endef
 
+# These goals don't need to collect and include Android.mks/CleanSpec.mks
+# in the source tree.
+dont_bother_goals := clean clobber dataclean installclean \
+    help out \
+    snod systemimage-nodeps \
+    stnod systemtarball-nodeps \
+    userdataimage-nodeps userdatatarball-nodeps \
+    cacheimage-nodeps \
+    bptimage-nodeps \
+    vendorimage-nodeps \
+    systemotherimage-nodeps \
+    ramdisk-nodeps \
+    bootimage-nodeps \
+    recoveryimage-nodeps \
+    vbmetaimage-nodeps \
+    product-graph dump-products
+
 include $(BUILD_SYSTEM)/dumpvar.mk