Issue an error when unknown files are added to ALL_PREBUILT

Change-Id: I72b086ed7a3ad04227ce429f4d367b726d573432
diff --git a/core/legacy_prebuilts.mk b/core/legacy_prebuilts.mk
new file mode 100644
index 0000000..d436ce7
--- /dev/null
+++ b/core/legacy_prebuilts.mk
@@ -0,0 +1,113 @@
+#
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This is the list of modules grandfathered to use ALL_PREBUILT
+
+# DO NOT ADD ANY NEW MODULE TO THIS FILE
+#
+# ALL_PREBUILT modules are hard to control and audit and we don't want
+# to add any new such module in the system
+
+GRANDFATHERED_ALL_PREBUILT := \
+	am \
+	audio.conf \
+	auto_pairing.conf \
+	AVRCP.kl \
+	baseline11k.par \
+	baseline8k.par \
+	baseline.par \
+	basic.ok \
+	bitmap_size.txt \
+	blacklist.conf \
+	bmgr \
+	boolean.g2g \
+	bp.img \
+	brcm_guci_drv \
+	bypassfactory \
+	cacerts.bks \
+	chat-ril \
+	cmu6plus.ok.zip \
+	cpcap-key.kl \
+	data \
+	dbus.conf \
+	dev \
+	egl.cfg \
+	enroll.ok \
+	en-US-ttp.data \
+	firmware_error.565 \
+	firmware_install.565 \
+	ftmipcd \
+	generic11_f.swimdl \
+	generic11.lda \
+	generic11_m.swimdl \
+	generic8_f.swimdl \
+	generic8.lda \
+	generic8_m.swimdl \
+	generic.swiarb \
+	gps.conf \
+	gpsconfig.xml \
+	gps.stingray.so \
+	gralloc.tegra.so \
+	hosts \
+	hwcomposer.tegra.so \
+	ime \
+	init.goldfish.rc \
+	init.goldfish.sh \
+	init.olympus.rc \
+	init.rc \
+	init.stingray.rc \
+	input \
+	input.conf \
+	kernel \
+	libEGL_tegra.so \
+	libGLESv1_CM_tegra.so \
+	libGLESv2_tegra.so \
+	libmdmctrl.a \
+	libmoto_ril.so \
+	libpppd_plugin-ril.so \
+	libril_rds.so \
+	location \
+	location.cfg \
+	main.conf \
+	monkey \
+	network.conf \
+	phone_type_choice.g2g \
+	pm \
+	pppd-ril \
+	pppd-ril.options \
+	proc \
+	qwerty.kl \
+	radio.img \
+	rdl.bin \
+	RFFspeed_501.bmd \
+	RFFstd_501.bmd \
+	savebpver \
+	sbin \
+	suplcerts.bks \
+	svc \
+	sys \
+	system \
+	tcmd \
+	tuttle2.kl \
+	ueventd.goldfish.rc \
+	ueventd.olympus.rc \
+	ueventd.rc \
+	ueventd.stingray.rc \
+	VoiceDialer.g2g \
+	vold.fstab \
+	zoneinfo.dat \
+	zoneinfo.idx \
+	zoneinfo.version
diff --git a/core/main.mk b/core/main.mk
index 428fa76..113bf4b 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -472,7 +472,7 @@
 
 # Before we go and include all of the module makefiles, stash away
 # the PRODUCT_* values so you can't get to them.
-stash_product_vars:=#true
+stash_product_vars:=true
 ifeq ($(stash_product_vars),true)
   $(call stash-product-vars, __STASHED, DO_NOT_USE_IN_ANDROID_MK_)
 endif
@@ -512,6 +512,22 @@
   $(call restore-product-vars, __STASHED)
 endif
 
+include $(BUILD_SYSTEM)/legacy_prebuilts.mk
+ifneq ($(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),)
+  $(warning *** Some files have been added to ALL_PREBUILT.)
+  $(warning *)
+  $(warning * ALL_PREBUILT is a depracated mechanism that)
+  $(warning * should not be used for new files.)
+  $(warning * As an alternative, use PRODUCT_COPY_FILES in)
+  $(warning * the appropriate product definition.)
+  $(warning * build/target/product/core.mk is the product)
+  $(warning * definition used in all products.)
+  $(warning *)
+  $(foreach bad_prebuilt,$(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),$(warning * unexpected $(bad_prebuilt) in ALL_PREBUILT))
+  $(warning *)
+  $(error ALL_PREBUILT contains unexpected files)
+endif
+
 # -------------------------------------------------------------------
 # All module makefiles have been included at this point.
 # -------------------------------------------------------------------