Merge "Fix excluded sources to not include common sources"
diff --git a/Android.bp b/Android.bp
index 7f921c6..5ddac99 100644
--- a/Android.bp
+++ b/Android.bp
@@ -2,7 +2,6 @@
 // Generated from Android.bp.in, run ./generate_config.sh to regenerate
 
 libvpx_arm_neon_c_srcs = [
-    "libvpx/vp8/common/alloccommon.c",
     "libvpx/vp8/common/arm/loopfilter_arm.c",
     "libvpx/vp8/common/arm/neon/bilinearpredict_neon.c",
     "libvpx/vp8/common/arm/neon/copymem_neon.c",
@@ -19,138 +18,15 @@
     "libvpx/vp8/common/arm/neon/shortidct4x4llm_neon.c",
     "libvpx/vp8/common/arm/neon/sixtappredict_neon.c",
     "libvpx/vp8/common/arm/neon/vp8_loopfilter_neon.c",
-    "libvpx/vp8/common/blockd.c",
-    "libvpx/vp8/common/copy_c.c",
-    "libvpx/vp8/common/dequantize.c",
-    "libvpx/vp8/common/entropy.c",
-    "libvpx/vp8/common/entropymode.c",
-    "libvpx/vp8/common/entropymv.c",
-    "libvpx/vp8/common/extend.c",
-    "libvpx/vp8/common/filter.c",
-    "libvpx/vp8/common/findnearmv.c",
-    "libvpx/vp8/common/generic/systemdependent.c",
-    "libvpx/vp8/common/idct_blk.c",
-    "libvpx/vp8/common/idctllm.c",
-    "libvpx/vp8/common/loopfilter_filters.c",
-    "libvpx/vp8/common/mbpitch.c",
-    "libvpx/vp8/common/modecont.c",
-    "libvpx/vp8/common/quant_common.c",
-    "libvpx/vp8/common/reconinter.c",
-    "libvpx/vp8/common/reconintra.c",
-    "libvpx/vp8/common/reconintra4x4.c",
-    "libvpx/vp8/common/rtcd.c",
-    "libvpx/vp8/common/setupintrarecon.c",
-    "libvpx/vp8/common/swapyv12buffer.c",
-    "libvpx/vp8/common/treecoder.c",
-    "libvpx/vp8/common/vp8_loopfilter.c",
-    "libvpx/vp8/decoder/dboolhuff.c",
-    "libvpx/vp8/decoder/decodeframe.c",
-    "libvpx/vp8/decoder/decodemv.c",
-    "libvpx/vp8/decoder/detokenize.c",
-    "libvpx/vp8/decoder/onyxd_if.c",
-    "libvpx/vp8/decoder/threading.c",
     "libvpx/vp8/encoder/arm/neon/denoising_neon.c",
     "libvpx/vp8/encoder/arm/neon/fastquantizeb_neon.c",
     "libvpx/vp8/encoder/arm/neon/shortfdct_neon.c",
     "libvpx/vp8/encoder/arm/neon/vp8_shortwalsh4x4_neon.c",
-    "libvpx/vp8/encoder/bitstream.c",
-    "libvpx/vp8/encoder/boolhuff.c",
-    "libvpx/vp8/encoder/dct.c",
-    "libvpx/vp8/encoder/denoising.c",
-    "libvpx/vp8/encoder/encodeframe.c",
-    "libvpx/vp8/encoder/encodeintra.c",
-    "libvpx/vp8/encoder/encodemb.c",
-    "libvpx/vp8/encoder/encodemv.c",
-    "libvpx/vp8/encoder/ethreading.c",
-    "libvpx/vp8/encoder/lookahead.c",
-    "libvpx/vp8/encoder/mcomp.c",
-    "libvpx/vp8/encoder/modecosts.c",
-    "libvpx/vp8/encoder/onyx_if.c",
-    "libvpx/vp8/encoder/pickinter.c",
-    "libvpx/vp8/encoder/picklpf.c",
-    "libvpx/vp8/encoder/ratectrl.c",
-    "libvpx/vp8/encoder/rdopt.c",
-    "libvpx/vp8/encoder/segmentation.c",
-    "libvpx/vp8/encoder/tokenize.c",
-    "libvpx/vp8/encoder/treewriter.c",
-    "libvpx/vp8/encoder/vp8_quantize.c",
-    "libvpx/vp8/vp8_cx_iface.c",
-    "libvpx/vp8/vp8_dx_iface.c",
     "libvpx/vp9/common/arm/neon/vp9_iht4x4_add_neon.c",
     "libvpx/vp9/common/arm/neon/vp9_iht8x8_add_neon.c",
-    "libvpx/vp9/common/vp9_alloccommon.c",
-    "libvpx/vp9/common/vp9_blockd.c",
-    "libvpx/vp9/common/vp9_common_data.c",
-    "libvpx/vp9/common/vp9_entropy.c",
-    "libvpx/vp9/common/vp9_entropymode.c",
-    "libvpx/vp9/common/vp9_entropymv.c",
-    "libvpx/vp9/common/vp9_filter.c",
-    "libvpx/vp9/common/vp9_frame_buffers.c",
-    "libvpx/vp9/common/vp9_idct.c",
-    "libvpx/vp9/common/vp9_loopfilter.c",
-    "libvpx/vp9/common/vp9_mvref_common.c",
-    "libvpx/vp9/common/vp9_pred_common.c",
-    "libvpx/vp9/common/vp9_quant_common.c",
-    "libvpx/vp9/common/vp9_reconinter.c",
-    "libvpx/vp9/common/vp9_reconintra.c",
-    "libvpx/vp9/common/vp9_rtcd.c",
-    "libvpx/vp9/common/vp9_scale.c",
-    "libvpx/vp9/common/vp9_scan.c",
-    "libvpx/vp9/common/vp9_seg_common.c",
-    "libvpx/vp9/common/vp9_thread_common.c",
-    "libvpx/vp9/common/vp9_tile_common.c",
-    "libvpx/vp9/decoder/vp9_decodeframe.c",
-    "libvpx/vp9/decoder/vp9_decodemv.c",
-    "libvpx/vp9/decoder/vp9_decoder.c",
-    "libvpx/vp9/decoder/vp9_detokenize.c",
-    "libvpx/vp9/decoder/vp9_dsubexp.c",
-    "libvpx/vp9/decoder/vp9_dthread.c",
     "libvpx/vp9/encoder/arm/neon/vp9_dct_neon.c",
     "libvpx/vp9/encoder/arm/neon/vp9_error_neon.c",
     "libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c",
-    "libvpx/vp9/encoder/vp9_alt_ref_aq.c",
-    "libvpx/vp9/encoder/vp9_aq_360.c",
-    "libvpx/vp9/encoder/vp9_aq_complexity.c",
-    "libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
-    "libvpx/vp9/encoder/vp9_aq_variance.c",
-    "libvpx/vp9/encoder/vp9_bitstream.c",
-    "libvpx/vp9/encoder/vp9_context_tree.c",
-    "libvpx/vp9/encoder/vp9_cost.c",
-    "libvpx/vp9/encoder/vp9_dct.c",
-    "libvpx/vp9/encoder/vp9_encodeframe.c",
-    "libvpx/vp9/encoder/vp9_encodemb.c",
-    "libvpx/vp9/encoder/vp9_encodemv.c",
-    "libvpx/vp9/encoder/vp9_encoder.c",
-    "libvpx/vp9/encoder/vp9_ethread.c",
-    "libvpx/vp9/encoder/vp9_extend.c",
-    "libvpx/vp9/encoder/vp9_firstpass.c",
-    "libvpx/vp9/encoder/vp9_frame_scale.c",
-    "libvpx/vp9/encoder/vp9_lookahead.c",
-    "libvpx/vp9/encoder/vp9_mbgraph.c",
-    "libvpx/vp9/encoder/vp9_mcomp.c",
-    "libvpx/vp9/encoder/vp9_multi_thread.c",
-    "libvpx/vp9/encoder/vp9_noise_estimate.c",
-    "libvpx/vp9/encoder/vp9_picklpf.c",
-    "libvpx/vp9/encoder/vp9_pickmode.c",
-    "libvpx/vp9/encoder/vp9_quantize.c",
-    "libvpx/vp9/encoder/vp9_ratectrl.c",
-    "libvpx/vp9/encoder/vp9_rd.c",
-    "libvpx/vp9/encoder/vp9_rdopt.c",
-    "libvpx/vp9/encoder/vp9_resize.c",
-    "libvpx/vp9/encoder/vp9_segmentation.c",
-    "libvpx/vp9/encoder/vp9_skin_detection.c",
-    "libvpx/vp9/encoder/vp9_speed_features.c",
-    "libvpx/vp9/encoder/vp9_subexp.c",
-    "libvpx/vp9/encoder/vp9_svc_layercontext.c",
-    "libvpx/vp9/encoder/vp9_temporal_filter.c",
-    "libvpx/vp9/encoder/vp9_tokenize.c",
-    "libvpx/vp9/encoder/vp9_treewriter.c",
-    "libvpx/vp9/vp9_cx_iface.c",
-    "libvpx/vp9/vp9_dx_iface.c",
-    "libvpx/vpx/src/vpx_codec.c",
-    "libvpx/vpx/src/vpx_decoder.c",
-    "libvpx/vpx/src/vpx_encoder.c",
-    "libvpx/vpx/src/vpx_image.c",
     "libvpx/vpx_dsp/arm/avg_neon.c",
     "libvpx/vpx_dsp/arm/fdct_neon.c",
     "libvpx/vpx_dsp/arm/fwd_txfm_neon.c",
@@ -170,35 +46,13 @@
     "libvpx/vpx_dsp/arm/subtract_neon.c",
     "libvpx/vpx_dsp/arm/variance_neon.c",
     "libvpx/vpx_dsp/arm/vpx_convolve_neon.c",
-    "libvpx/vpx_dsp/avg.c",
-    "libvpx/vpx_dsp/bitreader.c",
-    "libvpx/vpx_dsp/bitreader_buffer.c",
-    "libvpx/vpx_dsp/bitwriter.c",
-    "libvpx/vpx_dsp/bitwriter_buffer.c",
-    "libvpx/vpx_dsp/fwd_txfm.c",
-    "libvpx/vpx_dsp/intrapred.c",
-    "libvpx/vpx_dsp/inv_txfm.c",
-    "libvpx/vpx_dsp/loopfilter.c",
-    "libvpx/vpx_dsp/prob.c",
-    "libvpx/vpx_dsp/psnr.c",
-    "libvpx/vpx_dsp/quantize.c",
-    "libvpx/vpx_dsp/sad.c",
-    "libvpx/vpx_dsp/subtract.c",
-    "libvpx/vpx_dsp/sum_squares.c",
-    "libvpx/vpx_dsp/variance.c",
-    "libvpx/vpx_dsp/vpx_convolve.c",
-    "libvpx/vpx_dsp/vpx_dsp_rtcd.c",
-    "libvpx/vpx_mem/vpx_mem.c",
-    "libvpx/vpx_ports/arm_cpudetect.c",
-    "libvpx/vpx_scale/generic/gen_scalers.c",
-    "libvpx/vpx_scale/generic/vpx_scale.c",
-    "libvpx/vpx_scale/generic/yv12config.c",
-    "libvpx/vpx_scale/generic/yv12extend.c",
-    "libvpx/vpx_scale/vpx_scale_rtcd.c",
-    "libvpx/vpx_util/vpx_thread.c",
     "config/arm-neon/vpx_config.c",
 ]
 
