Home | History | Annotate | Download | only in core
      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_CONLYFLAGS, LOCAL_CPPFLAGS and LOCAL_C_INCLUDES, etc,
     21 # we need 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/CONLYFLAGS/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_CONLYFLAGS := $(call module-get-listed-export,$(all_depends),CONLYFLAGS)
     34 imported_CPPFLAGS   := $(call module-get-listed-export,$(all_depends),CPPFLAGS)
     35 imported_RENDERSCRIPT_FLAGS := $(call module-get-listed-export,$(all_depends),RENDERSCRIPT_FLAGS)
     36 imported_ASMFLAGS   := $(call module-get-listed-export,$(all_depends),ASMFLAGS)
     37 imported_C_INCLUDES := $(call module-get-listed-export,$(all_depends),C_INCLUDES)
     38 imported_LDFLAGS    := $(call module-get-listed-export,$(all_depends),LDFLAGS)
     39 
     40 ifdef NDK_DEBUG_IMPORTS
     41     $(info Imports for module $(LOCAL_MODULE):)
     42     $(info   CFLAGS='$(imported_CFLAGS)')
     43     $(info   CONLYFLAGS='$(imported_CONLYFLAGS)')
     44     $(info   CPPFLAGS='$(imported_CPPFLAGS)')
     45     $(info   RENDERSCRIPT_FLAGS='$(imported_RENDERSCRIPT_FLAGS)')
     46     $(info   ASMFLAGS='$(imported_ASMFLAGS)')
     47     $(info   C_INCLUDES='$(imported_C_INCLUDES)')
     48     $(info   LDFLAGS='$(imported_LDFLAGS)')
     49     $(info All depends='$(all_depends)')
     50 endif
     51 
     52 #
     53 # The imported compiler flags are prepended to their LOCAL_XXXX value
     54 # (this allows the module to override them).
     55 #
     56 LOCAL_CFLAGS     := $(strip $(imported_CFLAGS) $(LOCAL_CFLAGS))
     57 LOCAL_CONLYFLAGS := $(strip $(imported_CONLYFLAGS) $(LOCAL_CONLYFLAGS))
     58 LOCAL_CPPFLAGS   := $(strip $(imported_CPPFLAGS) $(LOCAL_CPPFLAGS))
     59 LOCAL_RENDERSCRIPT_FLAGS := $(strip $(imported_RENDERSCRIPT_FLAGS) $(LOCAL_RENDERSCRIPT_FLAGS))
     60 LOCAL_ASMFLAGS := $(strip $(imported_ASMFLAGS) $(LOCAL_ASMFLAGS))
     61 LOCAL_LDFLAGS    := $(strip $(imported_LDFLAGS) $(LOCAL_LDFLAGS))
     62 
     63 #
     64 # The imported include directories are appended to their LOCAL_XXX value
     65 # (this allows the module to override them)
     66 #
     67 LOCAL_C_INCLUDES := $(strip $(LOCAL_C_INCLUDES) $(imported_C_INCLUDES))
     68 
     69 # Similarly, you want the imported flags to appear _after_ the LOCAL_LDLIBS
     70 # due to the way Unix linkers work (depending libraries must appear before
     71 # dependees on final link command).
     72 #
     73 imported_LDLIBS := $(call module-get-listed-export,$(all_depends),LDLIBS)
     74 
     75 LOCAL_LDLIBS := $(strip $(LOCAL_LDLIBS) $(imported_LDLIBS))
     76 
     77 # We're done here
     78