1b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com#!/bin/bash -e
2b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com#
3f03997481c72e948cfe3b06b3c9caf894b145d09mcgrathr@chromium.org# Copyright (c) 2012 The Chromium Authors. All rights reserved.
4b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com# Use of this source code is governed by a BSD-style license that can be
5b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com# found in the LICENSE file.
6b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com
7bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org# This script is used to generate .gypi, .gni files and files in the
8bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org# config/platform directories needed to build libvpx.
9b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com# Every time libvpx source code is updated just run this script.
10b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com#
11b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com# For example:
12b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com# $ ./generate_gypi.sh
13b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com#
14bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org# And this will update all the .gypi, .gni and config files needed.
1529e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org#
161a56a960efec162d5c45886b735c911a0c7216e6wjia@chromium.org# !!! It's highly recommended to install yasm before running this script.
17b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com
18a7ffde18ed261f2d570e0d9cb2ddc5ffc204b5ebtomfinegan@chromium.orgexport LC_ALL=C
19bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgBASE_DIR=$(pwd)
20b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.comLIBVPX_SRC_DIR="source/libvpx"
2129e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgLIBVPX_CONFIG_DIR="source/config"
22b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com
23bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org# Print license header.
2461b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org# $1 - Output base name
25bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgfunction write_license {
26bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "# This file is generated. Do not edit." >> $1
27bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "# Copyright (c) 2014 The Chromium Authors. All rights reserved." >> $1
2861b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  echo "# Use of this source code is governed by a BSD-style license that can be" >> $1
2961b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  echo "# found in the LICENSE file." >> $1
3061b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  echo "" >> $1
31bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org}
32bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org
33bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org# Print gypi boilerplate header.
34bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org# $1 - Output base name
35bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgfunction write_gypi_header {
3661b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  echo "{" >> $1
3761b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org}
3861b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org
39bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org# Print gypi boilerplate footer.
4061b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org# $1 - Output base name
4161b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.orgfunction write_gypi_footer {
4261b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  echo "}" >> $1
4361b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org}
4461b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org
45583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com# Generate a gypi with a list of source files.
46583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com# $1 - Array name for file list. This is processed with 'declare' below to
47583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com#      regenerate the array locally.
48583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com# $2 - Output file
49bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgfunction write_gypi {
50583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  # Convert the first argument back in to an array.
51bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  local readonly file_list=(${!1})
52583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com
53bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  rm -rf "$2"
54bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  write_license "$2"
55bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  write_gypi_header "$2"
5661b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org
57bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "  'sources': [" >> "$2"
58bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  for f in ${file_list[@]}
59583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  do
60bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    echo "    '<(libvpx_source)/$f'," >> "$2"
61583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  done
62bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "  ]," >> "$2"
63bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org
64bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  write_gypi_footer "$2"
65bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org}
66bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org
67bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org# Generate a gni with a list of source files.
68bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org# $1 - Array name for file list. This is processed with 'declare' below to
69bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org#      regenerate the array locally.
70bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org# $2 - GN variable name.
71bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org# $3 - Output file.
72bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgfunction write_gni {
73bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  # Convert the first argument back in to an array.
74bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  declare -a file_list=("${!1}")
7561b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org
76bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "$2 = [" >> "$3"
77bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  for f in $file_list
78bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  do
79bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    echo "  \"//third_party/libvpx/source/libvpx/$f\"," >> "$3"
80bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  done
81bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "]" >> "$3"
8261b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org}
8361b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org
8461b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org# Target template function
8561b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org# $1 - Array name for file list.
8661b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org# $2 - Output file
8761b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org# $3 - Target name
8861b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org# $4 - Compiler flag
8961b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.orgfunction write_target_definition {
9061b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  declare -a sources_list=("${!1}")
9161b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org
92bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "    {" >> "$2"
93bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      'target_name': '$3'," >> "$2"
94bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      'type': 'static_library'," >> "$2"
95bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      'include_dirs': [" >> "$2"
96bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "        'source/config/<(OS_CATEGORY)/<(target_arch_full)'," >> "$2"
97bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "        '<(libvpx_source)'," >> "$2"
98bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      ]," >> "$2"
99bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      'sources': [" >> "$2"
10061b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  for f in $sources_list
10161b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  do
10261b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org    echo "        '<(libvpx_source)/$f'," >> $2
10361b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  done
104bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      ]," >> "$2"
105f68663a0a0a29543fd17333f30123aa060152bb8thakis@chromium.org  if [[ $4 == fpu=neon ]]; then
106bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      'cflags!': [ '-mfpu=vfpv3-d16' ]," >> "$2"
107982d14793a8e42d2fa5e6e5e34bede17b4ba67e3thakis@chromium.org  echo "      'conditions': [" >> $2
108bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "        # Disable LTO in neon targets due to compiler bug" >> "$2"
109bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "        # crbug.com/408997" >> "$2"
110bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "        ['use_lto==1', {" >> "$2"
111bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "          'cflags!': [" >> "$2"
112bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "            '-flto'," >> "$2"
113bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "            '-ffat-lto-objects'," >> "$2"
114bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "          ]," >> "$2"
115bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "        }]," >> "$2"
116bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      ]," >> "$2"
117f68663a0a0a29543fd17333f30123aa060152bb8thakis@chromium.org  fi
118bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      'cflags': [ '-m$4', ]," >> "$2"
119bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      'xcode_settings': { 'OTHER_CFLAGS': [ '-m$4' ] }," >> "$2"
120a4adce5bbb555442ef2bc16174660255751f4cafjohannkoenig@chromium.org  if [[ $4 == avx* ]]; then
121bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      'msvs_settings': {" >> "$2"
122bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "        'VCCLCompilerTool': {" >> "$2"
123bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "          'EnableEnhancedInstructionSet': '3', # /arch:AVX" >> "$2"
124bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "        }," >> "$2"
125bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      }," >> "$2"
126563c46bb2d0e5d5c8b7d2c6c0c50f0283e9087dethakis@chromium.org  elif [[ $4 == ssse3 || $4 == sse4.1 ]]; then
127bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      'conditions': [" >> "$2"
128bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "        ['OS==\"win\" and clang==1', {" >> "$2"
129bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "          # cl.exe's /arch flag doesn't have a setting for SSSE3/4, and cl.exe" >> "$2"
130bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "          # doesn't need it for intrinsics. clang-cl does need it, though." >> "$2"
131bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "          'msvs_settings': {" >> "$2"
132bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "            'VCCLCompilerTool': { 'AdditionalOptions': [ '-m$4' ] }," >> "$2"
133bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "          }," >> "$2"
134bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "        }]," >> "$2"
135bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "      ]," >> "$2"
136a4adce5bbb555442ef2bc16174660255751f4cafjohannkoenig@chromium.org  fi
137bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "    }," >> "$2"
13861b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org}
13961b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org
14061b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org
14161b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org# Generate a gypi which applies additional compiler flags based on the file
14261b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org# name.
14361b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org# $1 - Array name for file list.
14461b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org# $2 - Output file
145bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgfunction write_intrinsics_gypi {
14661b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  declare -a file_list=("${!1}")
14761b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org
14861b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  local mmx_sources=$(echo "$file_list" | grep '_mmx\.c$')
14961b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  local sse2_sources=$(echo "$file_list" | grep '_sse2\.c$')
15061b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  local sse3_sources=$(echo "$file_list" | grep '_sse3\.c$')
15161b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  local ssse3_sources=$(echo "$file_list" | grep '_ssse3\.c$')
15261b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org  local sse4_1_sources=$(echo "$file_list" | grep '_sse4\.c$')
153d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org  local avx_sources=$(echo "$file_list" | grep '_avx\.c$')
154d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org  local avx2_sources=$(echo "$file_list" | grep '_avx2\.c$')
15546e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  local neon_sources=$(echo "$file_list" | grep '_neon\.c$')
15646e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org
157a9c9b43ac6ebca2e63a1e36a3f51b968d910d724johannkoenig@chromium.org  # Intrinsic functions and files are in flux. We can selectively generate them
15846e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  # but we can not selectively include them in libvpx.gyp. Throw some errors
15946e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  # when new targets are needed.
160a9c9b43ac6ebca2e63a1e36a3f51b968d910d724johannkoenig@chromium.org
161bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  rm -rf "$2"
162bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  write_license "$2"
163bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  write_gypi_header "$2"
16446e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org
165bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "  'targets': [" >> "$2"
16646e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org
16746e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  # x86[_64]
16846e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  if [ 0 -ne ${#mmx_sources} ]; then
169bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_target_definition mmx_sources[@] "$2" libvpx_intrinsics_mmx mmx
170a9c9b43ac6ebca2e63a1e36a3f51b968d910d724johannkoenig@chromium.org  fi
17146e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  if [ 0 -ne ${#sse2_sources} ]; then
172bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_target_definition sse2_sources[@] "$2" libvpx_intrinsics_sse2 sse2
173d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org  fi
1744e102294f462b09dfafdb310cdaa6e6f491b7965johannkoenig@chromium.org  if [ 0 -ne ${#sse3_sources} ]; then
175bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    #write_target_definition sse3_sources[@] "$2" libvpx_intrinsics_sse3 sse3
176d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org    echo "ERROR: Uncomment sse3 sections in libvpx.gyp"
177a9c9b43ac6ebca2e63a1e36a3f51b968d910d724johannkoenig@chromium.org    exit 1
178a9c9b43ac6ebca2e63a1e36a3f51b968d910d724johannkoenig@chromium.org  fi
17946e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  if [ 0 -ne ${#ssse3_sources} ]; then
180bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_target_definition ssse3_sources[@] "$2" libvpx_intrinsics_ssse3 ssse3
18146e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  fi
182a9c9b43ac6ebca2e63a1e36a3f51b968d910d724johannkoenig@chromium.org  if [ 0 -ne ${#sse4_1_sources} ]; then
183bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_target_definition sse4_1_sources[@] "$2" libvpx_intrinsics_sse4_1 sse4.1
184d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org  fi
185d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org  if [ 0 -ne ${#avx_sources} ]; then
186bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    #write_target_definition avx_sources[@] "$2" libvpx_intrinsics_avx avx
187d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org    echo "ERROR: Uncomment avx sections in libvpx.gyp"
1884e102294f462b09dfafdb310cdaa6e6f491b7965johannkoenig@chromium.org    exit 1
1894e102294f462b09dfafdb310cdaa6e6f491b7965johannkoenig@chromium.org  fi
190d3f9c4491419cfcdb6d754ad0a3797b970502429johannkoenig@chromium.org  if [ 0 -ne ${#avx2_sources} ]; then
191bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    #write_target_definition avx2_sources[@] "$2" libvpx_intrinsics_avx2 avx2
192d143273207449af253a5af27dbccab572e1f1cfcjohannkoenig@chromium.org    echo "ERROR: Uncomment avx2 sections in libvpx.gyp"
193d143273207449af253a5af27dbccab572e1f1cfcjohannkoenig@chromium.org    exit 1
194d3f9c4491419cfcdb6d754ad0a3797b970502429johannkoenig@chromium.org  fi
1954e102294f462b09dfafdb310cdaa6e6f491b7965johannkoenig@chromium.org
19646e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  # arm neon
19746e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  if [ 0 -ne ${#neon_sources} ]; then
198bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_target_definition neon_sources[@] "$2" libvpx_intrinsics_neon fpu=neon
19946e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  fi
20061b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org
201bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  echo "  ]," >> "$2"
20261b5f712cdf0800881382215642e896156786f15johannkoenig@chromium.org
203bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  write_gypi_footer "$2"
204583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com}
205583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com
206bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org# Convert a list of source files into gypi and gni files.
20729e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org# $1 - Input file.
208583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com# $2 - Output gypi file base. Will generate additional .gypi files when
209583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com#      different compilation flags are required.
210bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgfunction convert_srcs_to_project_files {
211b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com  # Do the following here:
212b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com  # 1. Filter .c, .h, .s, .S and .asm files.
213583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  # 2. Move certain files to a separate include to allow applying different
214583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  #    compiler options.
2156fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  # 3. Replace .asm.s to .asm because gyp will do the conversion.
216583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com
2176fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  local source_list=$(grep -E '(\.c|\.h|\.S|\.s|\.asm)$' $1)
218583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com
219583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  # _offsets are used in pre-processing to generate files for assembly. They are
220583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  # not part of the compiled library.
2216fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  source_list=$(echo "$source_list" | grep -v '_offsets\.c')
222583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com
223583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  # Not sure why vpx_config is not included.
2246fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  source_list=$(echo "$source_list" | grep -v 'vpx_config\.c')
225583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com
226583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  # The actual ARM files end in .asm. We have rules to translate them to .S
2276fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  source_list=$(echo "$source_list" | sed s/\.asm\.s$/.asm/)
228b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com
229583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  # Select all x86 files ending with .c
23046e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  local intrinsic_list=$(echo "$source_list" | \
231583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com    egrep 'vp[89]/(encoder|decoder|common)/x86/'  | \
232d851b91d14ef0bd71acdce7b90c9a8f1af1181adjohannkoenig@chromium.org    egrep '(mmx|sse2|sse3|ssse3|sse4|avx|avx2).c$')
233583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com
23446e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  # Select all neon files ending in C but only when building in RTCD mode
23546e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  if [ "libvpx_srcs_arm_neon_cpu_detect" == "$2" ]; then
23646e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org    # Select all arm neon files ending in _neon.c
23746e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org    # the pattern may need to be updated if vpx_scale gets intrinics
23846e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org    local intrinsic_list=$(echo "$source_list" | \
23946e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org      egrep 'vp[89]/(encoder|decoder|common)/arm/neon/'  | \
24046e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org      egrep '_neon.c$')
24146e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  fi
24246e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org
243583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  # Remove these files from the main list.
24446e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  source_list=$(comm -23 <(echo "$source_list") <(echo "$intrinsic_list"))
245583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com
246bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  local x86_list=$(echo "$source_list" | egrep '/x86/')
247bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org
248bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  write_gypi source_list "$BASE_DIR/$2.gypi"
249583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com
250583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  # All the files are in a single "element." Check if the first element has
251583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  # length 0.
25246e7370ed33aece3a89c9c9e1a9bd35cb531c5bajohannkoenig@chromium.org  if [ 0 -ne ${#intrinsic_list} ]; then
253bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_intrinsics_gypi intrinsic_list[@] "$BASE_DIR/$2_intrinsics.gypi"
254583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com  fi
255583e5bc4696de531f6705b21fac541a70bfdaafdjohannkoenig@google.com
256bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  # Write a single .gni file that includes all source files for all archs.
257bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  if [ 0 -ne ${#x86_list} ]; then
258bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    local c_sources=$(echo "$source_list" | egrep '.(c|h)$')
259bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    local assembly_sources=$(echo "$source_list" | egrep '.asm$')
260bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    local mmx_sources=$(echo "$intrinsic_list" | grep '_mmx\.c$')
261bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    local sse2_sources=$(echo "$intrinsic_list" | grep '_sse2\.c$')
262bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    local sse3_sources=$(echo "$intrinsic_list" | grep '_sse3\.c$')
263bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    local ssse3_sources=$(echo "$intrinsic_list" | grep '_ssse3\.c$')
264bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    local sse4_1_sources=$(echo "$intrinsic_list" | grep '_sse4\.c$')
265bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    local avx_sources=$(echo "$intrinsic_list" | grep '_avx\.c$')
266bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    local avx2_sources=$(echo "$intrinsic_list" | grep '_avx2\.c$')
267bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org
268bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_gni c_sources $2 "$BASE_DIR/libvpx_srcs.gni"
269bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_gni assembly_sources $2_assembly "$BASE_DIR/libvpx_srcs.gni"
270bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_gni mmx_sources $2_mmx "$BASE_DIR/libvpx_srcs.gni"
271bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_gni sse2_sources $2_sse2 "$BASE_DIR/libvpx_srcs.gni"
272bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_gni sse3_sources $2_sse3 "$BASE_DIR/libvpx_srcs.gni"
273bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_gni ssse3_sources $2_ssse3 "$BASE_DIR/libvpx_srcs.gni"
274bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_gni sse4_1_sources $2_sse4_1 "$BASE_DIR/libvpx_srcs.gni"
275bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_gni avx_sources $2_avx "$BASE_DIR/libvpx_srcs.gni"
276bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    write_gni avx2_sources $2_avx2 "$BASE_DIR/libvpx_srcs.gni"
277bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  else
2788064f37966e30866abedb5f454406b5a7b13318ehclam@chromium.org    local c_sources=$(echo "$source_list" | egrep '.(c|h)$')
2798064f37966e30866abedb5f454406b5a7b13318ehclam@chromium.org    local assembly_sources=$(echo "$source_list" | egrep '.asm$')
280bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    local neon_sources=$(echo "$intrinsic_list" | grep '_neon\.c$')
2818064f37966e30866abedb5f454406b5a7b13318ehclam@chromium.org    write_gni c_sources $2 "$BASE_DIR/libvpx_srcs.gni"
2828064f37966e30866abedb5f454406b5a7b13318ehclam@chromium.org    write_gni assembly_sources $2_assembly "$BASE_DIR/libvpx_srcs.gni"
283bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    if [ 0 -ne ${#neon_sources} ]; then
284bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org      write_gni neon_sources $2_neon "$BASE_DIR/libvpx_srcs.gni"
285bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org    fi
286bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org  fi
287b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com}
288b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com
28929e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org# Clean files from previous make.
29029e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgfunction make_clean {
29129e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org  make clean > /dev/null
29229e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org  rm -f libvpx_srcs.txt
29329e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org}
29429e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org
29529e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org# Lint a pair of vpx_config.h and vpx_config.asm to make sure they match.
29629e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org# $1 - Header file directory.
29729e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgfunction lint_config {
2987765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.org  # mips does not contain any assembly so the header does not need to be
2997765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.org  # compared to the asm.
300796a08a9ccb0ab5cb47ce24ff80aea3e085aa34fjohannkoenig@chromium.org  if [[ "$1" != *mipsel && "$1" != *mips64el ]]; then
3017765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.org    $BASE_DIR/lint_config.sh \
3027765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.org      -h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
3037765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.org      -a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm
3047765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.org  fi
30529e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org}
30629e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org
30729e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org# Print the configuration.
30829e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org# $1 - Header file directory.
30929e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgfunction print_config {
31029e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org  $BASE_DIR/lint_config.sh -p \
31129e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org    -h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
31229e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org    -a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm
31329e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org}
31429e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org
315e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com# Print the configuration from Header file.
316e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com# This function is an abridged version of print_config which does not use
317e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com# lint_config and it does not require existence of vpx_config.asm.
318e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com# $1 - Header file directory.
319e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.comfunction print_config_basic {
320e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com  combined_config="$(cat $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
321e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com                   | grep -E ' +[01] *$')"
322e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com  combined_config="$(echo "$combined_config" | grep -v DO1STROUNDING)"
323e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com  combined_config="$(echo "$combined_config" | sed 's/[ \t]//g')"
324e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com  combined_config="$(echo "$combined_config" | sed 's/.*define//')"
325e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com  combined_config="$(echo "$combined_config" | sed 's/0$/=no/')"
326e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com  combined_config="$(echo "$combined_config" | sed 's/1$/=yes/')"
327e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com  echo "$combined_config" | sort | uniq
328e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com}
329e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com
3306fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org# Generate *_rtcd.h files.
331e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.org# $1 - Header file directory.
332e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.org# $2 - Architecture.
333e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.orgfunction gen_rtcd_header {
3346fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  echo "Generate $LIBVPX_CONFIG_DIR/$1/*_rtcd.h files."
335e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.org
336e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.org  rm -rf $BASE_DIR/$TEMP_DIR/libvpx.config
337796a08a9ccb0ab5cb47ce24ff80aea3e085aa34fjohannkoenig@chromium.org  if [[ "$2" == "mipsel" || "$2" == "mips64el" ]]; then
338e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com    print_config_basic $1 > $BASE_DIR/$TEMP_DIR/libvpx.config
339e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com  else
340e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com    $BASE_DIR/lint_config.sh -p \
341e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com      -h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
342e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com      -a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm \
343e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com      -o $BASE_DIR/$TEMP_DIR/libvpx.config
344e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com  fi
345e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.org
34693a74791c8e808ea76001ee07693aa2a5fdd3500johannkoenig@chromium.org  $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.pl \
347e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.org    --arch=$2 \
3486fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    --sym=vp8_rtcd \
349e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.org    --config=$BASE_DIR/$TEMP_DIR/libvpx.config \
350497a01b086cc703ed01af8e8aeed3e5733ad8315johannkoenig@chromium.org    --disable-avx2 \
35193a74791c8e808ea76001ee07693aa2a5fdd3500johannkoenig@chromium.org    $BASE_DIR/$LIBVPX_SRC_DIR/vp8/common/rtcd_defs.pl \
3526fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vp8_rtcd.h
3536fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
35493a74791c8e808ea76001ee07693aa2a5fdd3500johannkoenig@chromium.org  $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.pl \
3556fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    --arch=$2 \
3566fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    --sym=vp9_rtcd \
3576fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    --config=$BASE_DIR/$TEMP_DIR/libvpx.config \
358497a01b086cc703ed01af8e8aeed3e5733ad8315johannkoenig@chromium.org    --disable-avx2 \
35993a74791c8e808ea76001ee07693aa2a5fdd3500johannkoenig@chromium.org    $BASE_DIR/$LIBVPX_SRC_DIR/vp9/common/vp9_rtcd_defs.pl \
3606fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vp9_rtcd.h
3616fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
36293a74791c8e808ea76001ee07693aa2a5fdd3500johannkoenig@chromium.org  $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.pl \
3636fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    --arch=$2 \
3646fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    --sym=vpx_scale_rtcd \
3656fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    --config=$BASE_DIR/$TEMP_DIR/libvpx.config \
366497a01b086cc703ed01af8e8aeed3e5733ad8315johannkoenig@chromium.org    --disable-avx2 \
36793a74791c8e808ea76001ee07693aa2a5fdd3500johannkoenig@chromium.org    $BASE_DIR/$LIBVPX_SRC_DIR/vpx_scale/vpx_scale_rtcd.pl \
3686fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_scale_rtcd.h
369e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.org
370e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.org  rm -rf $BASE_DIR/$TEMP_DIR/libvpx.config
371e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.org}
372e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.org
3736fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org# Generate Config files. "--enable-external-build" must be set to skip
3746fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org# detection of capabilities on specific targets.
3756fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org# $1 - Header file directory.
3766fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org# $2 - Config command line.
3776fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orgfunction gen_config_files {
3786fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  ./configure $2  > /dev/null
3796fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
3806fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  # Generate vpx_config.asm. Do not create one for mips.
381796a08a9ccb0ab5cb47ce24ff80aea3e085aa34fjohannkoenig@chromium.org  if [[ "$1" != *mipsel && "$1" != *mips64el ]]; then
3826fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    if [[ "$1" == *x64* ]] || [[ "$1" == *ia32* ]]; then
383bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org      egrep "#define [A-Z0-9_]+ [01]" vpx_config.h | awk '{print "%define " $2 " " $3}' > vpx_config.asm
3846fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    else
3856fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org      egrep "#define [A-Z0-9_]+ [01]" vpx_config.h | awk '{print $2 " EQU " $3}' | perl $BASE_DIR/$LIBVPX_SRC_DIR/build/make/ads2gas.pl > vpx_config.asm
3866fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org    fi
3876fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  fi
3886fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
3896fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  cp vpx_config.* $BASE_DIR/$LIBVPX_CONFIG_DIR/$1
3906fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  make_clean
3916fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org  rm -rf vpx_config.*
3926fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org}
3936fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
3946fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orgecho "Create temporary directory."
3956fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orgTEMP_DIR="$LIBVPX_SRC_DIR.temp"
3966fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orgrm -rf $TEMP_DIR
3976fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orgcp -R $LIBVPX_SRC_DIR $TEMP_DIR
3986fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orgcd $TEMP_DIR
3996fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
400bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgecho "Generate config files."
401d143273207449af253a5af27dbccab572e1f1cfcjohannkoenig@chromium.org# TODO(joeyparrish) Enable AVX2 when broader VS2013 support is available
402d143273207449af253a5af27dbccab572e1f1cfcjohannkoenig@chromium.orgall_platforms="--enable-external-build --enable-postproc --disable-install-srcs --enable-multi-res-encoding --enable-temporal-denoising --disable-unit-tests --disable-install-docs --disable-examples --disable-avx2"
4039c920af5cd2f78ab30bb06f01f4a4d9d30d5c92bfgalligan@chromium.orggen_config_files linux/ia32 "--target=x86-linux-gcc --disable-ccache --enable-pic --enable-realtime-only ${all_platforms}"
4046fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orggen_config_files linux/x64 "--target=x86_64-linux-gcc --disable-ccache --enable-pic --enable-realtime-only ${all_platforms}"
405db9ac6c76553d95d7eb35e2bcf84c16a7901c3c3fgalligan@chromium.orggen_config_files linux/arm "--target=armv6-linux-gcc --enable-pic --enable-realtime-only --disable-install-bins --disable-install-libs --disable-edsp ${all_platforms}"
406db9ac6c76553d95d7eb35e2bcf84c16a7901c3c3fgalligan@chromium.orggen_config_files linux/arm-neon "--target=armv7-linux-gcc --enable-pic --enable-realtime-only --disable-edsp ${all_platforms}"
407db9ac6c76553d95d7eb35e2bcf84c16a7901c3c3fgalligan@chromium.orggen_config_files linux/arm-neon-cpu-detect "--target=armv7-linux-gcc --enable-pic --enable-realtime-only --enable-runtime-cpu-detect --disable-edsp ${all_platforms}"
408db9ac6c76553d95d7eb35e2bcf84c16a7901c3c3fgalligan@chromium.orggen_config_files linux/arm64 "--force-target=armv8-linux-gcc --enable-pic --enable-realtime-only --disable-edsp ${all_platforms}"
4096fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orggen_config_files linux/mipsel "--target=mips32-linux-gcc --disable-fast-unaligned ${all_platforms}"
410796a08a9ccb0ab5cb47ce24ff80aea3e085aa34fjohannkoenig@chromium.orggen_config_files linux/mips64el "--target=mips64-linux-gcc --disable-fast-unaligned ${all_platforms}"
41167a841642657cfd799c8b84cbdd2b0b85811514aearthdok@chromium.orggen_config_files linux/generic "--target=generic-gnu --enable-pic --enable-realtime-only ${all_platforms}"
412a4adce5bbb555442ef2bc16174660255751f4cafjohannkoenig@chromium.orggen_config_files win/ia32 "--target=x86-win32-vs12 --enable-realtime-only ${all_platforms}"
413a4adce5bbb555442ef2bc16174660255751f4cafjohannkoenig@chromium.orggen_config_files win/x64 "--target=x86_64-win64-vs12 --enable-realtime-only ${all_platforms}"
4149c920af5cd2f78ab30bb06f01f4a4d9d30d5c92bfgalligan@chromium.orggen_config_files mac/ia32 "--target=x86-darwin9-gcc --enable-pic --enable-realtime-only ${all_platforms}"
4156fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orggen_config_files mac/x64 "--target=x86_64-darwin9-gcc --enable-pic --enable-realtime-only ${all_platforms}"
416d5b5d74c44c300df0a4b2d288834e2c7d3e621d8sergeyu@chromium.orggen_config_files nacl "--target=generic-gnu --enable-pic --enable-realtime-only ${all_platforms}"
4176fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
4186fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orgecho "Remove temporary directory."
4196fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orgcd $BASE_DIR
4206fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orgrm -rf $TEMP_DIR
4216fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
42229e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgecho "Lint libvpx configuration."
42329e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orglint_config linux/ia32
42429e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orglint_config linux/x64
42529e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orglint_config linux/arm
42629e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orglint_config linux/arm-neon
4271a56a960efec162d5c45886b735c911a0c7216e6wjia@chromium.orglint_config linux/arm-neon-cpu-detect
4287765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.orglint_config linux/arm64
4297765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.orglint_config linux/mipsel
430796a08a9ccb0ab5cb47ce24ff80aea3e085aa34fjohannkoenig@chromium.orglint_config linux/mips64el
43167a841642657cfd799c8b84cbdd2b0b85811514aearthdok@chromium.orglint_config linux/generic
43229e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orglint_config win/ia32
4338ae1e8e2c7efa47d8464e8a3205dbfaed138690ffgalligan@chromium.orglint_config win/x64
43429e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orglint_config mac/ia32
4359cfd6feeaf43398646dc6027d64f9f17bdb5d24abadea@adobe.comlint_config mac/x64
436d5b5d74c44c300df0a4b2d288834e2c7d3e621d8sergeyu@chromium.orglint_config nacl
43729e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.org
438b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.comecho "Create temporary directory."
439b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.comTEMP_DIR="$LIBVPX_SRC_DIR.temp"
44029e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgrm -rf $TEMP_DIR
441b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.comcp -R $LIBVPX_SRC_DIR $TEMP_DIR
442b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.comcd $TEMP_DIR
443b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com
444e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.orggen_rtcd_header linux/ia32 x86
445e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.orggen_rtcd_header linux/x64 x86_64
446e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.orggen_rtcd_header linux/arm armv6
447e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.orggen_rtcd_header linux/arm-neon armv7
4481a56a960efec162d5c45886b735c911a0c7216e6wjia@chromium.orggen_rtcd_header linux/arm-neon-cpu-detect armv7
4497765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.orggen_rtcd_header linux/arm64 armv8
450e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.comgen_rtcd_header linux/mipsel mipsel
451796a08a9ccb0ab5cb47ce24ff80aea3e085aa34fjohannkoenig@chromium.orggen_rtcd_header linux/mips64el mips64el
45267a841642657cfd799c8b84cbdd2b0b85811514aearthdok@chromium.orggen_rtcd_header linux/generic generic
453e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.orggen_rtcd_header win/ia32 x86
4548ae1e8e2c7efa47d8464e8a3205dbfaed138690ffgalligan@chromium.orggen_rtcd_header win/x64 x86_64
455e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.orggen_rtcd_header mac/ia32 x86
4569cfd6feeaf43398646dc6027d64f9f17bdb5d24abadea@adobe.comgen_rtcd_header mac/x64 x86_64
457d5b5d74c44c300df0a4b2d288834e2c7d3e621d8sergeyu@chromium.orggen_rtcd_header nacl nacl
458e028001786c60e2c9deff0c3a913afa57a99d8d6hclam@chromium.org
459b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.comecho "Prepare Makefile."
460b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com./configure --target=generic-gnu > /dev/null
46129e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgmake_clean
462b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com
463bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org# Remove existing .gni file.
464bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgrm -rf $BASE_DIR/libvpx_srcs.gni
465bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgwrite_license $BASE_DIR/libvpx_srcs.gni
466bd09f762630df926103d21373961ced61ca0a653hclam@chromium.org
467b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.comecho "Generate X86 source list."
46829e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgconfig=$(print_config linux/ia32)
46929e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgmake_clean
47029e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgmake libvpx_srcs.txt target=libs $config > /dev/null
471bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgconvert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_x86
472b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com
4736fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org# Copy vpx_version.h. The file should be the same for all platforms.
4746fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.orgcp vpx_version.h $BASE_DIR/$LIBVPX_CONFIG_DIR
4756fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
476b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.comecho "Generate X86_64 source list."
47729e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgconfig=$(print_config linux/x64)
47829e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgmake_clean
47929e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgmake libvpx_srcs.txt target=libs $config > /dev/null
480bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgconvert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_x86_64
481b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com
482b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.comecho "Generate ARM source list."
48329e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgconfig=$(print_config linux/arm)
48429e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgmake_clean
48529e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgmake libvpx_srcs.txt target=libs $config > /dev/null
486bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgconvert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_arm
487b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com
488b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.comecho "Generate ARM NEON source list."
48929e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgconfig=$(print_config linux/arm-neon)
49029e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgmake_clean
49129e0140f8a477eccdfe8bbc82ac0b25415c941f7hclam@chromium.orgmake libvpx_srcs.txt target=libs $config > /dev/null
492bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgconvert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_arm_neon
493b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.com
4941a56a960efec162d5c45886b735c911a0c7216e6wjia@chromium.orgecho "Generate ARM NEON CPU DETECT source list."
4951a56a960efec162d5c45886b735c911a0c7216e6wjia@chromium.orgconfig=$(print_config linux/arm-neon-cpu-detect)
4961a56a960efec162d5c45886b735c911a0c7216e6wjia@chromium.orgmake_clean
4971a56a960efec162d5c45886b735c911a0c7216e6wjia@chromium.orgmake libvpx_srcs.txt target=libs $config > /dev/null
498bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgconvert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_arm_neon_cpu_detect
4991a56a960efec162d5c45886b735c911a0c7216e6wjia@chromium.org
5007765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.orgecho "Generate ARM64 source list."
5017765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.orgconfig=$(print_config linux/arm64)
5027765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.orgmake_clean
5037765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.orgmake libvpx_srcs.txt target=libs $config > /dev/null
504bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgconvert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_arm64
5057765c078fa920ba6c949c15f16b6cc979d8bb95bjohannkoenig@chromium.org
506e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.comecho "Generate MIPS source list."
507e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.comconfig=$(print_config_basic linux/mipsel)
508e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.commake_clean
509e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.commake libvpx_srcs.txt target=libs $config > /dev/null
510bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgconvert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_mips
511e1837fb6c0c201b561feb135d25b601351fb6999petarj@mips.com
512796a08a9ccb0ab5cb47ce24ff80aea3e085aa34fjohannkoenig@chromium.orgecho "MIPS64 source list is identical to MIPS source list. No need to generate it."
513796a08a9ccb0ab5cb47ce24ff80aea3e085aa34fjohannkoenig@chromium.org
514d5b5d74c44c300df0a4b2d288834e2c7d3e621d8sergeyu@chromium.orgecho "Generate NaCl source list."
515d5b5d74c44c300df0a4b2d288834e2c7d3e621d8sergeyu@chromium.orgconfig=$(print_config_basic nacl)
516d5b5d74c44c300df0a4b2d288834e2c7d3e621d8sergeyu@chromium.orgmake_clean
517d5b5d74c44c300df0a4b2d288834e2c7d3e621d8sergeyu@chromium.orgmake libvpx_srcs.txt target=libs $config > /dev/null
518bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgconvert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_nacl
519d5b5d74c44c300df0a4b2d288834e2c7d3e621d8sergeyu@chromium.org
52067a841642657cfd799c8b84cbdd2b0b85811514aearthdok@chromium.orgecho "Generate GENERIC source list."
52167a841642657cfd799c8b84cbdd2b0b85811514aearthdok@chromium.orgconfig=$(print_config_basic linux/generic)
52267a841642657cfd799c8b84cbdd2b0b85811514aearthdok@chromium.orgmake_clean
52367a841642657cfd799c8b84cbdd2b0b85811514aearthdok@chromium.orgmake libvpx_srcs.txt target=libs $config > /dev/null
524bd09f762630df926103d21373961ced61ca0a653hclam@chromium.orgconvert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_generic
52567a841642657cfd799c8b84cbdd2b0b85811514aearthdok@chromium.org
526b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.comecho "Remove temporary directory."
527b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.comcd $BASE_DIR
528b3c3acc1cc5528d92ba97dee9602ad7fb87b53bfchrome-bot@google.comrm -rf $TEMP_DIR
5296fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org
5306fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org# TODO(fgalligan): Is "--disable-fast-unaligned" needed on mipsel?
5316fefe538d859300e7febe78271828198c10f1b52fgalligan@chromium.org# TODO(fgalligan): Can we turn on "--enable-realtime-only" for mipsel?
532