+libvpx_arm_neon_exclude_c_srcs = [
+    "config/arm/vpx_config.c",
+]
+
 libvpx_arm_neon_asm_srcs = [
     "libvpx/vpx_dsp/arm/idct4x4_1_add_neon.asm",
     "libvpx/vpx_dsp/arm/idct4x4_add_neon.asm",
@@ -726,148 +580,15 @@
 ]
 
 libvpx_mips32_dspr2_c_srcs = [
-    "libvpx/vp8/common/alloccommon.c",
-    "libvpx/vp8/common/blockd.c",
-    "libvpx/vp8/common/copy_c.c",
-    "libvpx/vp8/common/dequantize.c",
-    "libvpx/vp8/common/entropy.c",
-    "libvpx/vp8/common/entropymode.c",
-    "libvpx/vp8/common/entropymv.c",
-    "libvpx/vp8/common/extend.c",
-    "libvpx/vp8/common/filter.c",
-    "libvpx/vp8/common/findnearmv.c",
-    "libvpx/vp8/common/generic/systemdependent.c",
-    "libvpx/vp8/common/idct_blk.c",
-    "libvpx/vp8/common/idctllm.c",
-    "libvpx/vp8/common/loopfilter_filters.c",
-    "libvpx/vp8/common/mbpitch.c",
     "libvpx/vp8/common/mips/dspr2/dequantize_dspr2.c",
     "libvpx/vp8/common/mips/dspr2/filter_dspr2.c",
     "libvpx/vp8/common/mips/dspr2/idct_blk_dspr2.c",
     "libvpx/vp8/common/mips/dspr2/idctllm_dspr2.c",
     "libvpx/vp8/common/mips/dspr2/reconinter_dspr2.c",
     "libvpx/vp8/common/mips/dspr2/vp8_loopfilter_filters_dspr2.c",
-    "libvpx/vp8/common/modecont.c",
-    "libvpx/vp8/common/quant_common.c",
-    "libvpx/vp8/common/reconinter.c",
-    "libvpx/vp8/common/reconintra.c",
-    "libvpx/vp8/common/reconintra4x4.c",
-    "libvpx/vp8/common/rtcd.c",
-    "libvpx/vp8/common/setupintrarecon.c",
-    "libvpx/vp8/common/swapyv12buffer.c",
-    "libvpx/vp8/common/treecoder.c",
-    "libvpx/vp8/common/vp8_loopfilter.c",
-    "libvpx/vp8/decoder/dboolhuff.c",
-    "libvpx/vp8/decoder/decodeframe.c",
-    "libvpx/vp8/decoder/decodemv.c",
-    "libvpx/vp8/decoder/detokenize.c",
-    "libvpx/vp8/decoder/onyxd_if.c",
-    "libvpx/vp8/decoder/threading.c",
-    "libvpx/vp8/encoder/bitstream.c",
-    "libvpx/vp8/encoder/boolhuff.c",
-    "libvpx/vp8/encoder/dct.c",
-    "libvpx/vp8/encoder/denoising.c",
-    "libvpx/vp8/encoder/encodeframe.c",
-    "libvpx/vp8/encoder/encodeintra.c",
-    "libvpx/vp8/encoder/encodemb.c",
-    "libvpx/vp8/encoder/encodemv.c",
-    "libvpx/vp8/encoder/ethreading.c",
-    "libvpx/vp8/encoder/lookahead.c",
-    "libvpx/vp8/encoder/mcomp.c",
-    "libvpx/vp8/encoder/modecosts.c",
-    "libvpx/vp8/encoder/onyx_if.c",
-    "libvpx/vp8/encoder/pickinter.c",
-    "libvpx/vp8/encoder/picklpf.c",
-    "libvpx/vp8/encoder/ratectrl.c",
-    "libvpx/vp8/encoder/rdopt.c",
-    "libvpx/vp8/encoder/segmentation.c",
-    "libvpx/vp8/encoder/tokenize.c",
-    "libvpx/vp8/encoder/treewriter.c",
-    "libvpx/vp8/encoder/vp8_quantize.c",
-    "libvpx/vp8/vp8_cx_iface.c",
-    "libvpx/vp8/vp8_dx_iface.c",
     "libvpx/vp9/common/mips/dspr2/vp9_itrans16_dspr2.c",
     "libvpx/vp9/common/mips/dspr2/vp9_itrans4_dspr2.c",
     "libvpx/vp9/common/mips/dspr2/vp9_itrans8_dspr2.c",
-    "libvpx/vp9/common/vp9_alloccommon.c",
-    "libvpx/vp9/common/vp9_blockd.c",
-    "libvpx/vp9/common/vp9_common_data.c",
-    "libvpx/vp9/common/vp9_entropy.c",
-    "libvpx/vp9/common/vp9_entropymode.c",
-    "libvpx/vp9/common/vp9_entropymv.c",
-    "libvpx/vp9/common/vp9_filter.c",
-    "libvpx/vp9/common/vp9_frame_buffers.c",
-    "libvpx/vp9/common/vp9_idct.c",
-    "libvpx/vp9/common/vp9_loopfilter.c",
-    "libvpx/vp9/common/vp9_mvref_common.c",
-    "libvpx/vp9/common/vp9_pred_common.c",
-    "libvpx/vp9/common/vp9_quant_common.c",
-    "libvpx/vp9/common/vp9_reconinter.c",
-    "libvpx/vp9/common/vp9_reconintra.c",
-    "libvpx/vp9/common/vp9_rtcd.c",
-    "libvpx/vp9/common/vp9_scale.c",
-    "libvpx/vp9/common/vp9_scan.c",
-    "libvpx/vp9/common/vp9_seg_common.c",
-    "libvpx/vp9/common/vp9_thread_common.c",
-    "libvpx/vp9/common/vp9_tile_common.c",
-    "libvpx/vp9/decoder/vp9_decodeframe.c",
-    "libvpx/vp9/decoder/vp9_decodemv.c",
-    "libvpx/vp9/decoder/vp9_decoder.c",
-    "libvpx/vp9/decoder/vp9_detokenize.c",
-    "libvpx/vp9/decoder/vp9_dsubexp.c",
-    "libvpx/vp9/decoder/vp9_dthread.c",
-    "libvpx/vp9/encoder/vp9_alt_ref_aq.c",
-    "libvpx/vp9/encoder/vp9_aq_360.c",
-    "libvpx/vp9/encoder/vp9_aq_complexity.c",
-    "libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
-    "libvpx/vp9/encoder/vp9_aq_variance.c",
-    "libvpx/vp9/encoder/vp9_bitstream.c",
-    "libvpx/vp9/encoder/vp9_context_tree.c",
-    "libvpx/vp9/encoder/vp9_cost.c",
-    "libvpx/vp9/encoder/vp9_dct.c",
-    "libvpx/vp9/encoder/vp9_encodeframe.c",
-    "libvpx/vp9/encoder/vp9_encodemb.c",
-    "libvpx/vp9/encoder/vp9_encodemv.c",
-    "libvpx/vp9/encoder/vp9_encoder.c",
-    "libvpx/vp9/encoder/vp9_ethread.c",
-    "libvpx/vp9/encoder/vp9_extend.c",
-    "libvpx/vp9/encoder/vp9_firstpass.c",
-    "libvpx/vp9/encoder/vp9_frame_scale.c",
-    "libvpx/vp9/encoder/vp9_lookahead.c",
-    "libvpx/vp9/encoder/vp9_mbgraph.c",
-    "libvpx/vp9/encoder/vp9_mcomp.c",
-    "libvpx/vp9/encoder/vp9_multi_thread.c",
-    "libvpx/vp9/encoder/vp9_noise_estimate.c",
-    "libvpx/vp9/encoder/vp9_picklpf.c",
-    "libvpx/vp9/encoder/vp9_pickmode.c",
-    "libvpx/vp9/encoder/vp9_quantize.c",
-    "libvpx/vp9/encoder/vp9_ratectrl.c",
-    "libvpx/vp9/encoder/vp9_rd.c",
-    "libvpx/vp9/encoder/vp9_rdopt.c",
-    "libvpx/vp9/encoder/vp9_resize.c",
-    "libvpx/vp9/encoder/vp9_segmentation.c",
-    "libvpx/vp9/encoder/vp9_skin_detection.c",
-    "libvpx/vp9/encoder/vp9_speed_features.c",
-    "libvpx/vp9/encoder/vp9_subexp.c",
-    "libvpx/vp9/encoder/vp9_svc_layercontext.c",
-    "libvpx/vp9/encoder/vp9_temporal_filter.c",
-    "libvpx/vp9/encoder/vp9_tokenize.c",
-    "libvpx/vp9/encoder/vp9_treewriter.c",
-    "libvpx/vp9/vp9_cx_iface.c",
-    "libvpx/vp9/vp9_dx_iface.c",
-    "libvpx/vpx/src/vpx_codec.c",
-    "libvpx/vpx/src/vpx_decoder.c",
-    "libvpx/vpx/src/vpx_encoder.c",
-    "libvpx/vpx/src/vpx_image.c",
-    "libvpx/vpx_dsp/avg.c",
-    "libvpx/vpx_dsp/bitreader.c",
-    "libvpx/vpx_dsp/bitreader_buffer.c",
-    "libvpx/vpx_dsp/bitwriter.c",
-    "libvpx/vpx_dsp/bitwriter_buffer.c",
-    "libvpx/vpx_dsp/fwd_txfm.c",
-    "libvpx/vpx_dsp/intrapred.c",
-    "libvpx/vpx_dsp/inv_txfm.c",
-    "libvpx/vpx_dsp/loopfilter.c",
     "libvpx/vpx_dsp/mips/common_dspr2.c",
     "libvpx/vpx_dsp/mips/convolve2_avg_dspr2.c",
     "libvpx/vpx_dsp/mips/convolve2_avg_horiz_dspr2.c",
@@ -891,176 +612,31 @@
     "libvpx/vpx_dsp/mips/loopfilter_mb_dspr2.c",
     "libvpx/vpx_dsp/mips/loopfilter_mb_horiz_dspr2.c",
     "libvpx/vpx_dsp/mips/loopfilter_mb_vert_dspr2.c",
-    "libvpx/vpx_dsp/prob.c",
-    "libvpx/vpx_dsp/psnr.c",
-    "libvpx/vpx_dsp/quantize.c",
-    "libvpx/vpx_dsp/sad.c",
-    "libvpx/vpx_dsp/subtract.c",
-    "libvpx/vpx_dsp/sum_squares.c",
-    "libvpx/vpx_dsp/variance.c",
-    "libvpx/vpx_dsp/vpx_convolve.c",
-    "libvpx/vpx_dsp/vpx_dsp_rtcd.c",
-    "libvpx/vpx_mem/vpx_mem.c",
-    "libvpx/vpx_scale/generic/gen_scalers.c",
-    "libvpx/vpx_scale/generic/vpx_scale.c",
-    "libvpx/vpx_scale/generic/yv12config.c",
-    "libvpx/vpx_scale/generic/yv12extend.c",
     "libvpx/vpx_scale/mips/dspr2/yv12extend_dspr2.c",
-    "libvpx/vpx_scale/vpx_scale_rtcd.c",
-    "libvpx/vpx_util/vpx_thread.c",
     "config/mips32-dspr2/vpx_config.c",
 ]
 
