| OLD | NEW |
| (Empty) | |
| 1 #!/bin/bash -e |
| 2 |
| 3 # Copyright (c) 2011 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 # Builds Chromium, Google Chrome and *OS FFmpeg binaries. |
| 8 # |
| 9 # For Windows it assumes being run from a MinGW shell with Visual Studio |
| 10 # environment (i.e., lib.exe and editbin.exe are in $PATH). |
| 11 # |
| 12 # Instructions for setting up a MinGW/MSYS shell can be found here: |
| 13 # http://src.chromium.org/viewvc/chrome/trunk/deps/third_party/mingw/README.chro
mium |
| 14 |
| 15 if [ "$3" = "" -o "$4" != "" ]; then |
| 16 echo "Usage:" |
| 17 echo " $0 [TARGET_OS] [TARGET_ARCH] [path/to/third_party/ffmpeg]" |
| 18 echo |
| 19 echo "Valid combinations are linux [ia32|x64|arm|arm-neon]" |
| 20 echo " win [ia32]" |
| 21 echo " mac [ia32]" |
| 22 echo |
| 23 echo " linux ia32/x64 - script can be run on a normal Ubuntu box." |
| 24 echo " linux arm/arm-neon should be run inside of CrOS chroot." |
| 25 echo " mac and win have to be run on Mac and Windows 7 (under mingw)." |
| 26 echo |
| 27 echo "The path should be absolute and point at Chromium's copy of FFmpeg." |
| 28 echo "This corresponds to:" |
| 29 echo " chrome/trunk/deps/third_party/ffmpeg" |
| 30 echo |
| 31 echo "Resulting binaries will be placed in:" |
| 32 echo " build.TARGET_ARCH.TARGET_OS/Chromium/out/" |
| 33 echo " build.TARGET_ARCH.TARGET_OS/Chrome/out/" |
| 34 echo " build.TARGET_ARCH.TARGET_OS/ChromiumOS/out/" |
| 35 echo " build.TARGET_ARCH.TARGET_OS/ChromeOS/out/" |
| 36 exit |
| 37 fi |
| 38 |
| 39 TARGET_OS=$1 |
| 40 TARGET_ARCH=$2 |
| 41 FFMPEG_PATH=$3 |
| 42 |
| 43 # Check TARGET_OS (TARGET_ARCH is checked during configuration). |
| 44 if [[ "$TARGET_OS" != "linux" && |
| 45 "$TARGET_OS" != "mac" && |
| 46 "$TARGET_OS" != "win" ]]; then |
| 47 echo "Valid target OSes are: linux, mac, win" |
| 48 exit 1 |
| 49 fi |
| 50 |
| 51 # Check FFMPEG_PATH to contain this script. |
| 52 if [ ! -f "$FFMPEG_PATH/$(basename $0)" ]; then |
| 53 echo "$FFMPEG_PATH doesn't appear to contain FFmpeg" |
| 54 exit 1 |
| 55 fi |
| 56 |
| 57 # If configure & make works but this script doesn't, make sure to grep for these
. |
| 58 LIBAVCODEC_VERSION_MAJOR=53 |
| 59 LIBAVFORMAT_VERSION_MAJOR=53 |
| 60 LIBAVUTIL_VERSION_MAJOR=51 |
| 61 |
| 62 case $(uname -sm) in |
| 63 Linux\ i386) |
| 64 HOST_OS=linux |
| 65 HOST_ARCH=ia32 |
| 66 JOBS=$(grep processor /proc/cpuinfo | wc -l) |
| 67 ;; |
| 68 Linux\ x86_64) |
| 69 HOST_OS=linux |
| 70 HOST_ARCH=x64 |
| 71 JOBS=$(grep processor /proc/cpuinfo | wc -l) |
| 72 ;; |
| 73 Darwin*) |
| 74 HOST_OS=mac |
| 75 HOST_ARCH=ia32 |
| 76 JOBS=$(sysctl -n hw.ncpu) |
| 77 ;; |
| 78 MINGW*) |
| 79 HOST_OS=win |
| 80 HOST_ARCH=ia32 |
| 81 JOBS=$NUMBER_OF_PROCESSORS |
| 82 ;; |
| 83 *) |
| 84 echo "Unrecognized HOST_OS: $(uname)" |
| 85 echo "Patches welcome!" |
| 86 exit 1 |
| 87 ;; |
| 88 esac |
| 89 |
| 90 # Print out system information. |
| 91 echo "System information:" |
| 92 echo "HOST_OS = $HOST_OS" |
| 93 echo "TARGET_OS = $TARGET_OS" |
| 94 echo "HOST_ARCH = $HOST_ARCH" |
| 95 echo "TARGET_ARCH = $TARGET_ARCH" |
| 96 echo "JOBS = $JOBS" |
| 97 echo "LD = $(ld --version | head -n1)" |
| 98 echo |
| 99 |
| 100 # As of this writing gold 2.20.1-system.20100303 is unable to link FFmpeg. |
| 101 if ld --version | grep -q gold; then |
| 102 echo "gold is unable to link FFmpeg" |
| 103 echo |
| 104 echo "Switch /usr/bin/ld to the regular binutils ld and try again" |
| 105 exit 1 |
| 106 fi |
| 107 |
| 108 # Returns the Dynamic Shared Object name given the module name and version. |
| 109 function dso_name { dso_name_${TARGET_OS} $1 $2; } |
| 110 function dso_name_win { echo "${1}-${2}.dll"; } |
| 111 function dso_name_linux { echo "lib${1}.so.${2}"; } |
| 112 function dso_name_mac { echo "lib${1}.${2}.dylib"; } |
| 113 |
| 114 # Appends configure flags. |
| 115 FLAGS_COMMON= |
| 116 FLAGS_CHROMIUM= |
| 117 FLAGS_CHROME= |
| 118 FLAGS_CHROMIUMOS= |
| 119 FLAGS_CHROMEOS= |
| 120 |
| 121 # Flags that are used in all of Chrome/Chromium + OS. |
| 122 function add_flag_common { |
| 123 FLAGS_COMMON="$FLAGS_COMMON $*" |
| 124 } |
| 125 # Flags that are used in Chromium and ChromiumOS. |
| 126 function add_flag_chromium { |
| 127 FLAGS_CHROMIUM="$FLAGS_CHROMIUM $*" |
| 128 } |
| 129 # Flags that are used in Chrome and ChromeOS. |
| 130 function add_flag_chrome { |
| 131 FLAGS_CHROME="$FLAGS_CHROME $*" |
| 132 } |
| 133 # Flags that are used only in ChromiumOS (but not Chromium). |
| 134 function add_flag_chromiumos { |
| 135 FLAGS_CHROMIUMOS="$FLAGS_CHROMIUMOS $*" |
| 136 } |
| 137 # Flags that are used only in ChromeOS (but not Chrome). |
| 138 function add_flag_chromeos { |
| 139 FLAGS_CHROMEOS="$FLAGS_CHROMEOS $*" |
| 140 } |
| 141 |
| 142 # Builds using $1 as the output directory and all following arguments as |
| 143 # configure script arguments. |
| 144 function build { |
| 145 CONFIG=$1 |
| 146 CONFIG_DIR="build.$TARGET_ARCH.$TARGET_OS/$CONFIG" |
| 147 shift |
| 148 |
| 149 # Create our working directory. |
| 150 echo "Creating build directory..." |
| 151 rm -rf $CONFIG_DIR |
| 152 mkdir -p $CONFIG_DIR |
| 153 pushd $CONFIG_DIR |
| 154 mkdir out |
| 155 shift |
| 156 |
| 157 # Configure and check for exit status. |
| 158 echo "Configuring $CONFIG..." |
| 159 echo "$FFMPEG_PATH/source/patched-ffmpeg/configure $*" |
| 160 $FFMPEG_PATH/source/patched-ffmpeg/configure $* |
| 161 |
| 162 if [ ! -f config.h ]; then |
| 163 echo "Configure failed!" |
| 164 exit 1 |
| 165 fi |
| 166 |
| 167 if [ $TARGET_ARCH = "ia32" ]; then |
| 168 echo $FFMPEG_PATH/source/munge_config_optimizations.sh config.h |
| 169 $FFMPEG_PATH/source/munge_config_optimizations.sh config.h |
| 170 fi |
| 171 |
| 172 # TODO(ihf): Remove munge_config_posix_memalign.sh when |
| 173 # DEPLOYMENT_TARGET >= 10.7. Background: If MACOSX_DEPLOYMENT_TARGET < 10.7 |
| 174 # we have to disable posix_memalign by hand, as it was introduced somewhere |
| 175 # in OSX 10.6 (configure finds it) but we can't use it yet. Just check |
| 176 # common.gypi for 'mac_deployment_target%': '10.5'. |
| 177 if [ $TARGET_OS = "mac" ]; then |
| 178 echo $FFMPEG_PATH/source/munge_config_posix_memalign.sh config.h |
| 179 $FFMPEG_PATH/source/munge_config_posix_memalign.sh config.h |
| 180 fi |
| 181 |
| 182 if [ "$HOST_OS" = "$TARGET_OS" ]; then |
| 183 # Build! |
| 184 LIBS="libavcodec/$(dso_name avcodec $LIBAVCODEC_VERSION_MAJOR)" |
| 185 LIBS="libavformat/$(dso_name avformat $LIBAVFORMAT_VERSION_MAJOR) $LIBS" |
| 186 LIBS="libavutil/$(dso_name avutil $LIBAVUTIL_VERSION_MAJOR) $LIBS" |
| 187 for lib in $LIBS; do |
| 188 echo "Building $lib for $CONFIG..." |
| 189 echo "make -j$JOBS $lib" |
| 190 make -j$JOBS $lib |
| 191 if [ -f $lib ]; then |
| 192 if [[ "$TARGET_ARCH" = "arm" || |
| 193 "$TARGET_ARCH" = "arm-neon" ]]; then |
| 194 # Assume we are in chroot for CrOS. |
| 195 /usr/bin/armv7a-cros-linux-gnueabi-strip $lib |
| 196 elif [[ "$TARGET_OS" = "win" ]]; then |
| 197 # Windows doesn't care if global symbols get stripped, saving us a |
| 198 # cool 100KB. |
| 199 strip $lib |
| 200 |
| 201 # Windows binaries need /NXCOMPAT and /DYNAMICBASE. |
| 202 editbin -nxcompat -dynamicbase $lib |
| 203 else |
| 204 strip -x $lib |
| 205 fi |
| 206 |
| 207 cp $lib out |
| 208 else |
| 209 echo "Build failed!" |
| 210 exit |
| 211 fi |
| 212 done |
| 213 else |
| 214 echo "Skipping compile as host configuration differs from target." |
| 215 echo "Please compare the generated config.h with the previous version." |
| 216 echo "You may also patch the script to properly cross-compile." |
| 217 echo "host OS = $HOST_OS" |
| 218 echo "target OS = $TARGET_OS" |
| 219 echo "host ARCH= $HOST_ARCH" |
| 220 echo "target ARCH= $TARGET_ARCH" |
| 221 fi |
| 222 popd |
| 223 } |
| 224 |
| 225 # Common configuration. |
| 226 add_flag_common --disable-doc |
| 227 add_flag_common --disable-everything |
| 228 add_flag_common --enable-fft |
| 229 add_flag_common --enable-rdft |
| 230 add_flag_common --disable-network |
| 231 add_flag_common --disable-bzlib |
| 232 add_flag_common --disable-zlib |
| 233 add_flag_common --disable-swscale |
| 234 add_flag_common --disable-amd3dnow |
| 235 add_flag_common --disable-amd3dnowext |
| 236 add_flag_common --enable-shared |
| 237 |
| 238 # Common codecs. |
| 239 add_flag_common --enable-decoder=theora,vorbis,vp8 |
| 240 add_flag_common --enable-decoder=pcm_u8,pcm_s16le,pcm_f32le |
| 241 add_flag_common --enable-demuxer=ogg,matroska,wav |
| 242 add_flag_common --enable-parser=vp8 |
| 243 |
| 244 # Linux only. |
| 245 if [ "$TARGET_OS" = "linux" ]; then |
| 246 if [ "$TARGET_ARCH" = "x64" ]; then |
| 247 # Nothing to add for now. |
| 248 add_flag_common "" |
| 249 elif [ "$TARGET_ARCH" = "ia32" ]; then |
| 250 add_flag_common --arch=i686 |
| 251 add_flag_common --enable-yasm |
| 252 add_flag_common --extra-cflags=-m32 |
| 253 # Adding fPIC since revision 53745. |
| 254 add_flag_common --extra-cflags=-fPIC |
| 255 add_flag_common --extra-ldflags=-m32 |
| 256 elif [ "$TARGET_ARCH" = "arm" ]; then |
| 257 # This if-statement essentially is for chroot tegra2. |
| 258 add_flag_common --enable-cross-compile |
| 259 |
| 260 # Location is for CrOS chroot. If you want to use this, enter chroot |
| 261 # and copy ffmpeg to a location that is reachable. |
| 262 add_flag_common --cross-prefix=/usr/bin/armv7a-cros-linux-gnueabi- |
| 263 add_flag_common --target-os=linux |
| 264 add_flag_common --arch=arm |
| 265 |
| 266 # TODO(ihf): ARM compile flags are tricky. The final options |
| 267 # overriding everything live in chroot /build/*/etc/make.conf. |
| 268 # We try to follow these here closely. In particular we need to |
| 269 # set ffmpeg internal #defines to conform to make.conf. |
| 270 # TODO(ihf): For now it is not clear if thumb or arm settings would be |
| 271 # faster. I ran experiments in other contexts and performance seemed |
| 272 # to be close and compiler version dependent. In practice thumb builds are |
| 273 # much smaller than optimized arm builds, hence we go with the global |
| 274 # CrOS settings. |
| 275 add_flag_common --enable-armv6 |
| 276 add_flag_common --enable-armv6t2 |
| 277 add_flag_common --enable-armvfp |
| 278 add_flag_common --enable-thumb |
| 279 add_flag_common --disable-neon |
| 280 add_flag_common --extra-cflags=-march=armv7-a |
| 281 add_flag_common --extra-cflags=-mtune=cortex-a8 |
| 282 add_flag_common --extra-cflags=-mfpu=vfpv3-d16 |
| 283 add_flag_common --extra-cflags=-mfloat-abi=softfp |
| 284 # TODO(ihf): We are probably going to switch the whole tegra2 board soon to |
| 285 # add_flag_common --extra-cflags=-mfloat-abi=hard |
| 286 elif [ "$TARGET_ARCH" = "arm-neon" ]; then |
| 287 # This if-statement is for chroot arm-generic. |
| 288 add_flag_common --enable-cross-compile |
| 289 add_flag_common --cross-prefix=/usr/bin/armv7a-cros-linux-gnueabi- |
| 290 add_flag_common --target-os=linux |
| 291 add_flag_common --arch=arm |
| 292 add_flag_common --enable-armv6 |
| 293 add_flag_common --enable-armv6t2 |
| 294 add_flag_common --enable-armvfp |
| 295 add_flag_common --enable-thumb |
| 296 add_flag_common --enable-neon |
| 297 add_flag_common --extra-cflags=-march=armv7-a |
| 298 add_flag_common --extra-cflags=-mtune=cortex-a8 |
| 299 add_flag_common --extra-cflags=-mfpu=neon |
| 300 add_flag_common --extra-cflags=-mfloat-abi=softfp |
| 301 else |
| 302 echo "Error: Unknown TARGET_ARCH=$TARGET_ARCH for TARGET_OS=$TARGET_OS!" |
| 303 exit |
| 304 fi |
| 305 fi |
| 306 |
| 307 # Should be run on Windows. |
| 308 if [ "$TARGET_OS" = "win" ]; then |
| 309 if [ "$HOST_OS" = "win" ]; then |
| 310 if [ "$TARGET_ARCH" = "ia32" ]; then |
| 311 add_flag_common --enable-filter=buffer |
| 312 add_flag_common --enable-memalign-hack |
| 313 add_flag_common --cc=mingw32-gcc |
| 314 add_flag_common --extra-cflags=-mtune=atom |
| 315 add_flag_common --extra-cflags=-U__STRICT_ANSI__ |
| 316 add_flag_common --extra-cflags=-I/usr/local/include |
| 317 add_flag_common --extra-ldflags=-L/usr/local/lib |
| 318 add_flag_common --extra-ldflags=-Wl,--enable-auto-import |
| 319 add_flag_common --extra-ldflags=-Wl,--no-seh |
| 320 else |
| 321 echo "Error: Unknown TARGET_ARCH=$TARGET_ARCH for TARGET_OS=$TARGET_OS!" |
| 322 exit |
| 323 fi |
| 324 else |
| 325 echo "Script should be run on Windows host. If this is not possible try a " |
| 326 echo "merge of config files with new linux ia32 config.h by hand." |
| 327 exit |
| 328 fi |
| 329 fi |
| 330 |
| 331 # Should be run on Mac. |
| 332 if [ "$TARGET_OS" = "mac" ]; then |
| 333 if [ "$HOST_OS" = "mac" ]; then |
| 334 if [ "$TARGET_ARCH" = "ia32" ]; then |
| 335 add_flag_common --arch=i686 |
| 336 add_flag_common --enable-yasm |
| 337 add_flag_common --extra-cflags=-m32 |
| 338 add_flag_common --extra-ldflags=-m32 |
| 339 else |
| 340 echo "Error: Unknown TARGET_ARCH=$TARGET_ARCH for TARGET_OS=$TARGET_OS!" |
| 341 exit |
| 342 fi |
| 343 else |
| 344 echo "Script should be run on a Mac host. If this is not possible try a " |
| 345 echo "merge of config files with new linux ia32 config.h by hand." |
| 346 exit |
| 347 fi |
| 348 fi |
| 349 |
| 350 # Chromium & ChromiumOS specific configuration. |
| 351 # (nothing at the moment) |
| 352 |
| 353 # Google Chrome & ChromeOS specific configuration. |
| 354 add_flag_chrome --enable-decoder=aac,h264,mp3 |
| 355 add_flag_chrome --enable-demuxer=mp3,mov |
| 356 add_flag_chrome --enable-parser=mpegaudio |
| 357 add_flag_chrome --enable-bsf=h264_mp4toannexb |
| 358 |
| 359 # ChromiumOS specific configuration. |
| 360 # Warning: do *NOT* add avi, aac, h264, mp3, mp4, amr* |
| 361 # Flac support. |
| 362 add_flag_chromiumos --enable-demuxer=flac |
| 363 add_flag_chromiumos --enable-decoder=flac |
| 364 |
| 365 # Google ChromeOS specific configuration. |
| 366 # We want to make sure to play everything Android generates and plays. |
| 367 # http://developer.android.com/guide/appendix/media-formats.html |
| 368 # Enable playing avi files. |
| 369 add_flag_chromeos --enable-decoder=mpeg4 |
| 370 add_flag_chromeos --enable-demuxer=avi |
| 371 add_flag_chromeos --enable-bsf=mpeg4video_es |
| 372 # Enable playing Android 3gp files. |
| 373 add_flag_chromeos --enable-demuxer=amr |
| 374 add_flag_chromeos --enable-decoder=amrnb,amrwb |
| 375 # Flac support. |
| 376 add_flag_chromeos --enable-demuxer=flac |
| 377 add_flag_chromeos --enable-decoder=flac |
| 378 # Wav files for playing phone messages. |
| 379 # Maybe later: gsm_ms,adpcm_ima_wav |
| 380 add_flag_chromeos --enable-decoder=pcm_mulaw |
| 381 |
| 382 echo "Chromium configure/build:" |
| 383 build Chromium $FLAGS_COMMON $FLAGS_CHROMIUM |
| 384 echo "Chrome configure/build:" |
| 385 build Chrome $FLAGS_COMMON $FLAGS_CHROME |
| 386 |
| 387 if [ "$TARGET_OS" = "linux" ]; then |
| 388 echo "ChromiumOS configure/build:" |
| 389 build ChromiumOS $FLAGS_COMMON $FLAGS_CHROMIUM $FLAGS_CHROMIUMOS |
| 390 echo "ChromeOS configure/build:" |
| 391 build ChromeOS $FLAGS_COMMON $FLAGS_CHROME $FLAGS_CHROMEOS |
| 392 fi |
| 393 |
| 394 echo "Done. If desired you may copy config.h/config.asm into the source/config t
ree using copy_config.sh." |
| OLD | NEW |