1 # Copyright (C) 2009 The Android Open Source Project 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 # 15 # Handle local variable expor/import during the build 16 # 17 18 $(call assert-defined,LOCAL_MODULE) 19 20 # For LOCAL_CFLAGS, LOCAL_CPPFLAGS and LOCAL_C_INCLUDES, we need 21 # to use the exported definitions of the closure of all modules 22 # we depend on. 23 # 24 # I.e. If module 'foo' depends on 'bar' which depends on 'zoo', 25 # then 'foo' will get the CFLAGS/CPPFLAGS/C_INCLUDES of both 'bar' 26 # and 'zoo' 27 # 28 29 all_depends := $(call module-get-all-dependencies,$(LOCAL_MODULE)) 30 all_depends := $(filter-out $(LOCAL_MODULE),$(all_depends)) 31 32 imported_CFLAGS := $(call module-get-listed-export,$(all_depends),CFLAGS) 33 imported_CPPFLAGS := $(call module-get-listed-export,$(all_depends),CPPFLAGS) 34 imported_C_INCLUDES := $(call module-get-listed-export,$(all_depends),C_INCLUDES) 35 36 ifdef NDK_DEBUG_IMPORTS 37 $(info Imports for module $(LOCAL_MODULE):) 38 $(info CFLAGS='$(imported_CFLAGS)') 39 $(info CPPFLAGS='$(imported_CPPFLAGS)') 40 $(info C_INCLUDES='$(imported_C_INCLUDES)') 41 $(info All depends='$(all_depends)') 42 endif 43 44 # 45 # The imported compiler flags are prepended to their LOCAL_XXXX value 46 # (this allows the module to override them). 47 # 48 LOCAL_CFLAGS := $(strip $(imported_CFLAGS) $(LOCAL_CFLAGS)) 49 LOCAL_CPPFLAGS := $(strip $(imported_CPPFLAGS) $(LOCAL_CPPFLAGS)) 50 51 # 52 # The imported include directories are appended to their LOCAL_XXX value 53 # (this allows the module to override them) 54 # 55 LOCAL_C_INCLUDES := $(strip $(LOCAL_C_INCLUDES) $(imported_C_INCLUDES)) 56 57 # Similarly, you want the imported flags to appear _after_ the LOCAL_LDLIBS 58 # due to the way Unix linkers work (depending libraries must appear before 59 # dependees on final link command). 60 # 61 imported_LDLIBS := $(call module-get-listed-export,$(all_depends),LDLIBS) 62 63 LOCAL_LDLIBS := $(strip $(LOCAL_LDLIBS) $(imported_LDLIBS)) 64 65 # We're done here 66