blob: 594bb637869f76af3f6ff2925dfb3c70156ec535 [file] [log] [blame]
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +00001#!/bin/bash -e
2#
mcgrathr@chromium.orgf0399742012-01-11 20:14:59 +00003# Copyright (c) 2012 The Chromium Authors. All rights reserved.
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +00004# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
hclam@chromium.orgbd09f762014-09-05 21:22:35 +00007# This script is used to generate .gypi, .gni files and files in the
8# config/platform directories needed to build libvpx.
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +00009# Every time libvpx source code is updated just run this script.
10#
11# For example:
12# $ ./generate_gypi.sh
13#
hclam@chromium.orgbd09f762014-09-05 21:22:35 +000014# And this will update all the .gypi, .gni and config files needed.
hclam@chromium.org29e01402012-05-30 20:41:48 +000015#
wjia@chromium.org1a56a962013-03-11 21:02:06 +000016# !!! It's highly recommended to install yasm before running this script.
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +000017
tomfinegan@chromium.orga7ffde12014-03-28 00:05:23 +000018export LC_ALL=C
hclam@chromium.orgbd09f762014-09-05 21:22:35 +000019BASE_DIR=$(pwd)
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +000020LIBVPX_SRC_DIR="source/libvpx"
hclam@chromium.org29e01402012-05-30 20:41:48 +000021LIBVPX_CONFIG_DIR="source/config"
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +000022
hclam@chromium.orgbd09f762014-09-05 21:22:35 +000023# Print license header.
johannkoenig@chromium.org61b5f712013-04-02 20:18:06 +000024# $1 - Output base name
hclam@chromium.orgbd09f762014-09-05 21:22:35 +000025function write_license {
26 echo "# This file is generated. Do not edit." >> $1
27 echo "# Copyright (c) 2014 The Chromium Authors. All rights reserved." >> $1
johannkoenig@chromium.org61b5f712013-04-02 20:18:06 +000028 echo "# Use of this source code is governed by a BSD-style license that can be" >> $1
29 echo "# found in the LICENSE file." >> $1
30 echo "" >> $1
hclam@chromium.orgbd09f762014-09-05 21:22:35 +000031}
32
33# Print gypi boilerplate header.
34# $1 - Output base name
35function write_gypi_header {
johannkoenig@chromium.org61b5f712013-04-02 20:18:06 +000036 echo "{" >> $1
37}
38
hclam@chromium.orgbd09f762014-09-05 21:22:35 +000039# Print gypi boilerplate footer.
johannkoenig@chromium.org61b5f712013-04-02 20:18:06 +000040# $1 - Output base name
41function write_gypi_footer {
42 echo "}" >> $1
43}
44
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +000045# Generate a gypi with a list of source files.
46# $1 - Array name for file list. This is processed with 'declare' below to
47# regenerate the array locally.
48# $2 - Output file
hclam@chromium.orgbd09f762014-09-05 21:22:35 +000049function write_gypi {
50 # Convert the first argument back in to an array.
51 local readonly file_list=(${!1})
52
53 rm -rf "$2"
54 write_license "$2"
55 write_gypi_header "$2"
56
57 echo " 'sources': [" >> "$2"
58 for f in ${file_list[@]}
59 do
60 echo " '<(libvpx_source)/$f'," >> "$2"
61 done
62 echo " ]," >> "$2"
63
64 write_gypi_footer "$2"
65}
66
67# Generate a gni with a list of source files.
68# $1 - Array name for file list. This is processed with 'declare' below to
69# regenerate the array locally.
70# $2 - GN variable name.
71# $3 - Output file.
72function write_gni {
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +000073 # Convert the first argument back in to an array.
74 declare -a file_list=("${!1}")
75
hclam@chromium.orgbd09f762014-09-05 21:22:35 +000076 echo "$2 = [" >> "$3"
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +000077 for f in $file_list
78 do
hclam@chromium.orgbd09f762014-09-05 21:22:35 +000079 echo " \"//third_party/libvpx/source/libvpx/$f\"," >> "$3"
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +000080 done
hclam@chromium.orgbd09f762014-09-05 21:22:35 +000081 echo "]" >> "$3"
johannkoenig@chromium.org61b5f712013-04-02 20:18:06 +000082}
83
84# Target template function
85# $1 - Array name for file list.
86# $2 - Output file
87# $3 - Target name
88# $4 - Compiler flag
89function write_target_definition {
90 declare -a sources_list=("${!1}")
91
hclam@chromium.orgbd09f762014-09-05 21:22:35 +000092 echo " {" >> "$2"
93 echo " 'target_name': '$3'," >> "$2"
94 echo " 'type': 'static_library'," >> "$2"
95 echo " 'include_dirs': [" >> "$2"
96 echo " 'source/config/<(OS_CATEGORY)/<(target_arch_full)'," >> "$2"
97 echo " '<(libvpx_source)'," >> "$2"
98 echo " ]," >> "$2"
99 echo " 'sources': [" >> "$2"
johannkoenig@chromium.org61b5f712013-04-02 20:18:06 +0000100 for f in $sources_list
101 do
102 echo " '<(libvpx_source)/$f'," >> $2
103 done
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000104 echo " ]," >> "$2"
thakis@chromium.orgf68663a2014-08-26 00:24:58 +0000105 if [[ $4 == fpu=neon ]]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000106 echo " 'cflags!': [ '-mfpu=vfpv3-d16' ]," >> "$2"
thakis@chromium.org982d1472014-08-29 15:23:06 +0000107 echo " 'conditions': [" >> $2
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000108 echo " # Disable LTO in neon targets due to compiler bug" >> "$2"
109 echo " # crbug.com/408997" >> "$2"
110 echo " ['use_lto==1', {" >> "$2"
111 echo " 'cflags!': [" >> "$2"
112 echo " '-flto'," >> "$2"
113 echo " '-ffat-lto-objects'," >> "$2"
114 echo " ]," >> "$2"
115 echo " }]," >> "$2"
116 echo " ]," >> "$2"
johannkoenig@chromium.orga4adce52014-04-15 23:01:37 +0000117 fi
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000118 echo " 'cflags': [ '-m$4', ]," >> "$2"
119 echo " 'xcode_settings': { 'OTHER_CFLAGS': [ '-m$4' ] }," >> "$2"
thakis@chromium.orgf68663a2014-08-26 00:24:58 +0000120 if [[ $4 == avx* ]]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000121 echo " 'msvs_settings': {" >> "$2"
122 echo " 'VCCLCompilerTool': {" >> "$2"
123 echo " 'EnableEnhancedInstructionSet': '3', # /arch:AVX" >> "$2"
124 echo " }," >> "$2"
125 echo " }," >> "$2"
thakis@chromium.org563c46b2014-08-26 02:25:28 +0000126 elif [[ $4 == ssse3 || $4 == sse4.1 ]]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000127 echo " 'conditions': [" >> "$2"
128 echo " ['OS==\"win\" and clang==1', {" >> "$2"
129 echo " # cl.exe's /arch flag doesn't have a setting for SSSE3/4, and cl.exe" >> "$2"
130 echo " # doesn't need it for intrinsics. clang-cl does need it, though." >> "$2"
131 echo " 'msvs_settings': {" >> "$2"
132 echo " 'VCCLCompilerTool': { 'AdditionalOptions': [ '-m$4' ] }," >> "$2"
133 echo " }," >> "$2"
134 echo " }]," >> "$2"
135 echo " ]," >> "$2"
thakis@chromium.orgf68663a2014-08-26 00:24:58 +0000136 fi
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000137 echo " }," >> "$2"
johannkoenig@chromium.org61b5f712013-04-02 20:18:06 +0000138}
139
140
141# Generate a gypi which applies additional compiler flags based on the file
142# name.
143# $1 - Array name for file list.
144# $2 - Output file
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000145function write_intrinsics_gypi {
johannkoenig@chromium.org61b5f712013-04-02 20:18:06 +0000146 declare -a file_list=("${!1}")
147
148 local mmx_sources=$(echo "$file_list" | grep '_mmx\.c$')
149 local sse2_sources=$(echo "$file_list" | grep '_sse2\.c$')
150 local sse3_sources=$(echo "$file_list" | grep '_sse3\.c$')
151 local ssse3_sources=$(echo "$file_list" | grep '_ssse3\.c$')
152 local sse4_1_sources=$(echo "$file_list" | grep '_sse4\.c$')
johannkoenig@chromium.orgd851b912013-12-16 19:49:40 +0000153 local avx_sources=$(echo "$file_list" | grep '_avx\.c$')
154 local avx2_sources=$(echo "$file_list" | grep '_avx2\.c$')
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000155 local neon_sources=$(echo "$file_list" | grep '_neon\.c$')
156
johannkoenig@chromium.orga9c9b432013-04-19 22:20:08 +0000157 # Intrinsic functions and files are in flux. We can selectively generate them
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000158 # but we can not selectively include them in libvpx.gyp. Throw some errors
159 # when new targets are needed.
johannkoenig@chromium.org4e102292013-04-03 21:30:23 +0000160
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000161 rm -rf "$2"
162 write_license "$2"
163 write_gypi_header "$2"
johannkoenig@chromium.org61b5f712013-04-02 20:18:06 +0000164
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000165 echo " 'targets': [" >> "$2"
johannkoenig@chromium.org61b5f712013-04-02 20:18:06 +0000166
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000167 # x86[_64]
168 if [ 0 -ne ${#mmx_sources} ]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000169 write_target_definition mmx_sources[@] "$2" libvpx_intrinsics_mmx mmx
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000170 fi
171 if [ 0 -ne ${#sse2_sources} ]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000172 write_target_definition sse2_sources[@] "$2" libvpx_intrinsics_sse2 sse2
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000173 fi
174 if [ 0 -ne ${#sse3_sources} ]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000175 #write_target_definition sse3_sources[@] "$2" libvpx_intrinsics_sse3 sse3
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000176 echo "ERROR: Uncomment sse3 sections in libvpx.gyp"
177 exit 1
178 fi
179 if [ 0 -ne ${#ssse3_sources} ]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000180 write_target_definition ssse3_sources[@] "$2" libvpx_intrinsics_ssse3 ssse3
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000181 fi
182 if [ 0 -ne ${#sse4_1_sources} ]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000183 write_target_definition sse4_1_sources[@] "$2" libvpx_intrinsics_sse4_1 sse4.1
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000184 fi
185 if [ 0 -ne ${#avx_sources} ]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000186 #write_target_definition avx_sources[@] "$2" libvpx_intrinsics_avx avx
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000187 echo "ERROR: Uncomment avx sections in libvpx.gyp"
188 exit 1
189 fi
190 if [ 0 -ne ${#avx2_sources} ]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000191 #write_target_definition avx2_sources[@] "$2" libvpx_intrinsics_avx2 avx2
johannkoenig@chromium.orgd1432732014-04-16 20:40:56 +0000192 echo "ERROR: Uncomment avx2 sections in libvpx.gyp"
193 exit 1
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000194 fi
195
196 # arm neon
197 if [ 0 -ne ${#neon_sources} ]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000198 write_target_definition neon_sources[@] "$2" libvpx_intrinsics_neon fpu=neon
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000199 fi
johannkoenig@chromium.org61b5f712013-04-02 20:18:06 +0000200
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000201 echo " ]," >> "$2"
johannkoenig@chromium.org61b5f712013-04-02 20:18:06 +0000202
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000203 write_gypi_footer "$2"
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000204}
205
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000206# Convert a list of source files into gypi and gni files.
hclam@chromium.org29e01402012-05-30 20:41:48 +0000207# $1 - Input file.
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000208# $2 - Output gypi file base. Will generate additional .gypi files when
209# different compilation flags are required.
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000210function convert_srcs_to_project_files {
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000211 # Do the following here:
212 # 1. Filter .c, .h, .s, .S and .asm files.
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000213 # 2. Move certain files to a separate include to allow applying different
214 # compiler options.
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000215 # 3. Replace .asm.s to .asm because gyp will do the conversion.
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000216
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000217 local source_list=$(grep -E '(\.c|\.h|\.S|\.s|\.asm)$' $1)
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000218
219 # _offsets are used in pre-processing to generate files for assembly. They are
220 # not part of the compiled library.
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000221 source_list=$(echo "$source_list" | grep -v '_offsets\.c')
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000222
223 # Not sure why vpx_config is not included.
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000224 source_list=$(echo "$source_list" | grep -v 'vpx_config\.c')
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000225
226 # The actual ARM files end in .asm. We have rules to translate them to .S
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000227 source_list=$(echo "$source_list" | sed s/\.asm\.s$/.asm/)
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000228
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000229 # Select all x86 files ending with .c
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000230 local intrinsic_list=$(echo "$source_list" | \
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000231 egrep 'vp[89]/(encoder|decoder|common)/x86/' | \
johannkoenig@chromium.orgd851b912013-12-16 19:49:40 +0000232 egrep '(mmx|sse2|sse3|ssse3|sse4|avx|avx2).c$')
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000233
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000234 # Select all neon files ending in C but only when building in RTCD mode
235 if [ "libvpx_srcs_arm_neon_cpu_detect" == "$2" ]; then
236 # Select all arm neon files ending in _neon.c
237 # the pattern may need to be updated if vpx_scale gets intrinics
238 local intrinsic_list=$(echo "$source_list" | \
239 egrep 'vp[89]/(encoder|decoder|common)/arm/neon/' | \
240 egrep '_neon.c$')
241 fi
242
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000243 # Remove these files from the main list.
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000244 source_list=$(comm -23 <(echo "$source_list") <(echo "$intrinsic_list"))
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000245
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000246 local x86_list=$(echo "$source_list" | egrep '/x86/')
247
248 write_gypi source_list "$BASE_DIR/$2.gypi"
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000249
250 # All the files are in a single "element." Check if the first element has
251 # length 0.
johannkoenig@chromium.org46e73702014-01-29 05:35:19 +0000252 if [ 0 -ne ${#intrinsic_list} ]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000253 write_intrinsics_gypi intrinsic_list[@] "$BASE_DIR/$2_intrinsics.gypi"
johannkoenig@google.com583e5bc2013-03-25 21:28:18 +0000254 fi
255
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000256 # Write a single .gni file that includes all source files for all archs.
257 if [ 0 -ne ${#x86_list} ]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000258 local c_sources=$(echo "$source_list" | egrep '.(c|h)$')
259 local assembly_sources=$(echo "$source_list" | egrep '.asm$')
260 local mmx_sources=$(echo "$intrinsic_list" | grep '_mmx\.c$')
261 local sse2_sources=$(echo "$intrinsic_list" | grep '_sse2\.c$')
262 local sse3_sources=$(echo "$intrinsic_list" | grep '_sse3\.c$')
263 local ssse3_sources=$(echo "$intrinsic_list" | grep '_ssse3\.c$')
264 local sse4_1_sources=$(echo "$intrinsic_list" | grep '_sse4\.c$')
265 local avx_sources=$(echo "$intrinsic_list" | grep '_avx\.c$')
266 local avx2_sources=$(echo "$intrinsic_list" | grep '_avx2\.c$')
267
268 write_gni c_sources $2 "$BASE_DIR/libvpx_srcs.gni"
269 write_gni assembly_sources $2_assembly "$BASE_DIR/libvpx_srcs.gni"
270 write_gni mmx_sources $2_mmx "$BASE_DIR/libvpx_srcs.gni"
271 write_gni sse2_sources $2_sse2 "$BASE_DIR/libvpx_srcs.gni"
272 write_gni sse3_sources $2_sse3 "$BASE_DIR/libvpx_srcs.gni"
273 write_gni ssse3_sources $2_ssse3 "$BASE_DIR/libvpx_srcs.gni"
274 write_gni sse4_1_sources $2_sse4_1 "$BASE_DIR/libvpx_srcs.gni"
275 write_gni avx_sources $2_avx "$BASE_DIR/libvpx_srcs.gni"
276 write_gni avx2_sources $2_avx2 "$BASE_DIR/libvpx_srcs.gni"
277 else
hclam@chromium.org8064f372014-09-13 00:28:02 +0000278 local c_sources=$(echo "$source_list" | egrep '.(c|h)$')
279 local assembly_sources=$(echo "$source_list" | egrep '.asm$')
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000280 local neon_sources=$(echo "$intrinsic_list" | grep '_neon\.c$')
hclam@chromium.org8064f372014-09-13 00:28:02 +0000281 write_gni c_sources $2 "$BASE_DIR/libvpx_srcs.gni"
282 write_gni assembly_sources $2_assembly "$BASE_DIR/libvpx_srcs.gni"
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000283 if [ 0 -ne ${#neon_sources} ]; then
284 write_gni neon_sources $2_neon "$BASE_DIR/libvpx_srcs.gni"
285 fi
286 fi
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000287}
288
hclam@chromium.org29e01402012-05-30 20:41:48 +0000289# Clean files from previous make.
290function make_clean {
291 make clean > /dev/null
292 rm -f libvpx_srcs.txt
293}
294
295# Lint a pair of vpx_config.h and vpx_config.asm to make sure they match.
296# $1 - Header file directory.
297function lint_config {
johannkoenig@chromium.org7765c072014-05-16 15:51:21 +0000298 # mips does not contain any assembly so the header does not need to be
299 # compared to the asm.
johannkoenig@chromium.org796a08a2014-09-04 17:34:57 +0000300 if [[ "$1" != *mipsel && "$1" != *mips64el ]]; then
johannkoenig@chromium.org7765c072014-05-16 15:51:21 +0000301 $BASE_DIR/lint_config.sh \
302 -h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
303 -a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm
304 fi
hclam@chromium.org29e01402012-05-30 20:41:48 +0000305}
306
307# Print the configuration.
308# $1 - Header file directory.
309function print_config {
310 $BASE_DIR/lint_config.sh -p \
311 -h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
312 -a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm
313}
314
petarj@mips.come1837fb2012-08-17 03:08:23 +0000315# Print the configuration from Header file.
316# This function is an abridged version of print_config which does not use
317# lint_config and it does not require existence of vpx_config.asm.
318# $1 - Header file directory.
319function print_config_basic {
320 combined_config="$(cat $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
321 | grep -E ' +[01] *$')"
322 combined_config="$(echo "$combined_config" | grep -v DO1STROUNDING)"
323 combined_config="$(echo "$combined_config" | sed 's/[ \t]//g')"
324 combined_config="$(echo "$combined_config" | sed 's/.*define//')"
325 combined_config="$(echo "$combined_config" | sed 's/0$/=no/')"
326 combined_config="$(echo "$combined_config" | sed 's/1$/=yes/')"
327 echo "$combined_config" | sort | uniq
328}
329
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000330# Generate *_rtcd.h files.
hclam@chromium.orge0280012012-05-31 01:37:32 +0000331# $1 - Header file directory.
332# $2 - Architecture.
333function gen_rtcd_header {
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000334 echo "Generate $LIBVPX_CONFIG_DIR/$1/*_rtcd.h files."
hclam@chromium.orge0280012012-05-31 01:37:32 +0000335
336 rm -rf $BASE_DIR/$TEMP_DIR/libvpx.config
johannkoenig@chromium.org796a08a2014-09-04 17:34:57 +0000337 if [[ "$2" == "mipsel" || "$2" == "mips64el" ]]; then
petarj@mips.come1837fb2012-08-17 03:08:23 +0000338 print_config_basic $1 > $BASE_DIR/$TEMP_DIR/libvpx.config
339 else
340 $BASE_DIR/lint_config.sh -p \
341 -h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
342 -a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm \
343 -o $BASE_DIR/$TEMP_DIR/libvpx.config
344 fi
hclam@chromium.orge0280012012-05-31 01:37:32 +0000345
johannkoenig@chromium.org93a74792014-04-10 17:14:25 +0000346 $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.pl \
hclam@chromium.orge0280012012-05-31 01:37:32 +0000347 --arch=$2 \
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000348 --sym=vp8_rtcd \
hclam@chromium.orge0280012012-05-31 01:37:32 +0000349 --config=$BASE_DIR/$TEMP_DIR/libvpx.config \
johannkoenig@chromium.org497a01b2014-04-16 22:02:25 +0000350 --disable-avx2 \
johannkoenig@chromium.org93a74792014-04-10 17:14:25 +0000351 $BASE_DIR/$LIBVPX_SRC_DIR/vp8/common/rtcd_defs.pl \
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000352 > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vp8_rtcd.h
353
johannkoenig@chromium.org93a74792014-04-10 17:14:25 +0000354 $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.pl \
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000355 --arch=$2 \
356 --sym=vp9_rtcd \
357 --config=$BASE_DIR/$TEMP_DIR/libvpx.config \
johannkoenig@chromium.org497a01b2014-04-16 22:02:25 +0000358 --disable-avx2 \
johannkoenig@chromium.org93a74792014-04-10 17:14:25 +0000359 $BASE_DIR/$LIBVPX_SRC_DIR/vp9/common/vp9_rtcd_defs.pl \
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000360 > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vp9_rtcd.h
361
johannkoenig@chromium.org93a74792014-04-10 17:14:25 +0000362 $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.pl \
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000363 --arch=$2 \
364 --sym=vpx_scale_rtcd \
365 --config=$BASE_DIR/$TEMP_DIR/libvpx.config \
johannkoenig@chromium.org497a01b2014-04-16 22:02:25 +0000366 --disable-avx2 \
johannkoenig@chromium.org93a74792014-04-10 17:14:25 +0000367 $BASE_DIR/$LIBVPX_SRC_DIR/vpx_scale/vpx_scale_rtcd.pl \
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000368 > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_scale_rtcd.h
hclam@chromium.orge0280012012-05-31 01:37:32 +0000369
370 rm -rf $BASE_DIR/$TEMP_DIR/libvpx.config
371}
372
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000373# Generate Config files. "--enable-external-build" must be set to skip
374# detection of capabilities on specific targets.
375# $1 - Header file directory.
376# $2 - Config command line.
377function gen_config_files {
378 ./configure $2 > /dev/null
379
380 # Generate vpx_config.asm. Do not create one for mips.
johannkoenig@chromium.org796a08a2014-09-04 17:34:57 +0000381 if [[ "$1" != *mipsel && "$1" != *mips64el ]]; then
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000382 if [[ "$1" == *x64* ]] || [[ "$1" == *ia32* ]]; then
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000383 egrep "#define [A-Z0-9_]+ [01]" vpx_config.h | awk '{print "%define " $2 " " $3}' > vpx_config.asm
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000384 else
385 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
386 fi
387 fi
388
389 cp vpx_config.* $BASE_DIR/$LIBVPX_CONFIG_DIR/$1
390 make_clean
391 rm -rf vpx_config.*
392}
393
394echo "Create temporary directory."
395TEMP_DIR="$LIBVPX_SRC_DIR.temp"
396rm -rf $TEMP_DIR
397cp -R $LIBVPX_SRC_DIR $TEMP_DIR
398cd $TEMP_DIR
399
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000400echo "Generate config files."
johannkoenig@chromium.orgd1432732014-04-16 20:40:56 +0000401# TODO(joeyparrish) Enable AVX2 when broader VS2013 support is available
402all_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"
fgalligan@chromium.org9c920af2013-09-18 23:03:43 +0000403gen_config_files linux/ia32 "--target=x86-linux-gcc --disable-ccache --enable-pic --enable-realtime-only ${all_platforms}"
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000404gen_config_files linux/x64 "--target=x86_64-linux-gcc --disable-ccache --enable-pic --enable-realtime-only ${all_platforms}"
fgalligan@chromium.orgdb9ac6c2014-06-19 21:41:26 +0000405gen_config_files linux/arm "--target=armv6-linux-gcc --enable-pic --enable-realtime-only --disable-install-bins --disable-install-libs --disable-edsp ${all_platforms}"
406gen_config_files linux/arm-neon "--target=armv7-linux-gcc --enable-pic --enable-realtime-only --disable-edsp ${all_platforms}"
407gen_config_files linux/arm-neon-cpu-detect "--target=armv7-linux-gcc --enable-pic --enable-realtime-only --enable-runtime-cpu-detect --disable-edsp ${all_platforms}"
408gen_config_files linux/arm64 "--force-target=armv8-linux-gcc --enable-pic --enable-realtime-only --disable-edsp ${all_platforms}"
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000409gen_config_files linux/mipsel "--target=mips32-linux-gcc --disable-fast-unaligned ${all_platforms}"
johannkoenig@chromium.org796a08a2014-09-04 17:34:57 +0000410gen_config_files linux/mips64el "--target=mips64-linux-gcc --disable-fast-unaligned ${all_platforms}"
earthdok@chromium.org67a84162014-03-27 19:05:43 +0000411gen_config_files linux/generic "--target=generic-gnu --enable-pic --enable-realtime-only ${all_platforms}"
johannkoenig@chromium.orga4adce52014-04-15 23:01:37 +0000412gen_config_files win/ia32 "--target=x86-win32-vs12 --enable-realtime-only ${all_platforms}"
413gen_config_files win/x64 "--target=x86_64-win64-vs12 --enable-realtime-only ${all_platforms}"
fgalligan@chromium.org9c920af2013-09-18 23:03:43 +0000414gen_config_files mac/ia32 "--target=x86-darwin9-gcc --enable-pic --enable-realtime-only ${all_platforms}"
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000415gen_config_files mac/x64 "--target=x86_64-darwin9-gcc --enable-pic --enable-realtime-only ${all_platforms}"
sergeyu@chromium.orgd5b5d742013-11-27 19:36:46 +0000416gen_config_files nacl "--target=generic-gnu --enable-pic --enable-realtime-only ${all_platforms}"
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000417
418echo "Remove temporary directory."
419cd $BASE_DIR
420rm -rf $TEMP_DIR
421
hclam@chromium.org29e01402012-05-30 20:41:48 +0000422echo "Lint libvpx configuration."
423lint_config linux/ia32
424lint_config linux/x64
425lint_config linux/arm
426lint_config linux/arm-neon
wjia@chromium.org1a56a962013-03-11 21:02:06 +0000427lint_config linux/arm-neon-cpu-detect
johannkoenig@chromium.org7765c072014-05-16 15:51:21 +0000428lint_config linux/arm64
429lint_config linux/mipsel
johannkoenig@chromium.org796a08a2014-09-04 17:34:57 +0000430lint_config linux/mips64el
earthdok@chromium.org67a84162014-03-27 19:05:43 +0000431lint_config linux/generic
hclam@chromium.org29e01402012-05-30 20:41:48 +0000432lint_config win/ia32
fgalligan@chromium.org8ae1e8e2013-01-26 07:22:44 +0000433lint_config win/x64
hclam@chromium.org29e01402012-05-30 20:41:48 +0000434lint_config mac/ia32
badea@adobe.com9cfd6fe2012-09-20 12:35:22 +0000435lint_config mac/x64
sergeyu@chromium.orgd5b5d742013-11-27 19:36:46 +0000436lint_config nacl
hclam@chromium.org29e01402012-05-30 20:41:48 +0000437
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000438echo "Create temporary directory."
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000439TEMP_DIR="$LIBVPX_SRC_DIR.temp"
hclam@chromium.org29e01402012-05-30 20:41:48 +0000440rm -rf $TEMP_DIR
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000441cp -R $LIBVPX_SRC_DIR $TEMP_DIR
442cd $TEMP_DIR
443
hclam@chromium.orge0280012012-05-31 01:37:32 +0000444gen_rtcd_header linux/ia32 x86
445gen_rtcd_header linux/x64 x86_64
446gen_rtcd_header linux/arm armv6
447gen_rtcd_header linux/arm-neon armv7
wjia@chromium.org1a56a962013-03-11 21:02:06 +0000448gen_rtcd_header linux/arm-neon-cpu-detect armv7
johannkoenig@chromium.org7765c072014-05-16 15:51:21 +0000449gen_rtcd_header linux/arm64 armv8
petarj@mips.come1837fb2012-08-17 03:08:23 +0000450gen_rtcd_header linux/mipsel mipsel
johannkoenig@chromium.org796a08a2014-09-04 17:34:57 +0000451gen_rtcd_header linux/mips64el mips64el
earthdok@chromium.org67a84162014-03-27 19:05:43 +0000452gen_rtcd_header linux/generic generic
hclam@chromium.orge0280012012-05-31 01:37:32 +0000453gen_rtcd_header win/ia32 x86
fgalligan@chromium.org8ae1e8e2013-01-26 07:22:44 +0000454gen_rtcd_header win/x64 x86_64
hclam@chromium.orge0280012012-05-31 01:37:32 +0000455gen_rtcd_header mac/ia32 x86
badea@adobe.com9cfd6fe2012-09-20 12:35:22 +0000456gen_rtcd_header mac/x64 x86_64
sergeyu@chromium.orgd5b5d742013-11-27 19:36:46 +0000457gen_rtcd_header nacl nacl
hclam@chromium.orge0280012012-05-31 01:37:32 +0000458
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000459echo "Prepare Makefile."
460./configure --target=generic-gnu > /dev/null
hclam@chromium.org29e01402012-05-30 20:41:48 +0000461make_clean
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000462
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000463# Remove existing .gni file.
464rm -rf $BASE_DIR/libvpx_srcs.gni
465write_license $BASE_DIR/libvpx_srcs.gni
466
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000467echo "Generate X86 source list."
hclam@chromium.org29e01402012-05-30 20:41:48 +0000468config=$(print_config linux/ia32)
469make_clean
470make libvpx_srcs.txt target=libs $config > /dev/null
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000471convert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_x86
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000472
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000473# Copy vpx_version.h. The file should be the same for all platforms.
474cp vpx_version.h $BASE_DIR/$LIBVPX_CONFIG_DIR
475
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000476echo "Generate X86_64 source list."
hclam@chromium.org29e01402012-05-30 20:41:48 +0000477config=$(print_config linux/x64)
478make_clean
479make libvpx_srcs.txt target=libs $config > /dev/null
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000480convert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_x86_64
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000481
482echo "Generate ARM source list."
hclam@chromium.org29e01402012-05-30 20:41:48 +0000483config=$(print_config linux/arm)
484make_clean
485make libvpx_srcs.txt target=libs $config > /dev/null
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000486convert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_arm
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000487
488echo "Generate ARM NEON source list."
hclam@chromium.org29e01402012-05-30 20:41:48 +0000489config=$(print_config linux/arm-neon)
490make_clean
491make libvpx_srcs.txt target=libs $config > /dev/null
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000492convert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_arm_neon
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000493
wjia@chromium.org1a56a962013-03-11 21:02:06 +0000494echo "Generate ARM NEON CPU DETECT source list."
495config=$(print_config linux/arm-neon-cpu-detect)
496make_clean
497make libvpx_srcs.txt target=libs $config > /dev/null
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000498convert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_arm_neon_cpu_detect
wjia@chromium.org1a56a962013-03-11 21:02:06 +0000499
johannkoenig@chromium.org7765c072014-05-16 15:51:21 +0000500echo "Generate ARM64 source list."
501config=$(print_config linux/arm64)
502make_clean
503make libvpx_srcs.txt target=libs $config > /dev/null
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000504convert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_arm64
johannkoenig@chromium.org7765c072014-05-16 15:51:21 +0000505
petarj@mips.come1837fb2012-08-17 03:08:23 +0000506echo "Generate MIPS source list."
507config=$(print_config_basic linux/mipsel)
508make_clean
509make libvpx_srcs.txt target=libs $config > /dev/null
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000510convert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_mips
petarj@mips.come1837fb2012-08-17 03:08:23 +0000511
johannkoenig@chromium.org796a08a2014-09-04 17:34:57 +0000512echo "MIPS64 source list is identical to MIPS source list. No need to generate it."
513
sergeyu@chromium.orgd5b5d742013-11-27 19:36:46 +0000514echo "Generate NaCl source list."
515config=$(print_config_basic nacl)
516make_clean
517make libvpx_srcs.txt target=libs $config > /dev/null
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000518convert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_nacl
sergeyu@chromium.orgd5b5d742013-11-27 19:36:46 +0000519
earthdok@chromium.org67a84162014-03-27 19:05:43 +0000520echo "Generate GENERIC source list."
521config=$(print_config_basic linux/generic)
522make_clean
523make libvpx_srcs.txt target=libs $config > /dev/null
hclam@chromium.orgbd09f762014-09-05 21:22:35 +0000524convert_srcs_to_project_files libvpx_srcs.txt libvpx_srcs_generic
earthdok@chromium.org67a84162014-03-27 19:05:43 +0000525
chrome-bot@google.comb3c3acc2011-10-11 14:10:16 +0000526echo "Remove temporary directory."
527cd $BASE_DIR
528rm -rf $TEMP_DIR
fgalligan@chromium.org6fefe532012-12-13 00:56:09 +0000529
530# TODO(fgalligan): Is "--disable-fast-unaligned" needed on mipsel?
531# TODO(fgalligan): Can we turn on "--enable-realtime-only" for mipsel?