+libvpx_mips32_dspr2_exclude_c_srcs = [
+    "config/mips32/vpx_config.c",
+]
+
 libvpx_mips32_msa_c_srcs = [
-    "libvpx/vp8/common/alloccommon.c",
-    "libvpx/vp8/common/blockd.c",
-    "libvpx/vp8/common/copy_c.c",
-    "libvpx/vp8/common/dequantize.c",
-    "libvpx/vp8/common/entropy.c",
-    "libvpx/vp8/common/entropymode.c",
-    "libvpx/vp8/common/entropymv.c",
-    "libvpx/vp8/common/extend.c",
-    "libvpx/vp8/common/filter.c",
-    "libvpx/vp8/common/findnearmv.c",
-    "libvpx/vp8/common/generic/systemdependent.c",
-    "libvpx/vp8/common/idct_blk.c",
-    "libvpx/vp8/common/idctllm.c",
-    "libvpx/vp8/common/loopfilter_filters.c",
-    "libvpx/vp8/common/mbpitch.c",
     "libvpx/vp8/common/mips/msa/bilinear_filter_msa.c",
     "libvpx/vp8/common/mips/msa/copymem_msa.c",
     "libvpx/vp8/common/mips/msa/idct_msa.c",
     "libvpx/vp8/common/mips/msa/loopfilter_filters_msa.c",
     "libvpx/vp8/common/mips/msa/sixtap_filter_msa.c",
-    "libvpx/vp8/common/modecont.c",
-    "libvpx/vp8/common/quant_common.c",
-    "libvpx/vp8/common/reconinter.c",
-    "libvpx/vp8/common/reconintra.c",
-    "libvpx/vp8/common/reconintra4x4.c",
-    "libvpx/vp8/common/rtcd.c",
-    "libvpx/vp8/common/setupintrarecon.c",
-    "libvpx/vp8/common/swapyv12buffer.c",
-    "libvpx/vp8/common/treecoder.c",
-    "libvpx/vp8/common/vp8_loopfilter.c",
-    "libvpx/vp8/decoder/dboolhuff.c",
-    "libvpx/vp8/decoder/decodeframe.c",
-    "libvpx/vp8/decoder/decodemv.c",
-    "libvpx/vp8/decoder/detokenize.c",
-    "libvpx/vp8/decoder/onyxd_if.c",
-    "libvpx/vp8/decoder/threading.c",
-    "libvpx/vp8/encoder/bitstream.c",
-    "libvpx/vp8/encoder/boolhuff.c",
-    "libvpx/vp8/encoder/dct.c",
-    "libvpx/vp8/encoder/denoising.c",
-    "libvpx/vp8/encoder/encodeframe.c",
-    "libvpx/vp8/encoder/encodeintra.c",
-    "libvpx/vp8/encoder/encodemb.c",
-    "libvpx/vp8/encoder/encodemv.c",
-    "libvpx/vp8/encoder/ethreading.c",
-    "libvpx/vp8/encoder/lookahead.c",
-    "libvpx/vp8/encoder/mcomp.c",
     "libvpx/vp8/encoder/mips/msa/dct_msa.c",
     "libvpx/vp8/encoder/mips/msa/denoising_msa.c",
     "libvpx/vp8/encoder/mips/msa/encodeopt_msa.c",
     "libvpx/vp8/encoder/mips/msa/quantize_msa.c",
-    "libvpx/vp8/encoder/modecosts.c",
-    "libvpx/vp8/encoder/onyx_if.c",
-    "libvpx/vp8/encoder/pickinter.c",
-    "libvpx/vp8/encoder/picklpf.c",
-    "libvpx/vp8/encoder/ratectrl.c",
-    "libvpx/vp8/encoder/rdopt.c",
-    "libvpx/vp8/encoder/segmentation.c",
-    "libvpx/vp8/encoder/tokenize.c",
-    "libvpx/vp8/encoder/treewriter.c",
-    "libvpx/vp8/encoder/vp8_quantize.c",
-    "libvpx/vp8/vp8_cx_iface.c",
-    "libvpx/vp8/vp8_dx_iface.c",
     "libvpx/vp9/common/mips/msa/vp9_idct16x16_msa.c",
     "libvpx/vp9/common/mips/msa/vp9_idct4x4_msa.c",
     "libvpx/vp9/common/mips/msa/vp9_idct8x8_msa.c",
-    "libvpx/vp9/common/vp9_alloccommon.c",
-    "libvpx/vp9/common/vp9_blockd.c",
-    "libvpx/vp9/common/vp9_common_data.c",
-    "libvpx/vp9/common/vp9_entropy.c",
-    "libvpx/vp9/common/vp9_entropymode.c",
-    "libvpx/vp9/common/vp9_entropymv.c",
-    "libvpx/vp9/common/vp9_filter.c",
-    "libvpx/vp9/common/vp9_frame_buffers.c",
-    "libvpx/vp9/common/vp9_idct.c",
-    "libvpx/vp9/common/vp9_loopfilter.c",
-    "libvpx/vp9/common/vp9_mvref_common.c",
-    "libvpx/vp9/common/vp9_pred_common.c",
-    "libvpx/vp9/common/vp9_quant_common.c",
-    "libvpx/vp9/common/vp9_reconinter.c",
-    "libvpx/vp9/common/vp9_reconintra.c",
-    "libvpx/vp9/common/vp9_rtcd.c",
-    "libvpx/vp9/common/vp9_scale.c",
-    "libvpx/vp9/common/vp9_scan.c",
-    "libvpx/vp9/common/vp9_seg_common.c",
-    "libvpx/vp9/common/vp9_thread_common.c",
-    "libvpx/vp9/common/vp9_tile_common.c",
-    "libvpx/vp9/decoder/vp9_decodeframe.c",
-    "libvpx/vp9/decoder/vp9_decodemv.c",
-    "libvpx/vp9/decoder/vp9_decoder.c",
-    "libvpx/vp9/decoder/vp9_detokenize.c",
-    "libvpx/vp9/decoder/vp9_dsubexp.c",
-    "libvpx/vp9/decoder/vp9_dthread.c",
     "libvpx/vp9/encoder/mips/msa/vp9_error_msa.c",
     "libvpx/vp9/encoder/mips/msa/vp9_fdct16x16_msa.c",
     "libvpx/vp9/encoder/mips/msa/vp9_fdct4x4_msa.c",
     "libvpx/vp9/encoder/mips/msa/vp9_fdct8x8_msa.c",
-    "libvpx/vp9/encoder/vp9_alt_ref_aq.c",
-    "libvpx/vp9/encoder/vp9_aq_360.c",
-    "libvpx/vp9/encoder/vp9_aq_complexity.c",
-    "libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
-    "libvpx/vp9/encoder/vp9_aq_variance.c",
-    "libvpx/vp9/encoder/vp9_bitstream.c",
-    "libvpx/vp9/encoder/vp9_context_tree.c",
-    "libvpx/vp9/encoder/vp9_cost.c",
-    "libvpx/vp9/encoder/vp9_dct.c",
-    "libvpx/vp9/encoder/vp9_encodeframe.c",
-    "libvpx/vp9/encoder/vp9_encodemb.c",
-    "libvpx/vp9/encoder/vp9_encodemv.c",
-    "libvpx/vp9/encoder/vp9_encoder.c",
-    "libvpx/vp9/encoder/vp9_ethread.c",
-    "libvpx/vp9/encoder/vp9_extend.c",
-    "libvpx/vp9/encoder/vp9_firstpass.c",
-    "libvpx/vp9/encoder/vp9_frame_scale.c",
-    "libvpx/vp9/encoder/vp9_lookahead.c",
-    "libvpx/vp9/encoder/vp9_mbgraph.c",
-    "libvpx/vp9/encoder/vp9_mcomp.c",
-    "libvpx/vp9/encoder/vp9_multi_thread.c",
-    "libvpx/vp9/encoder/vp9_noise_estimate.c",
-    "libvpx/vp9/encoder/vp9_picklpf.c",
-    "libvpx/vp9/encoder/vp9_pickmode.c",
-    "libvpx/vp9/encoder/vp9_quantize.c",
-    "libvpx/vp9/encoder/vp9_ratectrl.c",
-    "libvpx/vp9/encoder/vp9_rd.c",
-    "libvpx/vp9/encoder/vp9_rdopt.c",
-    "libvpx/vp9/encoder/vp9_resize.c",
-    "libvpx/vp9/encoder/vp9_segmentation.c",
-    "libvpx/vp9/encoder/vp9_skin_detection.c",
-    "libvpx/vp9/encoder/vp9_speed_features.c",
-    "libvpx/vp9/encoder/vp9_subexp.c",
-    "libvpx/vp9/encoder/vp9_svc_layercontext.c",
-    "libvpx/vp9/encoder/vp9_temporal_filter.c",
-    "libvpx/vp9/encoder/vp9_tokenize.c",
-    "libvpx/vp9/encoder/vp9_treewriter.c",
-    "libvpx/vp9/vp9_cx_iface.c",
-    "libvpx/vp9/vp9_dx_iface.c",
-    "libvpx/vpx/src/vpx_codec.c",
-    "libvpx/vpx/src/vpx_decoder.c",
-    "libvpx/vpx/src/vpx_encoder.c",
-    "libvpx/vpx/src/vpx_image.c",
-    "libvpx/vpx_dsp/avg.c",
-    "libvpx/vpx_dsp/bitreader.c",
-    "libvpx/vpx_dsp/bitreader_buffer.c",
-    "libvpx/vpx_dsp/bitwriter.c",
-    "libvpx/vpx_dsp/bitwriter_buffer.c",
-    "libvpx/vpx_dsp/fwd_txfm.c",
-    "libvpx/vpx_dsp/intrapred.c",
-    "libvpx/vpx_dsp/inv_txfm.c",
-    "libvpx/vpx_dsp/loopfilter.c",
     "libvpx/vpx_dsp/mips/avg_msa.c",
     "libvpx/vpx_dsp/mips/fwd_dct32x32_msa.c",
     "libvpx/vpx_dsp/mips/fwd_txfm_msa.c",
@@ -1085,25 +661,13 @@
     "libvpx/vpx_dsp/mips/vpx_convolve8_vert_msa.c",
     "libvpx/vpx_dsp/mips/vpx_convolve_avg_msa.c",
     "libvpx/vpx_dsp/mips/vpx_convolve_copy_msa.c",
-    "libvpx/vpx_dsp/prob.c",
-    "libvpx/vpx_dsp/psnr.c",
-    "libvpx/vpx_dsp/quantize.c",
-    "libvpx/vpx_dsp/sad.c",
-    "libvpx/vpx_dsp/subtract.c",
-    "libvpx/vpx_dsp/sum_squares.c",
-    "libvpx/vpx_dsp/variance.c",
-    "libvpx/vpx_dsp/vpx_convolve.c",
-    "libvpx/vpx_dsp/vpx_dsp_rtcd.c",
-    "libvpx/vpx_mem/vpx_mem.c",
-    "libvpx/vpx_scale/generic/gen_scalers.c",
-    "libvpx/vpx_scale/generic/vpx_scale.c",
-    "libvpx/vpx_scale/generic/yv12config.c",
-    "libvpx/vpx_scale/generic/yv12extend.c",
-    "libvpx/vpx_scale/vpx_scale_rtcd.c",
-    "libvpx/vpx_util/vpx_thread.c",
     "config/mips32-msa/vpx_config.c",
 ]
 
