In order to use the macro $(call all-subdir-makefiles) in a Makefile when building AOSP or one of the modules, one has to save and restore the $LOCAL_PATH.

  • $LOCAL_PATH gets overwritten from called subdir makefiles.
  • $(call my-dir) must be called before include $(call all-subdir-makefiles)
  • => So we redefine $LOCAL_PATH after the call to the subdir makefile


# Save LOCAL_PATH of the current file
SAVED_LOCAL_PATH := $(call my-dir)
# Include/Call all recursively 
include $(call all-subdir-makefiles)
# Restore LOCAL_PATH variable