Mark (BUILD_|LOCAL_)COPY_HEADERS as [more] deprecated

We've considered these deprecated for a while, and have reduced where
they may be used, but let's actually throw warnings and call them out
specifically now.

Bug: 130719878
Test: lunch aosp_arm; m nothing   [see no warnings]
Test: lunch aosp_crosshatch; m nothing   [see LOCAL_COPY_HEADERS warnings]
Test: lunch aosp_taimen; m nothing  [see BUILD_COPY_HEADERS warnings]
Change-Id: I8c12012366d84667de0d223bbde38d8b90419e36
diff --git a/core/board_config.mk b/core/board_config.mk
index f5c8ea5..63d7e07 100644
--- a/core/board_config.mk
+++ b/core/board_config.mk
@@ -621,11 +621,15 @@
 ###########################################
 # Handle BUILD_BROKEN_USES_BUILD_*
 
-$(foreach m,$(DEFAULT_WARNING_BUILD_MODULE_TYPES),\
+$(foreach m,$(filter-out BUILD_COPY_HEADERS,$(DEFAULT_WARNING_BUILD_MODULE_TYPES)),\
   $(if $(filter false,$(BUILD_BROKEN_USES_$(m))),\
     $(KATI_obsolete_var $(m),Please convert to Soong),\
     $(KATI_deprecated_var $(m),Please convert to Soong)))
 
+$(if $(filter false,$(BUILD_BROKEN_USES_BUILD_COPY_HEADERS)),\
+  $(KATI_obsolete_var BUILD_COPY_HEADERS,See $(CHANGES_URL)#copy_headers),\
+  $(KATI_deprecated_var BUILD_COPY_HEADERS,See $(CHANGES_URL)#copy_headers))
+
 $(foreach m,$(DEFAULT_ERROR_BUILD_MODULE_TYPES),\
   $(if $(filter true,$(BUILD_BROKEN_USES_$(m))),\
     $(KATI_deprecated_var $(m),Please convert to Soong),\
diff --git a/core/deprecation.mk b/core/deprecation.mk
index fd71f48..dac7e4b 100644
--- a/core/deprecation.mk
+++ b/core/deprecation.mk
@@ -1,6 +1,5 @@
 # These module types can still be used without warnings or errors.
 AVAILABLE_BUILD_MODULE_TYPES :=$= \
-  BUILD_COPY_HEADERS \
   BUILD_EXECUTABLE \
   BUILD_FUZZ_TEST \
   BUILD_HEADER_LIBRARY \
@@ -26,6 +25,7 @@
 # relevant BUILD_BROKEN_USES_BUILD_* variables, then these would move to
 # DEFAULT_ERROR_BUILD_MODULE_TYPES.
 DEFAULT_WARNING_BUILD_MODULE_TYPES :=$= \
+  BUILD_COPY_HEADERS \
   BUILD_HOST_SHARED_LIBRARY \
   BUILD_HOST_STATIC_LIBRARY \
 
diff --git a/core/host_shared_library.mk b/core/host_shared_library.mk
index 81236d1..c22af97 100644
--- a/core/host_shared_library.mk
+++ b/core/host_shared_library.mk
@@ -37,4 +37,7 @@
 ###########################################################
 ## Copy headers to the install tree
 ###########################################################
-include $(BUILD_COPY_HEADERS)
+ifdef LOCAL_COPY_HEADERS
+$(call pretty-warning,LOCAL_COPY_HEADERS is deprecated. See $(CHANGES_URL)#copy_headers)
+include $(BUILD_SYSTEM)/copy_headers.mk
+endif
diff --git a/core/host_static_library.mk b/core/host_static_library.mk
index 469da29..3dbd144 100644
--- a/core/host_static_library.mk
+++ b/core/host_static_library.mk
@@ -37,4 +37,7 @@
 ###########################################################
 ## Copy headers to the install tree
 ###########################################################
-include $(BUILD_COPY_HEADERS)
+ifdef LOCAL_COPY_HEADERS
+$(call pretty-warning,LOCAL_COPY_HEADERS is deprecated. See $(CHANGES_URL)#copy_headers)
+include $(BUILD_SYSTEM)/copy_headers.mk
+endif
diff --git a/core/shared_library.mk b/core/shared_library.mk
index 984f05f..ca17151 100644
--- a/core/shared_library.mk
+++ b/core/shared_library.mk
@@ -56,4 +56,7 @@
 ###########################################################
 ## Copy headers to the install tree
 ###########################################################
-include $(BUILD_COPY_HEADERS)
+ifdef LOCAL_COPY_HEADERS
+$(call pretty-warning,LOCAL_COPY_HEADERS is deprecated. See $(CHANGES_URL)#copy_headers)
+include $(BUILD_SYSTEM)/copy_headers.mk
+endif
diff --git a/core/static_library.mk b/core/static_library.mk
index 1b056ec..78908cf 100644
--- a/core/static_library.mk
+++ b/core/static_library.mk
@@ -41,4 +41,7 @@
 ###########################################################
 ## Copy headers to the install tree
 ###########################################################
-include $(BUILD_COPY_HEADERS)
+ifdef LOCAL_COPY_HEADERS
+$(call pretty-warning,LOCAL_COPY_HEADERS is deprecated. See $(CHANGES_URL)#copy_headers)
+include $(BUILD_SYSTEM)/copy_headers.mk
+endif