title: Simplifying an Android.mk file which build multiple executables
body: <p>I am building some hardware tests for Android.  I have an Android.mk file which builds these executables one-by-one, using a block of makefile code for each, as shown below:</p>
  
  <pre><code>##### shared #####
  LOCAL_PATH := $(my-dir)
  
  ##### test_number_one #####
  test_name := test_number_one
  include $(CLEAR_VARS)
  LOCAL_CFLAGS := $(commonCflags)
  LOCAL_C_INCLUDES := $(LOCAL_PATH)/../
  LOCAL_MODULE_TAGS := optional eng
  LOCAL_SHARED_LIBRARIES := some_library some_other_library
  LOCAL_MODULE := $(test_name)
  LOCAL_SRC_FILES := tests/$(test_name)/$(test_name).c
  include $(BUILD_EXECUTABLE)
  
  
  ##### test_number_two #####
  test_name := test_number_two
  include $(CLEAR_VARS)
  LOCAL_CFLAGS := $(commonCflags)
  LOCAL_C_INCLUDES := $(LOCAL_PATH)/../
  LOCAL_MODULE_TAGS := optional eng
  LOCAL_SHARED_LIBRARIES := some_library some_other_library
  LOCAL_MODULE := $(test_name)
  LOCAL_SRC_FILES := tests/$(test_name)/$(test_name).c
  include $(BUILD_EXECUTABLE)
  </code></pre>
  
  <p>As you can see, the majority of the code is repeated for each test (between <code>include $(CLEAR_VARS)</code> and <code>include $(CLEAR_VARS)</code>).  I would like to simplify this such that I have a list of test names and a section of makefile code which is 'called' for each one.  I don't care if that code must be split into another file.  Here's some python-esque pseudocode to demonstrate what I am going for:</p>
  
  <pre><code>##### shared #####
  LOCAL_PATH := $(my-dir)
  
  ##### test_number_one #####
  test_names := test_number_one test_numer_two
  
  for each item in test_names:
      include $(CLEAR_VARS)
      LOCAL_CFLAGS := $(commonCflags)
      LOCAL_C_INCLUDES := $(LOCAL_PATH)/../
      LOCAL_MODULE_TAGS := optional eng
      LOCAL_SHARED_LIBRARIES := some_library some_other_library
      LOCAL_MODULE := $(item)
      LOCAL_SRC_FILES := tests/$(item)/$(item).c
      include $(BUILD_EXECUTABLE)
  </code></pre>
  
  <p>Is this possible in Android.mk files?  How can it be done?</p>