+libvpx_mips32_msa_exclude_c_srcs = [
+    "config/mips32/vpx_config.c",
+]
+
 libvpx_mips32_c_srcs = [
     "libvpx/vp8/common/alloccommon.c",
     "libvpx/vp8/common/blockd.c",
@@ -1258,155 +822,22 @@
 ]
 
 libvpx_mips64_msa_c_srcs = [
-    "libvpx/vp8/common/alloccommon.c",
-    "libvpx/vp8/common/blockd.c",
-    "libvpx/vp8/common/copy_c.c",
-    "libvpx/vp8/common/dequantize.c",
-    "libvpx/vp8/common/entropy.c",
-    "libvpx/vp8/common/entropymode.c",
-    "libvpx/vp8/common/entropymv.c",
-    "libvpx/vp8/common/extend.c",
-    "libvpx/vp8/common/filter.c",
-    "libvpx/vp8/common/findnearmv.c",
-    "libvpx/vp8/common/generic/systemdependent.c",
-    "libvpx/vp8/common/idct_blk.c",
-    "libvpx/vp8/common/idctllm.c",
-    "libvpx/vp8/common/loopfilter_filters.c",
-    "libvpx/vp8/common/mbpitch.c",
     "libvpx/vp8/common/mips/msa/bilinear_filter_msa.c",
     "libvpx/vp8/common/mips/msa/copymem_msa.c",
     "libvpx/vp8/common/mips/msa/idct_msa.c",
     "libvpx/vp8/common/mips/msa/loopfilter_filters_msa.c",
     "libvpx/vp8/common/mips/msa/sixtap_filter_msa.c",
-    "libvpx/vp8/common/modecont.c",
-    "libvpx/vp8/common/quant_common.c",
-    "libvpx/vp8/common/reconinter.c",
-    "libvpx/vp8/common/reconintra.c",
-    "libvpx/vp8/common/reconintra4x4.c",
-    "libvpx/vp8/common/rtcd.c",
-    "libvpx/vp8/common/setupintrarecon.c",
-    "libvpx/vp8/common/swapyv12buffer.c",
-    "libvpx/vp8/common/treecoder.c",
-    "libvpx/vp8/common/vp8_loopfilter.c",
-    "libvpx/vp8/decoder/dboolhuff.c",
-    "libvpx/vp8/decoder/decodeframe.c",
-    "libvpx/vp8/decoder/decodemv.c",
-    "libvpx/vp8/decoder/detokenize.c",
-    "libvpx/vp8/decoder/onyxd_if.c",
-    "libvpx/vp8/decoder/threading.c",
-    "libvpx/vp8/encoder/bitstream.c",
-    "libvpx/vp8/encoder/boolhuff.c",
-    "libvpx/vp8/encoder/dct.c",
-    "libvpx/vp8/encoder/denoising.c",
-    "libvpx/vp8/encoder/encodeframe.c",
-    "libvpx/vp8/encoder/encodeintra.c",
-    "libvpx/vp8/encoder/encodemb.c",
-    "libvpx/vp8/encoder/encodemv.c",
-    "libvpx/vp8/encoder/ethreading.c",
-    "libvpx/vp8/encoder/lookahead.c",
-    "libvpx/vp8/encoder/mcomp.c",
     "libvpx/vp8/encoder/mips/msa/dct_msa.c",
     "libvpx/vp8/encoder/mips/msa/denoising_msa.c",
     "libvpx/vp8/encoder/mips/msa/encodeopt_msa.c",
     "libvpx/vp8/encoder/mips/msa/quantize_msa.c",
-    "libvpx/vp8/encoder/modecosts.c",
-    "libvpx/vp8/encoder/onyx_if.c",
-    "libvpx/vp8/encoder/pickinter.c",
-    "libvpx/vp8/encoder/picklpf.c",
-    "libvpx/vp8/encoder/ratectrl.c",
-    "libvpx/vp8/encoder/rdopt.c",
-    "libvpx/vp8/encoder/segmentation.c",
-    "libvpx/vp8/encoder/tokenize.c",
-    "libvpx/vp8/encoder/treewriter.c",
-    "libvpx/vp8/encoder/vp8_quantize.c",
-    "libvpx/vp8/vp8_cx_iface.c",
-    "libvpx/vp8/vp8_dx_iface.c",
     "libvpx/vp9/common/mips/msa/vp9_idct16x16_msa.c",
     "libvpx/vp9/common/mips/msa/vp9_idct4x4_msa.c",
     "libvpx/vp9/common/mips/msa/vp9_idct8x8_msa.c",
-    "libvpx/vp9/common/vp9_alloccommon.c",
-    "libvpx/vp9/common/vp9_blockd.c",
-    "libvpx/vp9/common/vp9_common_data.c",
-    "libvpx/vp9/common/vp9_entropy.c",
-    "libvpx/vp9/common/vp9_entropymode.c",
-    "libvpx/vp9/common/vp9_entropymv.c",
-    "libvpx/vp9/common/vp9_filter.c",
-    "libvpx/vp9/common/vp9_frame_buffers.c",
-    "libvpx/vp9/common/vp9_idct.c",
-    "libvpx/vp9/common/vp9_loopfilter.c",
-    "libvpx/vp9/common/vp9_mvref_common.c",
-    "libvpx/vp9/common/vp9_pred_common.c",
-    "libvpx/vp9/common/vp9_quant_common.c",
-    "libvpx/vp9/common/vp9_reconinter.c",
-    "libvpx/vp9/common/vp9_reconintra.c",
-    "libvpx/vp9/common/vp9_rtcd.c",
-    "libvpx/vp9/common/vp9_scale.c",
-    "libvpx/vp9/common/vp9_scan.c",
-    "libvpx/vp9/common/vp9_seg_common.c",
-    "libvpx/vp9/common/vp9_thread_common.c",
-    "libvpx/vp9/common/vp9_tile_common.c",
-    "libvpx/vp9/decoder/vp9_decodeframe.c",
-    "libvpx/vp9/decoder/vp9_decodemv.c",
-    "libvpx/vp9/decoder/vp9_decoder.c",
-    "libvpx/vp9/decoder/vp9_detokenize.c",
-    "libvpx/vp9/decoder/vp9_dsubexp.c",
-    "libvpx/vp9/decoder/vp9_dthread.c",
     "libvpx/vp9/encoder/mips/msa/vp9_error_msa.c",
     "libvpx/vp9/encoder/mips/msa/vp9_fdct16x16_msa.c",
     "libvpx/vp9/encoder/mips/msa/vp9_fdct4x4_msa.c",
     "libvpx/vp9/encoder/mips/msa/vp9_fdct8x8_msa.c",
-    "libvpx/vp9/encoder/vp9_alt_ref_aq.c",
-    "libvpx/vp9/encoder/vp9_aq_360.c",
-    "libvpx/vp9/encoder/vp9_aq_complexity.c",
-    "libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c",
-    "libvpx/vp9/encoder/vp9_aq_variance.c",
-    "libvpx/vp9/encoder/vp9_bitstream.c",
-    "libvpx/vp9/encoder/vp9_context_tree.c",
-    "libvpx/vp9/encoder/vp9_cost.c",
-    "libvpx/vp9/encoder/vp9_dct.c",
-    "libvpx/vp9/encoder/vp9_encodeframe.c",
-    "libvpx/vp9/encoder/vp9_encodemb.c",
-    "libvpx/vp9/encoder/vp9_encodemv.c",
-    "libvpx/vp9/encoder/vp9_encoder.c",
-    "libvpx/vp9/encoder/vp9_ethread.c",
-    "libvpx/vp9/encoder/vp9_extend.c",
-    "libvpx/vp9/encoder/vp9_firstpass.c",
-    "libvpx/vp9/encoder/vp9_frame_scale.c",
-    "libvpx/vp9/encoder/vp9_lookahead.c",
-    "libvpx/vp9/encoder/vp9_mbgraph.c",
-    "libvpx/vp9/encoder/vp9_mcomp.c",
-    "libvpx/vp9/encoder/vp9_multi_thread.c",
-    "libvpx/vp9/encoder/vp9_noise_estimate.c",
-    "libvpx/vp9/encoder/vp9_picklpf.c",
-    "libvpx/vp9/encoder/vp9_pickmode.c",
-    "libvpx/vp9/encoder/vp9_quantize.c",
-    "libvpx/vp9/encoder/vp9_ratectrl.c",
-    "libvpx/vp9/encoder/vp9_rd.c",
-    "libvpx/vp9/encoder/vp9_rdopt.c",
-    "libvpx/vp9/encoder/vp9_resize.c",
-    "libvpx/vp9/encoder/vp9_segmentation.c",
-    "libvpx/vp9/encoder/vp9_skin_detection.c",
-    "libvpx/vp9/encoder/vp9_speed_features.c",
-    "libvpx/vp9/encoder/vp9_subexp.c",
-    "libvpx/vp9/encoder/vp9_svc_layercontext.c",
-    "libvpx/vp9/encoder/vp9_temporal_filter.c",
-    "libvpx/vp9/encoder/vp9_tokenize.c",
-    "libvpx/vp9/encoder/vp9_treewriter.c",
-    "libvpx/vp9/vp9_cx_iface.c",
-    "libvpx/vp9/vp9_dx_iface.c",
-    "libvpx/vpx/src/vpx_codec.c",
-    "libvpx/vpx/src/vpx_decoder.c",
-    "libvpx/vpx/src/vpx_encoder.c",
-    "libvpx/vpx/src/vpx_image.c",
-    "libvpx/vpx_dsp/avg.c",
-    "libvpx/vpx_dsp/bitreader.c",
-    "libvpx/vpx_dsp/bitreader_buffer.c",
-    "libvpx/vpx_dsp/bitwriter.c",
-    "libvpx/vpx_dsp/bitwriter_buffer.c",
-    "libvpx/vpx_dsp/fwd_txfm.c",
-    "libvpx/vpx_dsp/intrapred.c",
-    "libvpx/vpx_dsp/inv_txfm.c",
-    "libvpx/vpx_dsp/loopfilter.c",
     "libvpx/vpx_dsp/mips/avg_msa.c",
     "libvpx/vpx_dsp/mips/fwd_dct32x32_msa.c",
     "libvpx/vpx_dsp/mips/fwd_txfm_msa.c",
@@ -1431,25 +862,13 @@
     "libvpx/vpx_dsp/mips/vpx_convolve8_vert_msa.c",
     "libvpx/vpx_dsp/mips/vpx_convolve_avg_msa.c",
     "libvpx/vpx_dsp/mips/vpx_convolve_copy_msa.c",
-    "libvpx/vpx_dsp/prob.c",
-    "libvpx/vpx_dsp/psnr.c",
-    "libvpx/vpx_dsp/quantize.c",
-    "libvpx/vpx_dsp/sad.c",
-    "libvpx/vpx_dsp/subtract.c",
-    "libvpx/vpx_dsp/sum_squares.c",
-    "libvpx/vpx_dsp/variance.c",
-    "libvpx/vpx_dsp/vpx_convolve.c",
-    "libvpx/vpx_dsp/vpx_dsp_rtcd.c",
-    "libvpx/vpx_mem/vpx_mem.c",
-    "libvpx/vpx_scale/generic/gen_scalers.c",
-    "libvpx/vpx_scale/generic/vpx_scale.c",
-    "libvpx/vpx_scale/generic/yv12config.c",
-    "libvpx/vpx_scale/generic/yv12extend.c",
-    "libvpx/vpx_scale/vpx_scale_rtcd.c",
-    "libvpx/vpx_util/vpx_thread.c",
     "config/mips64-msa/vpx_config.c",
 ]
 
