blob: 56c7994e85ee3529a984dbc57ccf0a07aefb0378 [file] [log] [blame]
Vignesh Venkatasubramanianda49e342015-08-25 11:05:01 -07001#!/bin/bash -e
2#
3# Copyright (c) 2012 The Chromium Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# This script is used to generate files in the <platform> directories needed to
8# build libvpx. Every time libvpx source code is updated run this script.
9#
10# For example:
11# $ ./generate_config.sh
12#
13# And this will update all the config files needed.
14
15export LC_ALL=C
16BASE_DIR=$(pwd)
17LIBVPX_SRC_DIR="libvpx"
18LIBVPX_CONFIG_DIR="config"
19
20# Clean files from previous make.
21function make_clean {
22 make clean > /dev/null
23 rm -f libvpx_srcs.txt
24}
25
26# Lint a pair of vpx_config.h and vpx_config.asm to make sure they match.
27# $1 - Header file directory.
28function lint_config {
29 # mips does not contain any assembly so the header does not need to be
30 # compared to the asm.
31 if [[ "$1" != *mips* ]]; then
32 $BASE_DIR/lint_config.sh \
33 -h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
34 -a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm
35 fi
36}
37
38# Print the configuration.
39# $1 - Header file directory.
40function print_config {
41 $BASE_DIR/lint_config.sh -p \
42 -h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
43 -a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm
44}
45
46# Print the configuration from Header file.
47# This function is an abridged version of print_config which does not use
48# lint_config and it does not require existence of vpx_config.asm.
49# $1 - Header file directory.
50function print_config_basic {
51 combined_config="$(cat $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
52 | grep -E ' +[01] *$')"
53 combined_config="$(echo "$combined_config" | grep -v DO1STROUNDING)"
54 combined_config="$(echo "$combined_config" | sed 's/[ \t]//g')"
55 combined_config="$(echo "$combined_config" | sed 's/.*define//')"
56 combined_config="$(echo "$combined_config" | sed 's/0$/=no/')"
57 combined_config="$(echo "$combined_config" | sed 's/1$/=yes/')"
58 echo "$combined_config" | sort | uniq
59}
60
61# Generate *_rtcd.h files.
62# $1 - Header file directory.
63# $2 - Architecture.
64function gen_rtcd_header {
65 echo "Generate $LIBVPX_CONFIG_DIR/$1/*_rtcd.h files."
66
67 # We don't properly persist the config options specificed on the configure
68 # line. Until that is fixed, force them here.
69 DISABLE_CONFIG="--disable-sse4_1 --disable-avx --disable-avx2"
70
71 rm -rf $BASE_DIR/$TEMP_DIR/libvpx.config
72 if [[ "$2" == *mips* ]]; then
73 print_config_basic $1 > $BASE_DIR/$TEMP_DIR/libvpx.config
74 else
75 $BASE_DIR/lint_config.sh -p \
76 -h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.h \
77 -a $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_config.asm \
78 -o $BASE_DIR/$TEMP_DIR/libvpx.config
79 fi
80
81 $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.pl \
82 --arch=$2 \
83 --sym=vp8_rtcd \
84 $DISABLE_CONFIG \
85 --config=$BASE_DIR/$TEMP_DIR/libvpx.config \
86 $BASE_DIR/$LIBVPX_SRC_DIR/vp8/common/rtcd_defs.pl \
87 > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vp8_rtcd.h
88
89 $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.pl \
90 --arch=$2 \
91 --sym=vp9_rtcd \
92 --config=$BASE_DIR/$TEMP_DIR/libvpx.config \
93 $DISABLE_CONFIG \
94 $BASE_DIR/$LIBVPX_SRC_DIR/vp9/common/vp9_rtcd_defs.pl \
95 > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vp9_rtcd.h
96
97 $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.pl \
98 --arch=$2 \
99 --sym=vpx_scale_rtcd \
100 --config=$BASE_DIR/$TEMP_DIR/libvpx.config \
101 $DISABLE_CONFIG \
102 $BASE_DIR/$LIBVPX_SRC_DIR/vpx_scale/vpx_scale_rtcd.pl \
103 > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_scale_rtcd.h
104
105 $BASE_DIR/$LIBVPX_SRC_DIR/build/make/rtcd.pl \
106 --arch=$2 \
107 --sym=vpx_dsp_rtcd \
108 --config=$BASE_DIR/$TEMP_DIR/libvpx.config \
109 $DISABLE_CONFIG \
110 $BASE_DIR/$LIBVPX_SRC_DIR/vpx_dsp/vpx_dsp_rtcd_defs.pl \
111 > $BASE_DIR/$LIBVPX_CONFIG_DIR/$1/vpx_dsp_rtcd.h
112
113 rm -rf $BASE_DIR/$TEMP_DIR/libvpx.config
114}
115
116# Generate Config files. "--enable-external-build" must be set to skip
117# detection of capabilities on specific targets.
118# $1 - Header file directory.
119# $2 - Config command line.
120function gen_config_files {
121 ./configure $2 > /dev/null
122
123 # Generate vpx_config.asm. Do not create one for mips.
124 if [[ "$1" != *mips* ]]; then
125 if [[ "$1" == *x86* ]]; then
126 egrep "#define [A-Z0-9_]+ [01]" vpx_config.h \
127 | awk '{print "%define " $2 " " $3}' > vpx_config.asm
128 else
129 egrep "#define [A-Z0-9_]+ [01]" vpx_config.h \
130 | awk '{print $2 " EQU " $3}' \
131 | perl $BASE_DIR/$LIBVPX_SRC_DIR/build/make/ads2gas.pl > vpx_config.asm
132 fi
133 fi
134
135 # Generate vpx_version.h
136 $BASE_DIR/$LIBVPX_SRC_DIR/build/make/version.sh "$BASE_DIR/$LIBVPX_SRC_DIR" vpx_version.h
137
138 cp vpx_config.* vpx_version.h $BASE_DIR/$LIBVPX_CONFIG_DIR/$1
139 make_clean
140 rm -rf vpx_config.* vpx_version.h
141}
142
143echo "Create temporary directory."
144TEMP_DIR="$LIBVPX_SRC_DIR.temp"
145rm -rf $TEMP_DIR
146cp -R $LIBVPX_SRC_DIR $TEMP_DIR
147cd $TEMP_DIR
148
149echo "Generate config files."
Marco Nelissen698796f2017-04-04 08:41:32 -0700150all_platforms="--enable-external-build --enable-realtime-only --enable-pic --disable-runtime-cpu-detect --disable-install-docs --size-limit=4096x3072"
Vignesh Venkatasubramanianda49e342015-08-25 11:05:01 -0700151intel="--disable-sse4_1 --disable-avx --disable-avx2 --as=yasm"
152gen_config_files x86 "--target=x86-linux-gcc ${intel} ${all_platforms}"
153gen_config_files x86_64 "--target=x86_64-linux-gcc ${intel} ${all_platforms}"
154gen_config_files arm "--target=armv6-linux-gcc ${all_platforms}"
155gen_config_files arm-neon "--target=armv7-linux-gcc ${all_platforms}"
156gen_config_files arm64 "--force-target=armv8-linux-gcc ${all_platforms}"
157gen_config_files mips32 "--target=mips32-linux-gcc --disable-dspr2 ${all_platforms}"
158gen_config_files mips32-dspr2 "--target=mips32-linux-gcc --enable-dspr2 ${all_platforms}"
159gen_config_files mips64 "--target=mips64-linux-gcc ${all_platforms}"
160gen_config_files generic "--target=generic-gnu ${all_platforms}"
161
162echo "Remove temporary directory."
163cd $BASE_DIR
164rm -rf $TEMP_DIR
165
166echo "Lint libvpx configuration."
167lint_config x86
168lint_config x86_64
169lint_config arm
170lint_config arm-neon
171lint_config arm64
172lint_config mips32
173lint_config mips32-dspr2
174lint_config mips64
175lint_config generic
176
177echo "Create temporary directory."
178TEMP_DIR="$LIBVPX_SRC_DIR.temp"
179rm -rf $TEMP_DIR
180cp -R $LIBVPX_SRC_DIR $TEMP_DIR
181cd $TEMP_DIR
182
183gen_rtcd_header x86 x86
184gen_rtcd_header x86_64 x86_64
185gen_rtcd_header arm armv6
186gen_rtcd_header arm-neon armv7
187gen_rtcd_header arm64 armv8
188gen_rtcd_header mips32 mips32
189gen_rtcd_header mips32-dspr2 mips32
190gen_rtcd_header mips64 mips64
191gen_rtcd_header generic generic
192
193echo "Prepare Makefile."
194./configure --target=generic-gnu > /dev/null
195make_clean
196
197echo "Generate X86 source list."
198config=$(print_config x86)
199make_clean
200make libvpx_srcs.txt target=libs $config > /dev/null
201cp libvpx_srcs.txt $BASE_DIR/$LIBVPX_CONFIG_DIR/x86/
202
203echo "Generate X86_64 source list."
204config=$(print_config x86_64)
205make_clean
206make libvpx_srcs.txt target=libs $config > /dev/null
207cp libvpx_srcs.txt $BASE_DIR/$LIBVPX_CONFIG_DIR/x86_64/
208
209echo "Generate ARM source list."
210config=$(print_config arm)
211make_clean
212make libvpx_srcs.txt target=libs $config > /dev/null
213cp libvpx_srcs.txt $BASE_DIR/$LIBVPX_CONFIG_DIR/arm/
214
215echo "Generate ARM NEON source list."
216config=$(print_config arm-neon)
217make_clean
218make libvpx_srcs.txt target=libs $config > /dev/null
219cp libvpx_srcs.txt $BASE_DIR/$LIBVPX_CONFIG_DIR/arm-neon/
220
221echo "Generate ARM64 source list."
222config=$(print_config arm64)
223make_clean
224make libvpx_srcs.txt target=libs $config > /dev/null
225cp libvpx_srcs.txt $BASE_DIR/$LIBVPX_CONFIG_DIR/arm64/
226
227echo "Generate MIPS source list."
228config=$(print_config_basic mips32)
229make_clean
230make libvpx_srcs.txt target=libs $config > /dev/null
231cp libvpx_srcs.txt $BASE_DIR/$LIBVPX_CONFIG_DIR/mips32/
232
233echo "Generate MIPS DSPR2 source list."
234config=$(print_config_basic mips32-dspr2)
235make_clean
236make libvpx_srcs.txt target=libs $config > /dev/null
237cp libvpx_srcs.txt $BASE_DIR/$LIBVPX_CONFIG_DIR/mips32-dspr2/
238
239echo "Generate MIPS64 source list."
240config=$(print_config_basic mips64)
241make_clean
242make libvpx_srcs.txt target=libs $config > /dev/null
243cp libvpx_srcs.txt $BASE_DIR/$LIBVPX_CONFIG_DIR/mips64/
244
245echo "Generate GENERIC source list."
246config=$(print_config_basic generic)
247make_clean
248make libvpx_srcs.txt target=libs $config > /dev/null
249cp libvpx_srcs.txt $BASE_DIR/$LIBVPX_CONFIG_DIR/generic/
250
251
252echo "Remove temporary directory."
253cd $BASE_DIR
254rm -rf $TEMP_DIR