Hi,

I have two directories under device/poplar, one is gralloc one is audio.

All gralloc and audio builds fine with mm inside of the directory. But werid
thing happens when trying to build on the top of source using make gralloc.poplar

From the error message, it is because when building the gralloc.poplar, the audio source 
is included, but the compiler option (cflag, include) are actually the one setup for gralloc!

[ 14% 1/7] target thumb C: gralloc.poplar <= device/hisilicon/poplar/audio/audio_hw.c
FAILED: /bin/bash -c "(PWD=/proc/self/cwd prebuilts/misc/linux-x86/ccache/ccache prebuilts/clang/host/linux-x86/clang-2690385/bin/clang -I vendor/arm/mali6xx -I vendor/arm/mali6xx/include -I vendor/arm/mali6xx/kernel/include -I system/core/libion/include -I device/hisilicon/poplar/gralloc -I out/target/product/poplar/obj/SHARED_LIBRARIES/gralloc.poplar_intermediates -I out/target/product/poplar/gen/SHARED_LIBRARIES/gralloc.poplar_intermediates -I libnativehelper/include/nativehelper \$(cat out/target/product/poplar/obj/SHARED_LIBRARIES/gralloc.poplar_intermediates/import_includes) -isystem system/core/include -isystem system/media/audio/include -isystem hardware/libhardware/include -isystem hardware/libhardware_legacy/include -isystem hardware/ril/include -isystem libnativehelper/include -isystem frameworks/native/include -isystem frameworks/native/opengl/include -isystem frameworks/av/include -isystem frameworks/base/include -isystem out/target/product/poplar/obj/include -isystem bionic/libc/arch-arm/include -isystem bionic/libc/include -isystem bionic/libc/kernel/uapi -isystem bionic/libc/kernel/common -isystem bionic/libc/kernel/uapi/asm-arm -isystem bionic/libm/include -isystem bionic/libm/include/arm -c    -fno-exceptions -Wno-multichar -msoft-float -ffunction-sections -fdata-sections -funwind-tables -fstack-protector-strong -Wa,--noexecstack -Werror=format-security -D_FORTIFY_SOURCE=2 -fno-short-enums -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Werror=date-time -DNDEBUG -g -Wstrict-aliasing=2 -DNDEBUG -UDEBUG  -D__compiler_offsetof=__builtin_offsetof -Werror=int-conversion -Wno-reserved-id-macro -Wno-format-pedantic -Wno-unused-command-line-argument -fcolor-diagnostics -nostdlibinc  -target arm-linux-androideabi    -target arm-linux-androideabi -Bprebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/arm-linux-androideabi/bin    -std=gnu99     -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing   -DLOG_TAG=\\\"gralloc\\\" -DSTANDARD_LINUX_SCREEN -DMALI_ION=1 -DMALI_AFBC_GRALLOC=0 -DGRALLOC_32_BITS -DMALI_ARCHITECTURE_UTGARD=0 -DPLATFORM_SDK_VERSION=25 -DDISABLE_FRAMEBUFFER_HAL=0 -DMALI_SUPPORT_AFBC_WIDEBLK=0 -DMALI_USE_YUV_AFBC_WIDEBLK=0 -DAFBC_YUV420_EXTRA_MB_ROW_NEEDED=0 -DGRALLOC_USE_ION_DMA_HEAP=0 -DGRALLOC_USE_ION_COMPOUND_PAGE_HEAP=0 -DGRALLOC_INIT_AFBC=0 -DGRALLOC_FB_SWAP_RED_BLUE -DGRALLOC_ARM_FORMAT_SELECTION_DISABLE -fPIC -D_USING_LIBCXX   -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast  -Werror=address-of-temporary -Werror=null-dereference -Werror=return-type  -MD -MF out/target/product/poplar/obj/SHARED_LIBRARIES/audio.primary.poplar_intermediates/audio_hw.d -o out/target/product/poplar/obj/SHARED_LIBRARIES/audio.primary.poplar_intermediates/audio_hw.o device/hisilicon/poplar/audio/audio_hw.c ) && (cp out/target/product/poplar/obj/SHARED_LIBRARIES/audio.primary.poplar_intermediates/audio_hw.d out/target/product/poplar/obj/SHARED_LIBRARIES/audio.primary.poplar_intermediates/audio_hw.P; sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\\\\$//' -e '/^\$/ d' -e 's/\$/ :/' < out/target/product/poplar/obj/SHARED_LIBRARIES/audio.primary.poplar_intermediates/audio_hw.d >> out/target/product/poplar/obj/SHARED_LIBRARIES/audio.primary.poplar_intermediates/audio_hw.P; rm -f out/target/product/poplar/obj/SHARED_LIBRARIES/audio.primary.poplar_intermediates/audio_hw.d )"

I debug the Android.mk file, by printing out the $(LOCAL_SRC_FILES) before calling 
$(BUILD_SHARED_LIBRARY). And include $(CLEAR_VARS) were called in each Android.mk.

including ./device/hisilicon/poplar/audio/Android.mk ...
./device/hisilicon/poplar/audio/Android.mk:36: audio_hw.c
including ./device/hisilicon/poplar/gralloc/Android.mk ...
./device/hisilicon/poplar/gralloc/Android.mk:171: gralloc_module.cpp alloc_device.cpp alloc_ion.cpp gralloc_module_ion.cpp framebuffer_device.cpp format_chooser.cpp format_chooser_blockinit.cpp  gralloc_vsync_default.cpp gralloc_hisilicon_adp.cpp

Note that audio_hw.c is not in the source of gralloc target.

What can possible go wrong? 

--
Regards,
Bin