+libvpx_mips64_msa_exclude_c_srcs = [
+    "config/mips64/vpx_config.c",
+]
+
 libvpx_mips64_c_srcs = [
     "libvpx/vp8/common/alloccommon.c",
     "libvpx/vp8/common/blockd.c",
@@ -2086,7 +1505,7 @@
             local_include_dirs: ["config/arm"],
 
             neon: {
-                exclude_srcs: libvpx_arm_c_srcs,
+                exclude_srcs: libvpx_arm_neon_exclude_c_srcs,
                 srcs: libvpx_arm_neon_c_srcs,
                 generated_sources: ["libvpx_arm_neon_asm_srcs_converted"],
                 local_include_dirs: ["config/arm-neon"],
@@ -2103,13 +1522,13 @@
             local_include_dirs: ["config/mips32"],
 
             dspr2: {
-                exclude_srcs: libvpx_mips32_c_srcs,
+                exclude_srcs: libvpx_mips32_dspr2_exclude_c_srcs,
                 srcs: libvpx_mips32_dspr2_c_srcs,
                 local_include_dirs: ["config/mips32-dspr2"],
             },
 
             msa: {
-                exclude_srcs: libvpx_mips32_c_srcs,
+                exclude_srcs: libvpx_mips32_msa_exclude_c_srcs,
                 srcs: libvpx_mips32_msa_c_srcs,
                 local_include_dirs: ["config/mips32-msa"],
             },
@@ -2120,7 +1539,7 @@
             local_include_dirs: ["config/mips64"],
 
             msa: {
-                exclude_srcs: libvpx_mips64_c_srcs,
+                exclude_srcs: libvpx_mips64_msa_exclude_c_srcs,
                 srcs: libvpx_mips64_msa_c_srcs,
                 local_include_dirs: ["config/mips64-msa"],
             },
diff --git a/Android.bp.in b/Android.bp.in
index ac6a464..f4039d8 100644
--- a/Android.bp.in
+++ b/Android.bp.in
@@ -28,7 +28,7 @@
             local_include_dirs: ["config/arm"],
 
             neon: {
-                exclude_srcs: libvpx_arm_c_srcs,
+                exclude_srcs: libvpx_arm_neon_exclude_c_srcs,
                 srcs: libvpx_arm_neon_c_srcs,
                 generated_sources: ["libvpx_arm_neon_asm_srcs_converted"],
                 local_include_dirs: ["config/arm-neon"],
@@ -45,13 +45,13 @@
             local_include_dirs: ["config/mips32"],
 
             dspr2: {
-                exclude_srcs: libvpx_mips32_c_srcs,
+                exclude_srcs: libvpx_mips32_dspr2_exclude_c_srcs,
                 srcs: libvpx_mips32_dspr2_c_srcs,
                 local_include_dirs: ["config/mips32-dspr2"],
             },
 
             msa: {
-                exclude_srcs: libvpx_mips32_c_srcs,
+                exclude_srcs: libvpx_mips32_msa_exclude_c_srcs,
                 srcs: libvpx_mips32_msa_c_srcs,
                 local_include_dirs: ["config/mips32-msa"],
             },
@@ -62,7 +62,7 @@
             local_include_dirs: ["config/mips64"],
 
             msa: {
-                exclude_srcs: libvpx_mips64_c_srcs,
+                exclude_srcs: libvpx_mips64_msa_exclude_c_srcs,
                 srcs: libvpx_mips64_msa_c_srcs,
                 local_include_dirs: ["config/mips64-msa"],
             },
diff --git a/generate_config.sh b/generate_config.sh
index 97e5a00..e2c34b5 100755
--- a/generate_config.sh
+++ b/generate_config.sh
@@ -139,23 +139,76 @@
   rm -rf vpx_config.* vpx_version.h
 }
 
+# Generate a text file containing sources for a config
+# $1 - Config
+function gen_source_list {
+  make_clean
+  if [[ "$1" = "mips"* ]] || [[ "$1" = "generic" ]]; then
+    config=$(print_config_basic $1)
+  else
+    config=$(print_config $1)
+  fi
+  make libvpx_srcs.txt target=libs $config > /dev/null
+  mv libvpx_srcs.txt libvpx_srcs_$1.txt
+}
+
+# Extract a list of C sources from a libvpx_srcs.txt file
+# $1 - path to libvpx_srcs.txt
+function libvpx_srcs_txt_to_c_srcs {
+    grep ".c$" $1 | grep -v "^vpx_config.c$" | awk '$0="\"libvpx/"$0"\","' | sort
+}
+
+# Extract a list of ASM sources from a libvpx_srcs.txt file
+# $1 - path to libvpx_srcs.txt
+function libvpx_srcs_txt_to_asm_srcs {
+    grep ".asm$" $1 | awk '$0="\"libvpx/"$0"\","' | sort
+}
+
 # Convert a list of sources to a blueprint file containing a variable
 # assignment.
-# $1 - Variable name prefix.
-# $2 - Input file.
-# $3 - Config directory.
+# $1 - Config
 function gen_bp_srcs {
-  echo "$1_c_srcs = ["
-  grep ".c$" $2 | grep -v "^vpx_config.c$" | awk '$0="\"libvpx/"$0"\","'
-  echo "\"$3/vpx_config.c\","
-  echo "]"
-  if grep -q ".asm$" $2; then
-    echo
-    echo "$1_asm_srcs = ["
-    grep ".asm$" $2 | awk '$0="\"libvpx/"$0"\","'
+  (
+    varprefix=libvpx_${1//-/_}
+    echo "${varprefix}_c_srcs = ["
+    libvpx_srcs_txt_to_c_srcs libvpx_srcs_$1.txt
+    echo "\"$LIBVPX_CONFIG_DIR/$1/vpx_config.c\","
     echo "]"
-  fi
-  echo
+    if grep -q ".asm$" libvpx_srcs_$1.txt; then
+      echo
+      echo "${varprefix}_asm_srcs = ["
+      libvpx_srcs_txt_to_asm_srcs libvpx_srcs_$1.txt
+      echo "]"
+    fi
+    echo
+  ) > config_$1.bp
+}
+
+# Convert a list of sources to a blueprint file containing a variable
+# assignment, relative to a reference config.
+# $1 - Config
+# $2 - Reference config
+function gen_bp_srcs_with_excludes {
+  (
+    varprefix=libvpx_${1//-/_}
+    echo "${varprefix}_c_srcs = ["
+    comm -23 <(libvpx_srcs_txt_to_c_srcs libvpx_srcs_$1.txt) <(libvpx_srcs_txt_to_c_srcs libvpx_srcs_$2.txt)
+    echo "\"$LIBVPX_CONFIG_DIR/$1/vpx_config.c\","
+    echo "]"
+    echo
+    echo "${varprefix}_exclude_c_srcs = ["
+    comm -13 <(libvpx_srcs_txt_to_c_srcs libvpx_srcs_$1.txt) <(libvpx_srcs_txt_to_c_srcs libvpx_srcs_$2.txt)
+    echo "\"$LIBVPX_CONFIG_DIR/$2/vpx_config.c\","
+    echo "]"
+    echo
+    if grep -q ".asm$" libvpx_srcs_$1.txt; then
+      echo
+      echo "${varprefix}_asm_srcs = ["
+      libvpx_srcs_txt_to_asm_srcs libvpx_srcs_$1.txt
+      echo "]"
+    fi
+    echo
+  ) > config_$1.bp
 }
 
 echo "Create temporary directory."
@@ -218,71 +271,31 @@
 ./configure --target=generic-gnu > /dev/null
 make_clean
 
-echo "Generate X86 source list."
-config=$(print_config x86)
-make_clean
-make libvpx_srcs.txt target=libs $config > /dev/null
-gen_bp_srcs libvpx_x86 libvpx_srcs.txt $LIBVPX_CONFIG_DIR/x86 > config_x86.bp
+echo "Generate source lists"
+gen_source_list x86
+gen_source_list x86_64
+gen_source_list arm
+gen_source_list arm-neon
+gen_source_list arm64
+gen_source_list mips32
+gen_source_list mips32-dspr2
+gen_source_list mips32-msa
+gen_source_list mips64
+gen_source_list mips64-msa
+gen_source_list generic
 
-echo "Generate X86_64 source list."
-config=$(print_config x86_64)
-make_clean
-make libvpx_srcs.txt target=libs $config > /dev/null
-gen_bp_srcs libvpx_x86_64 libvpx_srcs.txt $LIBVPX_CONFIG_DIR/x86_64 > config_x86_64.bp
-
-echo "Generate ARM source list."
-config=$(print_config arm)
-make_clean
-make libvpx_srcs.txt target=libs $config > /dev/null
-gen_bp_srcs libvpx_arm libvpx_srcs.txt $LIBVPX_CONFIG_DIR/arm > config_arm.bp
-
-echo "Generate ARM NEON source list."
-config=$(print_config arm-neon)
-make_clean
-make libvpx_srcs.txt target=libs $config > /dev/null
-gen_bp_srcs libvpx_arm_neon libvpx_srcs.txt $LIBVPX_CONFIG_DIR/arm-neon > config_arm-neon.bp
-
-echo "Generate ARM64 source list."
-config=$(print_config arm64)
-make_clean
-make libvpx_srcs.txt target=libs $config > /dev/null
-gen_bp_srcs libvpx_arm64 libvpx_srcs.txt $LIBVPX_CONFIG_DIR/arm64 > config_arm64.bp
-
-echo "Generate MIPS source list."
-config=$(print_config_basic mips32)
-make_clean
-make libvpx_srcs.txt target=libs $config > /dev/null
-gen_bp_srcs libvpx_mips32 libvpx_srcs.txt $LIBVPX_CONFIG_DIR/mips32 > config_mips32.bp
-
-echo "Generate MIPS DSPR2 source list."
-config=$(print_config_basic mips32-dspr2)
-make_clean
-make libvpx_srcs.txt target=libs $config > /dev/null
-gen_bp_srcs libvpx_mips32_dspr2 libvpx_srcs.txt $LIBVPX_CONFIG_DIR/mips32-dspr2 > config_mips32-dispr2.bp
-
-echo "Generate MIPS MSA source list."
-config=$(print_config_basic mips32-msa)
-make_clean
-make libvpx_srcs.txt target=libs $config > /dev/null
-gen_bp_srcs libvpx_mips32_msa libvpx_srcs.txt $LIBVPX_CONFIG_DIR/mips32-msa > config_mips32-msa.bp
-
-echo "Generate MIPS64 source list."
-config=$(print_config_basic mips64)
-make_clean
-make libvpx_srcs.txt target=libs $config > /dev/null
-gen_bp_srcs libvpx_mips64 libvpx_srcs.txt $LIBVPX_CONFIG_DIR/mips64 > config_mips64.bp
-
-echo "Generate MIPS64 MSA source list."
-config=$(print_config_basic mips64-msa)
-make_clean
-make libvpx_srcs.txt target=libs $config > /dev/null
-gen_bp_srcs libvpx_mips64_msa libvpx_srcs.txt $LIBVPX_CONFIG_DIR/mips64-msa > config_mips64-msa.bp
-
-echo "Generate GENERIC source list."
-config=$(print_config_basic generic)
-make_clean
-make libvpx_srcs.txt target=libs $config > /dev/null
-gen_bp_srcs libvpx_generic libvpx_srcs.txt $LIBVPX_CONFIG_DIR/generic > config_generic.bp
+echo "Convert to bp"
+gen_bp_srcs x86
+gen_bp_srcs x86_64
+gen_bp_srcs arm
+gen_bp_srcs_with_excludes arm-neon arm
+gen_bp_srcs arm64
+gen_bp_srcs mips32
+gen_bp_srcs_with_excludes mips32-dspr2 mips32
+gen_bp_srcs_with_excludes mips32-msa mips32
+gen_bp_srcs mips64
+gen_bp_srcs_with_excludes mips64-msa mips64
+gen_bp_srcs generic
 
 rm -f $BASE_DIR/Android.bp
 (