You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3907 lines
113KB

  1. #!/bin/sh
  2. #
  3. # Libav configure script
  4. #
  5. # Copyright (c) 2000-2002 Fabrice Bellard
  6. # Copyright (c) 2005-2008 Diego Biurrun
  7. # Copyright (c) 2005-2008 Mans Rullgard
  8. #
  9. # Prevent locale nonsense from breaking basic text processing.
  10. LC_ALL=C
  11. export LC_ALL
  12. # make sure we are running under a compatible shell
  13. # try to make this part work with most shells
  14. try_exec(){
  15. echo "Trying shell $1"
  16. type "$1" > /dev/null 2>&1 && exec "$@"
  17. }
  18. unset foo
  19. (: ${foo%%bar}) 2> /dev/null
  20. E1="$?"
  21. (: ${foo?}) 2> /dev/null
  22. E2="$?"
  23. if test "$E1" != 0 || test "$E2" = 0; then
  24. echo "Broken shell detected. Trying alternatives."
  25. export FF_CONF_EXEC
  26. if test "0$FF_CONF_EXEC" -lt 1; then
  27. FF_CONF_EXEC=1
  28. try_exec bash "$0" "$@"
  29. fi
  30. if test "0$FF_CONF_EXEC" -lt 2; then
  31. FF_CONF_EXEC=2
  32. try_exec ksh "$0" "$@"
  33. fi
  34. if test "0$FF_CONF_EXEC" -lt 3; then
  35. FF_CONF_EXEC=3
  36. try_exec /usr/xpg4/bin/sh "$0" "$@"
  37. fi
  38. echo "No compatible shell script interpreter found."
  39. echo "This configure script requires a POSIX-compatible shell"
  40. echo "such as bash or ksh."
  41. echo "THIS IS NOT A BUG IN LIBAV, DO NOT REPORT IT AS SUCH."
  42. echo "Instead, install a working POSIX-compatible shell."
  43. echo "Disabling this configure test will create a broken Libav."
  44. if test "$BASH_VERSION" = '2.04.0(1)-release'; then
  45. echo "This bash version ($BASH_VERSION) is broken on your platform."
  46. echo "Upgrade to a later version if available."
  47. fi
  48. exit 1
  49. fi
  50. test -d /usr/xpg4/bin && PATH=/usr/xpg4/bin:$PATH
  51. show_help(){
  52. cat <<EOF
  53. Usage: configure [options]
  54. Options: [defaults in brackets after descriptions]
  55. Help options:
  56. --help print this message
  57. --list-decoders show all available decoders
  58. --list-encoders show all available encoders
  59. --list-hwaccels show all available hardware accelerators
  60. --list-demuxers show all available demuxers
  61. --list-muxers show all available muxers
  62. --list-parsers show all available parsers
  63. --list-protocols show all available protocols
  64. --list-bsfs show all available bitstream filters
  65. --list-indevs show all available input devices
  66. --list-outdevs show all available output devices
  67. --list-filters show all available filters
  68. Standard options:
  69. --logfile=FILE log tests and output to FILE [config.log]
  70. --disable-logging do not log configure debug information
  71. --prefix=PREFIX install in PREFIX [$prefix]
  72. --bindir=DIR install binaries in DIR [PREFIX/bin]
  73. --datadir=DIR install data files in DIR [PREFIX/share/avconv]
  74. --libdir=DIR install libs in DIR [PREFIX/lib]
  75. --shlibdir=DIR install shared libs in DIR [PREFIX/lib]
  76. --incdir=DIR install includes in DIR [PREFIX/include]
  77. --mandir=DIR install man page in DIR [PREFIX/share/man]
  78. Licensing options:
  79. --enable-gpl allow use of GPL code, the resulting libs
  80. and binaries will be under GPL [no]
  81. --enable-version3 upgrade (L)GPL to version 3 [no]
  82. --enable-nonfree allow use of nonfree code, the resulting libs
  83. and binaries will be unredistributable [no]
  84. Configuration options:
  85. --disable-static do not build static libraries [no]
  86. --enable-shared build shared libraries [no]
  87. --enable-small optimize for size instead of speed
  88. --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
  89. --enable-gray enable full grayscale support (slower color)
  90. --disable-swscale-alpha disable alpha channel support in swscale
  91. Component options:
  92. --disable-doc do not build documentation
  93. --disable-avconv disable avconv build
  94. --disable-avplay disable avplay build
  95. --disable-avprobe disable avprobe build
  96. --disable-avserver disable avserver build
  97. --disable-avdevice disable libavdevice build
  98. --disable-avcodec disable libavcodec build
  99. --disable-avformat disable libavformat build
  100. --disable-swscale disable libswscale build
  101. --disable-avfilter disable video filter support [no]
  102. --disable-avresample disable libavresample build [no]
  103. --disable-pthreads disable pthreads [auto]
  104. --disable-w32threads disable Win32 threads [auto]
  105. --enable-x11grab enable X11 grabbing [no]
  106. --disable-network disable network support [no]
  107. --disable-dct disable DCT code
  108. --disable-dwt disable DWT code
  109. --disable-lsp disable LSP code
  110. --disable-lzo disable LZO decoder code
  111. --disable-mdct disable MDCT code
  112. --disable-rdft disable RDFT code
  113. --disable-fft disable FFT code
  114. --enable-dxva2 enable DXVA2 code
  115. --enable-vaapi enable VAAPI code
  116. --enable-vda enable VDA code
  117. --enable-vdpau enable VDPAU code
  118. Individual component options:
  119. --disable-everything disable all components listed below
  120. --disable-encoder=NAME disable encoder NAME
  121. --enable-encoder=NAME enable encoder NAME
  122. --disable-encoders disable all encoders
  123. --disable-decoder=NAME disable decoder NAME
  124. --enable-decoder=NAME enable decoder NAME
  125. --disable-decoders disable all decoders
  126. --disable-hwaccel=NAME disable hwaccel NAME
  127. --enable-hwaccel=NAME enable hwaccel NAME
  128. --disable-hwaccels disable all hwaccels
  129. --disable-muxer=NAME disable muxer NAME
  130. --enable-muxer=NAME enable muxer NAME
  131. --disable-muxers disable all muxers
  132. --disable-demuxer=NAME disable demuxer NAME
  133. --enable-demuxer=NAME enable demuxer NAME
  134. --disable-demuxers disable all demuxers
  135. --enable-parser=NAME enable parser NAME
  136. --disable-parser=NAME disable parser NAME
  137. --disable-parsers disable all parsers
  138. --enable-bsf=NAME enable bitstream filter NAME
  139. --disable-bsf=NAME disable bitstream filter NAME
  140. --disable-bsfs disable all bitstream filters
  141. --enable-protocol=NAME enable protocol NAME
  142. --disable-protocol=NAME disable protocol NAME
  143. --disable-protocols disable all protocols
  144. --enable-indev=NAME enable input device NAME
  145. --disable-indev=NAME disable input device NAME
  146. --disable-indevs disable input devices
  147. --enable-outdev=NAME enable output device NAME
  148. --disable-outdev=NAME disable output device NAME
  149. --disable-outdevs disable output devices
  150. --disable-devices disable all devices
  151. --enable-filter=NAME enable filter NAME
  152. --disable-filter=NAME disable filter NAME
  153. --disable-filters disable all filters
  154. External library support:
  155. --enable-avisynth enable reading of AVISynth script files [no]
  156. --enable-bzlib enable bzlib [autodetect]
  157. --enable-frei0r enable frei0r video filtering
  158. --enable-gnutls enable gnutls [no]
  159. --enable-libcdio enable audio CD grabbing with libcdio
  160. --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
  161. and libraw1394 [no]
  162. --enable-libfaac enable AAC encoding via libfaac [no]
  163. --enable-libfdk-aac enable AAC encoding via libfdk-aac [no]
  164. --enable-libfreetype enable libfreetype [no]
  165. --enable-libgsm enable GSM de/encoding via libgsm [no]
  166. --enable-libilbc enable iLBC de/encoding via libilbc [no]
  167. --enable-libmp3lame enable MP3 encoding via libmp3lame [no]
  168. --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
  169. --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
  170. --enable-libopencv enable video filtering via libopencv [no]
  171. --enable-libopenjpeg enable JPEG 2000 de/encoding via OpenJPEG [no]
  172. --enable-libopus enable Opus decoding via libopus [no]
  173. --enable-libpulse enable Pulseaudio input via libpulse [no]
  174. --enable-librtmp enable RTMP[E] support via librtmp [no]
  175. --enable-libschroedinger enable Dirac de/encoding via libschroedinger [no]
  176. --enable-libspeex enable Speex de/encoding via libspeex [no]
  177. --enable-libtheora enable Theora encoding via libtheora [no]
  178. --enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no]
  179. --enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no]
  180. --enable-libvorbis enable Vorbis encoding via libvorbis [no]
  181. --enable-libvpx enable VP8 de/encoding via libvpx [no]
  182. --enable-libx264 enable H.264 encoding via x264 [no]
  183. --enable-libxavs enable AVS encoding via xavs [no]
  184. --enable-libxvid enable Xvid encoding via xvidcore,
  185. native MPEG-4/Xvid encoder exists [no]
  186. --enable-openssl enable openssl [no]
  187. --enable-zlib enable zlib [autodetect]
  188. Advanced options (experts only):
  189. --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]
  190. --enable-cross-compile assume a cross-compiler is used
  191. --sysroot=PATH root of cross-build tree
  192. --sysinclude=PATH location of cross-build system headers
  193. --target-os=OS compiler targets OS [$target_os]
  194. --target-exec=CMD command to run executables on target
  195. --target-path=DIR path to view of build directory on target
  196. --toolchain=NAME set tool defaults according to NAME
  197. --nm=NM use nm tool
  198. --ar=AR use archive tool AR [$ar_default]
  199. --as=AS use assembler AS [$as_default]
  200. --cc=CC use C compiler CC [$cc_default]
  201. --dep-cc=DEPCC use dependency generator DEPCC [$cc_default]
  202. --ld=LD use linker LD
  203. --host-cc=HOSTCC use host C compiler HOSTCC
  204. --host-cflags=HCFLAGS use HCFLAGS when compiling for host
  205. --host-ld=HOSTLD use host linker HOSTLD
  206. --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
  207. --host-libs=HLIBS use libs HLIBS when linking for host
  208. --host-os=OS compiler host OS [$target_os]
  209. --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
  210. --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
  211. --extra-libs=ELIBS add ELIBS [$ELIBS]
  212. --extra-version=STRING version string suffix []
  213. --optflags=OPTFLAGS override optimization-related compiler flags
  214. --build-suffix=SUFFIX library name suffix []
  215. --malloc-prefix=PREFIX prefix malloc and related names with PREFIX
  216. --arch=ARCH select architecture [$arch]
  217. --cpu=CPU select the minimum required CPU (affects
  218. instruction selection, may crash on older CPUs)
  219. --enable-pic build position-independent code
  220. --enable-sram allow use of on-chip SRAM
  221. --enable-thumb compile for Thumb instruction set
  222. --disable-symver disable symbol versioning
  223. --enable-hardcoded-tables use hardcoded tables instead of runtime generation
  224. --disable-safe-bitstream-reader
  225. disable buffer boundary checking in bitreaders
  226. (faster, but may crash)
  227. --enable-memalign-hack emulate memalign, interferes with memory debuggers
  228. --enable-lto use link-time optimization
  229. Optimization options (experts only):
  230. --disable-asm disable all assembler optimizations
  231. --disable-altivec disable AltiVec optimizations
  232. --disable-amd3dnow disable 3DNow! optimizations
  233. --disable-amd3dnowext disable 3DNow! extended optimizations
  234. --disable-mmx disable MMX optimizations
  235. --disable-mmxext disable MMXEXT optimizations
  236. --disable-sse disable SSE optimizations
  237. --disable-sse2 disable SSE2 optimizations
  238. --disable-sse3 disable SSE3 optimizations
  239. --disable-ssse3 disable SSSE3 optimizations
  240. --disable-sse4 disable SSE4 optimizations
  241. --disable-sse42 disable SSE4.2 optimizations
  242. --disable-avx disable AVX optimizations
  243. --disable-fma4 disable FMA4 optimizations
  244. --disable-armv5te disable armv5te optimizations
  245. --disable-armv6 disable armv6 optimizations
  246. --disable-armv6t2 disable armv6t2 optimizations
  247. --disable-armvfp disable ARM VFP optimizations
  248. --disable-neon disable NEON optimizations
  249. --disable-vis disable VIS optimizations
  250. --disable-inline-asm disable use of inline assembler
  251. --disable-yasm disable use of yasm assembler
  252. Developer options (useful when working on Libav itself):
  253. --disable-debug disable debugging symbols
  254. --enable-debug=LEVEL set the debug level [$debuglevel]
  255. --disable-optimizations disable compiler optimizations
  256. --enable-extra-warnings enable more compiler warnings
  257. --samples=PATH location of test samples for FATE, if not set use
  258. \$LIBAV_SAMPLES at make invocation time.
  259. --enable-xmm-clobber-test check XMM registers for clobbering (Win64-only;
  260. should be used only for debugging purposes)
  261. --enable-random randomly enable/disable components
  262. --disable-random
  263. --enable-random=LIST randomly enable/disable specific components or
  264. --disable-random=LIST component groups. LIST is a comma-separated list
  265. of NAME[:PROB] entries where NAME is a component
  266. (group) and PROB the probability associated with
  267. NAME (default 0.5).
  268. --random-seed=VALUE seed value for --enable/disable-random
  269. NOTE: Object files are built at the place where configure is launched.
  270. EOF
  271. exit 0
  272. }
  273. quotes='""'
  274. log(){
  275. echo "$@" >> $logfile
  276. }
  277. log_file(){
  278. log BEGIN $1
  279. pr -n -t $1 >> $logfile
  280. log END $1
  281. }
  282. echolog(){
  283. log "$@"
  284. echo "$@"
  285. }
  286. warn(){
  287. log "WARNING: $*"
  288. WARNINGS="${WARNINGS}WARNING: $*\n"
  289. }
  290. die(){
  291. echolog "$@"
  292. cat <<EOF
  293. If you think configure made a mistake, make sure you are using the latest
  294. version from Git. If the latest version fails, report the problem to the
  295. libav-user@libav.org mailing list or IRC #libav on irc.freenode.net.
  296. EOF
  297. if disabled logging; then
  298. cat <<EOF
  299. Rerun configure with logging enabled (do not use --disable-logging), and
  300. include the log this produces with your report.
  301. EOF
  302. else
  303. cat <<EOF
  304. Include the log file "$logfile" produced by configure as this will help
  305. solving the problem.
  306. EOF
  307. fi
  308. exit 1
  309. }
  310. # Avoid locale weirdness, besides we really just want to translate ASCII.
  311. toupper(){
  312. echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  313. }
  314. tolower(){
  315. echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
  316. }
  317. c_escape(){
  318. echo "$*" | sed 's/["\\]/\\\0/g'
  319. }
  320. sh_quote(){
  321. v=$(echo "$1" | sed "s/'/'\\\\''/g")
  322. test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
  323. echo "$v"
  324. }
  325. cleanws(){
  326. echo "$@" | sed 's/^ *//;s/ */ /g;s/ *$//'
  327. }
  328. filter(){
  329. pat=$1
  330. shift
  331. for v; do
  332. eval "case $v in $pat) echo $v ;; esac"
  333. done
  334. }
  335. filter_out(){
  336. pat=$1
  337. shift
  338. for v; do
  339. eval "case $v in $pat) ;; *) echo $v ;; esac"
  340. done
  341. }
  342. map(){
  343. m=$1
  344. shift
  345. for v; do eval $m; done
  346. }
  347. add_suffix(){
  348. suffix=$1
  349. shift
  350. for v; do echo ${v}${suffix}; done
  351. }
  352. set_all(){
  353. value=$1
  354. shift
  355. for var in $*; do
  356. eval $var=$value
  357. done
  358. }
  359. set_weak(){
  360. value=$1
  361. shift
  362. for var; do
  363. eval : \${$var:=$value}
  364. done
  365. }
  366. set_safe(){
  367. var=$1
  368. shift
  369. eval $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')='$*'
  370. }
  371. get_safe(){
  372. eval echo \$$(echo "$1" | sed 's/[^A-Za-z0-9_]/_/g')
  373. }
  374. pushvar(){
  375. for var in $*; do
  376. eval level=\${${var}_level:=0}
  377. eval ${var}_${level}="\$$var"
  378. eval ${var}_level=$(($level+1))
  379. done
  380. }
  381. popvar(){
  382. for var in $*; do
  383. eval level=\${${var}_level:-0}
  384. test $level = 0 && continue
  385. eval level=$(($level-1))
  386. eval $var="\${${var}_${level}}"
  387. eval ${var}_level=$level
  388. eval unset ${var}_${level}
  389. done
  390. }
  391. enable(){
  392. set_all yes $*
  393. }
  394. disable(){
  395. set_all no $*
  396. }
  397. enable_weak(){
  398. set_weak yes $*
  399. }
  400. disable_weak(){
  401. set_weak no $*
  402. }
  403. enable_safe(){
  404. for var; do
  405. enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
  406. done
  407. }
  408. disable_safe(){
  409. for var; do
  410. disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
  411. done
  412. }
  413. do_enable_deep(){
  414. for var; do
  415. enabled $var && continue
  416. eval sel="\$${var}_select"
  417. eval sgs="\$${var}_suggest"
  418. pushvar var sgs
  419. enable_deep $sel
  420. popvar sgs
  421. enable_deep_weak $sgs
  422. popvar var
  423. done
  424. }
  425. enable_deep(){
  426. do_enable_deep $*
  427. enable $*
  428. }
  429. enable_deep_weak(){
  430. do_enable_deep $*
  431. enable_weak $*
  432. }
  433. enabled(){
  434. test "${1#!}" = "$1" && op== || op=!=
  435. eval test "x\$${1#!}" $op "xyes"
  436. }
  437. disabled(){
  438. test "${1#!}" = "$1" && op== || op=!=
  439. eval test "x\$${1#!}" $op "xno"
  440. }
  441. enabled_all(){
  442. for opt; do
  443. enabled $opt || return 1
  444. done
  445. }
  446. disabled_all(){
  447. for opt; do
  448. disabled $opt || return 1
  449. done
  450. }
  451. enabled_any(){
  452. for opt; do
  453. enabled $opt && return 0
  454. done
  455. }
  456. disabled_any(){
  457. for opt; do
  458. disabled $opt && return 0
  459. done
  460. return 1
  461. }
  462. set_default(){
  463. for opt; do
  464. eval : \${$opt:=\$${opt}_default}
  465. done
  466. }
  467. is_in(){
  468. value=$1
  469. shift
  470. for var in $*; do
  471. [ $var = $value ] && return 0
  472. done
  473. return 1
  474. }
  475. check_deps(){
  476. for cfg; do
  477. cfg="${cfg#!}"
  478. enabled ${cfg}_checking && die "Circular dependency for $cfg."
  479. disabled ${cfg}_checking && continue
  480. enable ${cfg}_checking
  481. eval dep_all="\$${cfg}_deps"
  482. eval dep_any="\$${cfg}_deps_any"
  483. eval dep_sel="\$${cfg}_select"
  484. eval dep_sgs="\$${cfg}_suggest"
  485. eval dep_ifa="\$${cfg}_if"
  486. eval dep_ifn="\$${cfg}_if_any"
  487. pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
  488. check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
  489. popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
  490. [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
  491. [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
  492. enabled_all $dep_all || disable $cfg
  493. enabled_any $dep_any || disable $cfg
  494. disabled_any $dep_sel && disable $cfg
  495. if enabled $cfg; then
  496. eval dep_extralibs="\$${cfg}_extralibs"
  497. test -n "$dep_extralibs" && add_extralibs $dep_extralibs
  498. enable_deep $dep_sel
  499. enable_deep_weak $dep_sgs
  500. fi
  501. disable ${cfg}_checking
  502. done
  503. }
  504. print_config(){
  505. pfx=$1
  506. files=$2
  507. shift 2
  508. map 'eval echo "$v \${$v:-no}"' "$@" |
  509. awk "BEGIN { split(\"$files\", files) }
  510. {
  511. c = \"$pfx\" toupper(\$1);
  512. v = \$2;
  513. sub(/yes/, 1, v);
  514. sub(/no/, 0, v);
  515. for (f in files) {
  516. file = files[f];
  517. if (file ~ /\\.h\$/) {
  518. printf(\"#define %s %d\\n\", c, v) >>file;
  519. } else if (file ~ /\\.asm\$/) {
  520. printf(\"%%define %s %d\\n\", c, v) >>file;
  521. } else if (file ~ /\\.mak\$/) {
  522. n = -v ? \"\" : \"!\";
  523. printf(\"%s%s=yes\\n\", n, c) >>file;
  524. }
  525. }
  526. }"
  527. }
  528. print_enabled(){
  529. suf=$1
  530. shift
  531. for v; do
  532. enabled $v && printf "%s\n" ${v%$suf};
  533. done
  534. }
  535. append(){
  536. var=$1
  537. shift
  538. eval "$var=\"\$$var $*\""
  539. }
  540. prepend(){
  541. var=$1
  542. shift
  543. eval "$var=\"$* \$$var\""
  544. }
  545. add_cppflags(){
  546. append CPPFLAGS "$@"
  547. }
  548. add_cflags(){
  549. append CFLAGS $($cflags_filter "$@")
  550. }
  551. add_asflags(){
  552. append ASFLAGS $($asflags_filter "$@")
  553. }
  554. add_ldflags(){
  555. append LDFLAGS $($ldflags_filter "$@")
  556. }
  557. add_extralibs(){
  558. prepend extralibs $($ldflags_filter "$@")
  559. }
  560. add_host_cflags(){
  561. append host_cflags $($host_cflags_filter "$@")
  562. }
  563. add_host_ldflags(){
  564. append host_ldflags $($host_ldflags_filter "$@")
  565. }
  566. add_compat(){
  567. append compat_objs $1
  568. shift
  569. map 'add_cppflags -D$v' "$@"
  570. }
  571. check_cmd(){
  572. log "$@"
  573. "$@" >> $logfile 2>&1
  574. }
  575. cc_o(){
  576. eval printf '%s\\n' $CC_O
  577. }
  578. cc_e(){
  579. eval printf '%s\\n' $CC_E
  580. }
  581. check_cc(){
  582. log check_cc "$@"
  583. cat > $TMPC
  584. log_file $TMPC
  585. check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
  586. }
  587. check_cpp(){
  588. log check_cpp "$@"
  589. cat > $TMPC
  590. log_file $TMPC
  591. check_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
  592. }
  593. as_o(){
  594. eval printf '%s\\n' $AS_O
  595. }
  596. check_as(){
  597. log check_as "$@"
  598. cat > $TMPC
  599. log_file $TMPC
  600. check_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPC
  601. }
  602. check_inline_asm(){
  603. log check_inline_asm "$@"
  604. name="$1"
  605. code="$2"
  606. shift 2
  607. disable $name
  608. check_as "$@" <<EOF && enable $name
  609. void foo(void){ __asm__ volatile($code); }
  610. EOF
  611. }
  612. check_yasm(){
  613. log check_yasm "$@"
  614. echo "$1" > $TMPS
  615. log_file $TMPS
  616. shift 1
  617. check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
  618. }
  619. ld_o(){
  620. eval printf '%s\\n' $LD_O
  621. }
  622. check_ld(){
  623. log check_ld "$@"
  624. flags=$(filter_out '-l*' "$@")
  625. libs=$(filter '-l*' "$@")
  626. check_cc $($cflags_filter $flags) || return
  627. flags=$($ldflags_filter $flags)
  628. libs=$($ldflags_filter $libs)
  629. check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
  630. }
  631. check_code(){
  632. log check_code "$@"
  633. check=$1
  634. headers=$2
  635. code=$3
  636. shift 3
  637. {
  638. for hdr in $headers; do
  639. echo "#include <$hdr>"
  640. done
  641. echo "int main(void) { $code; return 0; }"
  642. } | check_$check "$@"
  643. }
  644. check_cppflags(){
  645. log check_cppflags "$@"
  646. check_cc "$@" <<EOF && append CPPFLAGS "$@"
  647. int x;
  648. EOF
  649. }
  650. check_cflags(){
  651. log check_cflags "$@"
  652. set -- $($cflags_filter "$@")
  653. check_cc "$@" <<EOF && append CFLAGS "$@"
  654. int x;
  655. EOF
  656. }
  657. test_ldflags(){
  658. log test_ldflags "$@"
  659. check_ld "$@" <<EOF
  660. int main(void){ return 0; }
  661. EOF
  662. }
  663. check_ldflags(){
  664. log check_ldflags "$@"
  665. test_ldflags "$@" && add_ldflags "$@"
  666. }
  667. check_header(){
  668. log check_header "$@"
  669. header=$1
  670. shift
  671. disable_safe $header
  672. check_cpp "$@" <<EOF && enable_safe $header
  673. #include <$header>
  674. int x;
  675. EOF
  676. }
  677. check_func(){
  678. log check_func "$@"
  679. func=$1
  680. shift
  681. disable $func
  682. check_ld "$@" <<EOF && enable $func
  683. extern int $func();
  684. int main(void){ $func(); }
  685. EOF
  686. }
  687. check_mathfunc(){
  688. log check_mathfunc "$@"
  689. func=$1
  690. narg=$2
  691. shift 2
  692. test $narg = 2 && args="f, g" || args="f"
  693. disable $func
  694. check_ld "$@" <<EOF && enable $func
  695. #include <math.h>
  696. float foo(float f, float g) { return $func($args); }
  697. int main(void){ return 0; }
  698. EOF
  699. }
  700. check_func_headers(){
  701. log check_func_headers "$@"
  702. headers=$1
  703. funcs=$2
  704. shift 2
  705. {
  706. for hdr in $headers; do
  707. echo "#include <$hdr>"
  708. done
  709. for func in $funcs; do
  710. echo "long check_$func(void) { return (long) $func; }"
  711. done
  712. echo "int main(void) { return 0; }"
  713. } | check_ld "$@" && enable $funcs && enable_safe $headers
  714. }
  715. check_cpp_condition(){
  716. log check_cpp_condition "$@"
  717. header=$1
  718. condition=$2
  719. shift 2
  720. check_cpp "$@" <<EOF
  721. #include <$header>
  722. #if !($condition)
  723. #error "unsatisfied condition: $condition"
  724. #endif
  725. EOF
  726. }
  727. check_lib(){
  728. log check_lib "$@"
  729. header="$1"
  730. func="$2"
  731. shift 2
  732. check_header $header && check_func $func "$@" && add_extralibs "$@"
  733. }
  734. check_lib2(){
  735. log check_lib2 "$@"
  736. headers="$1"
  737. funcs="$2"
  738. shift 2
  739. check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
  740. }
  741. check_pkg_config(){
  742. log check_pkg_config "$@"
  743. pkg="$1"
  744. headers="$2"
  745. funcs="$3"
  746. shift 3
  747. $pkg_config --exists $pkg || return
  748. pkg_cflags=$($pkg_config --cflags $pkg)
  749. pkg_libs=$($pkg_config --libs $pkg)
  750. check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
  751. set_safe ${pkg}_cflags $pkg_cflags &&
  752. set_safe ${pkg}_libs $pkg_libs
  753. }
  754. check_exec(){
  755. check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
  756. }
  757. check_exec_crash(){
  758. code=$(cat)
  759. # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
  760. # are safe but may not be available everywhere. Thus we use
  761. # raise(SIGTERM) instead. The check is run in a subshell so we
  762. # can redirect the "Terminated" message from the shell. SIGBUS
  763. # is not defined by standard C so it is used conditionally.
  764. (check_exec "$@") >> $logfile 2>&1 <<EOF
  765. #include <signal.h>
  766. static void sighandler(int sig){
  767. raise(SIGTERM);
  768. }
  769. int foo(void){
  770. $code
  771. }
  772. int main(void){
  773. signal(SIGILL, sighandler);
  774. signal(SIGFPE, sighandler);
  775. signal(SIGSEGV, sighandler);
  776. #ifdef SIGBUS
  777. signal(SIGBUS, sighandler);
  778. #endif
  779. foo();
  780. }
  781. EOF
  782. }
  783. check_type(){
  784. log check_type "$@"
  785. headers=$1
  786. type=$2
  787. shift 2
  788. disable_safe "$type"
  789. check_code cc "$headers" "$type v" "$@" && enable_safe "$type"
  790. }
  791. check_struct(){
  792. log check_type "$@"
  793. headers=$1
  794. struct=$2
  795. member=$3
  796. shift 3
  797. disable_safe "${struct}_${member}"
  798. check_code cc "$headers" "const void *p = &(($struct *)0)->$member" "$@" &&
  799. enable_safe "${struct}_${member}"
  800. }
  801. require(){
  802. name="$1"
  803. header="$2"
  804. func="$3"
  805. shift 3
  806. check_lib $header $func "$@" || die "ERROR: $name not found"
  807. }
  808. require2(){
  809. name="$1"
  810. headers="$2"
  811. func="$3"
  812. shift 3
  813. check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
  814. }
  815. require_pkg_config(){
  816. pkg="$1"
  817. check_pkg_config "$@" || die "ERROR: $pkg not found"
  818. add_cflags $(get_safe ${pkg}_cflags)
  819. add_extralibs $(get_safe ${pkg}_libs)
  820. }
  821. hostcc_o(){
  822. eval printf '%s\\n' $HOSTCC_O
  823. }
  824. check_host_cc(){
  825. log check_host_cc "$@"
  826. cat > $TMPC
  827. log_file $TMPC
  828. check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
  829. }
  830. check_host_cflags(){
  831. log check_host_cflags "$@"
  832. set -- $($host_cflags_filter "$@")
  833. check_host_cc "$@" <<EOF && append host_cflags "$@"
  834. int x;
  835. EOF
  836. }
  837. apply(){
  838. file=$1
  839. shift
  840. "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
  841. }
  842. cp_if_changed(){
  843. cmp -s "$1" "$2" && echo "$2 is unchanged" && return
  844. mkdir -p "$(dirname $2)"
  845. $cp_f "$1" "$2"
  846. }
  847. # CONFIG_LIST contains configurable options, while HAVE_LIST is for
  848. # system-dependent things.
  849. COMPONENT_LIST="
  850. bsfs
  851. decoders
  852. demuxers
  853. encoders
  854. filters
  855. hwaccels
  856. indevs
  857. muxers
  858. outdevs
  859. parsers
  860. protocols
  861. "
  862. PROGRAM_LIST="
  863. avconv
  864. avplay
  865. avprobe
  866. avserver
  867. "
  868. CONFIG_LIST="
  869. $COMPONENT_LIST
  870. $PROGRAM_LIST
  871. avcodec
  872. avdevice
  873. avfilter
  874. avformat
  875. avresample
  876. avisynth
  877. bzlib
  878. dct
  879. doc
  880. dwt
  881. dxva2
  882. fft
  883. frei0r
  884. gnutls
  885. gpl
  886. gray
  887. hardcoded_tables
  888. libcdio
  889. libdc1394
  890. libfaac
  891. libfdk_aac
  892. libfreetype
  893. libgsm
  894. libilbc
  895. libmp3lame
  896. libopencore_amrnb
  897. libopencore_amrwb
  898. libopencv
  899. libopenjpeg
  900. libopus
  901. libpulse
  902. librtmp
  903. libschroedinger
  904. libspeex
  905. libtheora
  906. libvo_aacenc
  907. libvo_amrwbenc
  908. libvorbis
  909. libvpx
  910. libx264
  911. libxavs
  912. libxvid
  913. lsp
  914. lzo
  915. mdct
  916. memalign_hack
  917. network
  918. nonfree
  919. openssl
  920. pic
  921. rdft
  922. runtime_cpudetect
  923. safe_bitstream_reader
  924. shared
  925. small
  926. sram
  927. static
  928. swscale
  929. swscale_alpha
  930. thumb
  931. vaapi
  932. vda
  933. vdpau
  934. version3
  935. xmm_clobber_test
  936. x11grab
  937. zlib
  938. "
  939. THREADS_LIST='
  940. pthreads
  941. w32threads
  942. '
  943. ARCH_LIST='
  944. alpha
  945. arm
  946. avr32
  947. avr32_ap
  948. avr32_uc
  949. bfin
  950. ia64
  951. m68k
  952. mips
  953. mips64
  954. parisc
  955. ppc
  956. ppc64
  957. s390
  958. sh4
  959. sparc
  960. sparc64
  961. tilegx
  962. tilepro
  963. tomi
  964. x86
  965. x86_32
  966. x86_64
  967. '
  968. ARCH_EXT_LIST_X86='
  969. amd3dnow
  970. amd3dnowext
  971. avx
  972. fma4
  973. mmx
  974. mmxext
  975. sse
  976. sse2
  977. sse3
  978. sse4
  979. sse42
  980. ssse3
  981. '
  982. ARCH_EXT_LIST="
  983. $ARCH_EXT_LIST_X86
  984. altivec
  985. armv5te
  986. armv6
  987. armv6t2
  988. armvfp
  989. neon
  990. ppc4xx
  991. vfpv3
  992. vis
  993. "
  994. HAVE_LIST_CMDLINE='
  995. inline_asm
  996. symver
  997. yasm
  998. '
  999. HAVE_LIST_PUB='
  1000. bigendian
  1001. fast_unaligned
  1002. '
  1003. MATH_FUNCS="
  1004. atanf
  1005. atan2f
  1006. cbrtf
  1007. cosf
  1008. exp2
  1009. exp2f
  1010. expf
  1011. isinf
  1012. isnan
  1013. ldexpf
  1014. llrint
  1015. llrintf
  1016. log2
  1017. log2f
  1018. log10f
  1019. lrint
  1020. lrintf
  1021. powf
  1022. rint
  1023. round
  1024. roundf
  1025. sinf
  1026. trunc
  1027. truncf
  1028. "
  1029. HAVE_LIST="
  1030. $ARCH_EXT_LIST
  1031. $(add_suffix _external $ARCH_EXT_LIST)
  1032. $(add_suffix _inline $ARCH_EXT_LIST)
  1033. $HAVE_LIST_CMDLINE
  1034. $HAVE_LIST_PUB
  1035. $THREADS_LIST
  1036. $MATH_FUNCS
  1037. aligned_malloc
  1038. aligned_stack
  1039. alsa_asoundlib_h
  1040. altivec_h
  1041. arpa_inet_h
  1042. asm_mod_q
  1043. asm_mod_y
  1044. attribute_may_alias
  1045. attribute_packed
  1046. closesocket
  1047. cmov
  1048. cpunop
  1049. CryptGenRandom
  1050. dcbzl
  1051. dev_bktr_ioctl_bt848_h
  1052. dev_bktr_ioctl_meteor_h
  1053. dev_ic_bt8xx_h
  1054. dev_video_bktr_ioctl_bt848_h
  1055. dev_video_meteor_ioctl_meteor_h
  1056. direct_h
  1057. dlfcn_h
  1058. dlopen
  1059. dos_paths
  1060. dxva_h
  1061. ebp_available
  1062. ebx_available
  1063. fast_64bit
  1064. fast_clz
  1065. fast_cmov
  1066. fcntl
  1067. fork
  1068. getaddrinfo
  1069. gethrtime
  1070. getopt
  1071. GetProcessAffinityMask
  1072. GetProcessMemoryInfo
  1073. GetProcessTimes
  1074. GetSystemTimeAsFileTime
  1075. getrusage
  1076. getservbyport
  1077. gettimeofday
  1078. gnu_as
  1079. ibm_asm
  1080. inet_aton
  1081. io_h
  1082. isatty
  1083. jack_port_get_latency_range
  1084. ldbrx
  1085. libdc1394_1
  1086. libdc1394_2
  1087. local_aligned_16
  1088. local_aligned_8
  1089. localtime_r
  1090. loongson
  1091. machine_ioctl_bt848_h
  1092. machine_ioctl_meteor_h
  1093. malloc_h
  1094. MapViewOfFile
  1095. memalign
  1096. mkstemp
  1097. mm_empty
  1098. mmap
  1099. mprotect
  1100. msvcrt
  1101. nanosleep
  1102. poll_h
  1103. posix_memalign
  1104. rdtsc
  1105. sched_getaffinity
  1106. sdl
  1107. sdl_video_size
  1108. setmode
  1109. setrlimit
  1110. Sleep
  1111. sndio_h
  1112. socklen_t
  1113. soundcard_h
  1114. strerror_r
  1115. strptime
  1116. strtok_r
  1117. struct_addrinfo
  1118. struct_group_source_req
  1119. struct_ip_mreq_source
  1120. struct_ipv6_mreq
  1121. struct_pollfd
  1122. struct_rusage_ru_maxrss
  1123. struct_sockaddr_in6
  1124. struct_sockaddr_sa_len
  1125. struct_sockaddr_storage
  1126. struct_v4l2_frmivalenum_discrete
  1127. symver_asm_label
  1128. symver_gnu_asm
  1129. sysconf
  1130. sysctl
  1131. sys_mman_h
  1132. sys_param_h
  1133. sys_resource_h
  1134. sys_select_h
  1135. sys_soundcard_h
  1136. sys_time_h
  1137. sys_videoio_h
  1138. threads
  1139. unistd_h
  1140. usleep
  1141. vfp_args
  1142. VirtualAlloc
  1143. windows_h
  1144. winsock2_h
  1145. xform_asm
  1146. xmm_clobbers
  1147. "
  1148. # options emitted with CONFIG_ prefix but not available on command line
  1149. CONFIG_EXTRA="
  1150. aandcttables
  1151. ac3dsp
  1152. avutil
  1153. error_resilience
  1154. gcrypt
  1155. golomb
  1156. gplv3
  1157. h264chroma
  1158. h264dsp
  1159. h264pred
  1160. h264qpel
  1161. huffman
  1162. lgplv3
  1163. lpc
  1164. mpegaudio
  1165. mpegaudiodsp
  1166. mpegvideo
  1167. mpegvideoenc
  1168. nettle
  1169. rangecoder
  1170. rtpdec
  1171. sinewin
  1172. vp3dsp
  1173. "
  1174. CMDLINE_SELECT="
  1175. $ARCH_EXT_LIST
  1176. $CONFIG_LIST
  1177. $HAVE_LIST_CMDLINE
  1178. $THREADS_LIST
  1179. asm
  1180. cross_compile
  1181. debug
  1182. extra_warnings
  1183. logging
  1184. lto
  1185. optimizations
  1186. "
  1187. PATHS_LIST='
  1188. bindir
  1189. datadir
  1190. incdir
  1191. libdir
  1192. mandir
  1193. prefix
  1194. shlibdir
  1195. '
  1196. CMDLINE_SET="
  1197. $PATHS_LIST
  1198. ar
  1199. arch
  1200. as
  1201. build_suffix
  1202. cc
  1203. cpu
  1204. cross_prefix
  1205. dep_cc
  1206. extra_version
  1207. host_cc
  1208. host_cflags
  1209. host_ld
  1210. host_ldflags
  1211. host_libs
  1212. host_os
  1213. ld
  1214. logfile
  1215. malloc_prefix
  1216. nm
  1217. optflags
  1218. pkg_config
  1219. random_seed
  1220. samples
  1221. sysinclude
  1222. sysroot
  1223. target_exec
  1224. target_os
  1225. target_path
  1226. toolchain
  1227. "
  1228. CMDLINE_APPEND="
  1229. extra_cflags
  1230. "
  1231. # code dependency declarations
  1232. # architecture extensions
  1233. armv5te_deps="arm"
  1234. armv6_deps="arm"
  1235. armv6t2_deps="arm"
  1236. armvfp_deps="arm"
  1237. neon_deps="arm"
  1238. vfpv3_deps="armvfp"
  1239. altivec_deps="ppc"
  1240. ppc4xx_deps="ppc"
  1241. vis_deps="sparc"
  1242. x86_64_suggest="cmov fast_cmov"
  1243. amd3dnow_deps="mmx"
  1244. amd3dnowext_deps="amd3dnow"
  1245. mmx_deps="x86"
  1246. mmxext_deps="mmx"
  1247. sse_deps="mmxext"
  1248. sse2_deps="sse"
  1249. sse3_deps="sse2"
  1250. ssse3_deps="sse3"
  1251. sse4_deps="ssse3"
  1252. sse42_deps="sse4"
  1253. avx_deps="sse42"
  1254. fma4_deps="avx"
  1255. mmx_external_deps="yasm"
  1256. mmx_inline_deps="inline_asm"
  1257. mmx_suggest="mmx_external mmx_inline"
  1258. for ext in $(filter_out mmx $ARCH_EXT_LIST_X86); do
  1259. eval dep=\$${ext}_deps
  1260. eval ${ext}_external_deps='"${dep}_external"'
  1261. eval ${ext}_inline_deps='"${dep}_inline"'
  1262. eval ${ext}_suggest='"${ext}_external ${ext}_inline"'
  1263. done
  1264. aligned_stack_if_any="ppc x86"
  1265. fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
  1266. fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
  1267. fast_unaligned_if_any="armv6 ppc x86"
  1268. inline_asm_deps="!tms470"
  1269. need_memalign="altivec neon sse"
  1270. symver_if_any="symver_asm_label symver_gnu_asm"
  1271. log2_deps="!msvcrt"
  1272. # subsystems
  1273. dct_select="rdft"
  1274. mdct_select="fft"
  1275. rdft_select="fft"
  1276. mpegaudio_select="mpegaudiodsp"
  1277. mpegaudiodsp_select="dct"
  1278. mpegvideoenc_select="mpegvideo"
  1279. # decoders / encoders / hardware accelerators
  1280. aac_decoder_select="mdct sinewin"
  1281. aac_encoder_select="mdct sinewin"
  1282. aac_latm_decoder_select="aac_decoder aac_latm_parser"
  1283. ac3_decoder_select="mdct ac3dsp ac3_parser"
  1284. ac3_encoder_select="mdct ac3dsp"
  1285. ac3_fixed_encoder_select="mdct ac3dsp"
  1286. alac_encoder_select="lpc"
  1287. amrnb_decoder_select="lsp"
  1288. amrwb_decoder_select="lsp"
  1289. atrac1_decoder_select="mdct sinewin"
  1290. atrac3_decoder_select="mdct"
  1291. binkaudio_dct_decoder_select="mdct rdft dct sinewin"
  1292. binkaudio_rdft_decoder_select="mdct rdft sinewin"
  1293. cavs_decoder_select="golomb mpegvideo"
  1294. comfortnoise_encoder_select="lpc"
  1295. cook_decoder_select="mdct sinewin"
  1296. cscd_decoder_select="lzo"
  1297. cscd_decoder_suggest="zlib"
  1298. dca_decoder_select="mdct"
  1299. dnxhd_encoder_select="aandcttables mpegvideoenc"
  1300. dxa_decoder_select="zlib"
  1301. eac3_decoder_select="ac3_decoder"
  1302. eac3_encoder_select="ac3_encoder"
  1303. eamad_decoder_select="aandcttables error_resilience mpegvideo"
  1304. eatgq_decoder_select="aandcttables"
  1305. eatqi_decoder_select="aandcttables error_resilience mpegvideo"
  1306. ffv1_decoder_select="golomb rangecoder"
  1307. ffv1_encoder_select="rangecoder"
  1308. ffvhuff_encoder_select="huffman"
  1309. flac_decoder_select="golomb"
  1310. flac_encoder_select="golomb lpc"
  1311. flashsv_decoder_select="zlib"
  1312. flashsv_encoder_select="zlib"
  1313. flashsv2_decoder_select="zlib"
  1314. flv_decoder_select="h263_decoder"
  1315. flv_encoder_select="h263_encoder"
  1316. fraps_decoder_select="huffman"
  1317. h261_decoder_select="error_resilience mpegvideo"
  1318. h261_encoder_select="aandcttables mpegvideoenc"
  1319. h263_decoder_select="error_resilience h263_parser mpegvideo"
  1320. h263_encoder_select="aandcttables error_resilience mpegvideoenc"
  1321. h263_vaapi_hwaccel_select="vaapi h263_decoder"
  1322. h263i_decoder_select="h263_decoder"
  1323. h263p_encoder_select="h263_encoder"
  1324. h264_decoder_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
  1325. h264_dxva2_hwaccel_deps="dxva2api_h"
  1326. h264_dxva2_hwaccel_select="dxva2 h264_decoder"
  1327. h264_vaapi_hwaccel_select="vaapi h264_decoder"
  1328. h264_vda_hwaccel_select="vda h264_decoder"
  1329. h264_vdpau_decoder_select="vdpau h264_decoder"
  1330. huffyuv_encoder_select="huffman"
  1331. iac_decoder_select="fft mdct sinewin"
  1332. imc_decoder_select="fft mdct sinewin"
  1333. jpegls_decoder_select="golomb"
  1334. jpegls_encoder_select="golomb"
  1335. ljpeg_encoder_select="aandcttables mpegvideoenc"
  1336. loco_decoder_select="golomb"
  1337. mdec_decoder_select="error_resilience mpegvideo"
  1338. mjpeg_encoder_select="aandcttables mpegvideoenc"
  1339. mlp_decoder_select="mlp_parser"
  1340. mp1_decoder_select="mpegaudio"
  1341. mp1float_decoder_select="mpegaudio"
  1342. mp2_decoder_select="mpegaudio"
  1343. mp2float_decoder_select="mpegaudio"
  1344. mp3_decoder_select="mpegaudio"
  1345. mp3adu_decoder_select="mpegaudio"
  1346. mp3adufloat_decoder_select="mpegaudio"
  1347. mp3float_decoder_select="mpegaudio"
  1348. mp3on4_decoder_select="mpegaudio"
  1349. mp3on4float_decoder_select="mpegaudio"
  1350. mpc7_decoder_select="mpegaudiodsp"
  1351. mpc8_decoder_select="mpegaudiodsp"
  1352. mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
  1353. mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
  1354. mpeg_xvmc_decoder_select="mpegvideo_decoder"
  1355. mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
  1356. mpeg1video_decoder_select="error_resilience mpegvideo"
  1357. mpeg1video_encoder_select="aandcttables error_resilience mpegvideoenc"
  1358. mpeg2_dxva2_hwaccel_deps="dxva2api_h"
  1359. mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder"
  1360. mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
  1361. mpeg2video_decoder_select="error_resilience mpegvideo"
  1362. mpeg2video_encoder_select="aandcttables error_resilience mpegvideoenc"
  1363. mpeg4_decoder_select="h263_decoder mpeg4video_parser"
  1364. mpeg4_encoder_select="h263_encoder"
  1365. mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
  1366. mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
  1367. msmpeg4v1_decoder_select="h263_decoder"
  1368. msmpeg4v1_encoder_select="h263_encoder"
  1369. msmpeg4v2_decoder_select="h263_decoder"
  1370. msmpeg4v2_encoder_select="h263_encoder"
  1371. msmpeg4v3_decoder_select="h263_decoder"
  1372. msmpeg4v3_encoder_select="h263_encoder"
  1373. mss2_decoder_select="vc1_decoder"
  1374. nellymoser_decoder_select="mdct sinewin"
  1375. nellymoser_encoder_select="mdct sinewin"
  1376. nuv_decoder_select="lzo"
  1377. png_decoder_select="zlib"
  1378. png_encoder_select="zlib"
  1379. qcelp_decoder_select="lsp"
  1380. qdm2_decoder_select="mdct rdft mpegaudiodsp"
  1381. ra_144_encoder_select="lpc"
  1382. ralf_decoder_select="golomb"
  1383. rv10_decoder_select="h263_decoder"
  1384. rv10_encoder_select="h263_encoder"
  1385. rv20_decoder_select="h263_decoder"
  1386. rv20_encoder_select="h263_encoder"
  1387. rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo"
  1388. rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo"
  1389. shorten_decoder_select="golomb"
  1390. sipr_decoder_select="lsp"
  1391. snow_decoder_select="dwt rangecoder"
  1392. snow_encoder_select="aandcttables dwt error_resilience mpegvideoenc rangecoder"
  1393. svq1_decoder_select="error_resilience mpegvideo"
  1394. svq1_encoder_select="aandcttables error_resilience mpegvideoenc"
  1395. svq3_decoder_select="error_resilience golomb h264chroma h264dsp h264pred h264qpel mpegvideo"
  1396. svq3_decoder_suggest="zlib"
  1397. theora_decoder_select="vp3_decoder"
  1398. tiff_decoder_suggest="zlib"
  1399. tiff_encoder_suggest="zlib"
  1400. truehd_decoder_select="mlp_decoder"
  1401. tscc_decoder_select="zlib"
  1402. twinvq_decoder_select="mdct lsp sinewin"
  1403. utvideo_encoder_select="huffman"
  1404. vc1_decoder_select="h263_decoder h264chroma h264qpel"
  1405. vc1_dxva2_hwaccel_deps="dxva2api_h"
  1406. vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
  1407. vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
  1408. vc1_vdpau_decoder_select="vdpau vc1_decoder"
  1409. vc1image_decoder_select="vc1_decoder"
  1410. vorbis_decoder_select="mdct"
  1411. vorbis_encoder_select="mdct"
  1412. vp3_decoder_select="vp3dsp"
  1413. vp5_decoder_select="vp3dsp"
  1414. vp6_decoder_select="huffman vp3dsp"
  1415. vp6a_decoder_select="vp6_decoder"
  1416. vp6f_decoder_select="vp6_decoder"
  1417. vp8_decoder_select="h264pred h264qpel"
  1418. wmapro_decoder_select="mdct sinewin"
  1419. wmav1_decoder_select="mdct sinewin"
  1420. wmav1_encoder_select="mdct sinewin"
  1421. wmav2_decoder_select="mdct sinewin"
  1422. wmav2_encoder_select="mdct sinewin"
  1423. wmavoice_decoder_select="lsp rdft dct mdct sinewin"
  1424. wmv1_decoder_select="h263_decoder"
  1425. wmv1_encoder_select="h263_encoder"
  1426. wmv2_decoder_select="h263_decoder"
  1427. wmv2_encoder_select="h263_encoder"
  1428. wmv3_decoder_select="vc1_decoder"
  1429. wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
  1430. wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
  1431. wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
  1432. wmv3image_decoder_select="wmv3_decoder"
  1433. zerocodec_decoder_select="zlib"
  1434. zlib_decoder_select="zlib"
  1435. zlib_encoder_select="zlib"
  1436. zmbv_decoder_select="zlib"
  1437. zmbv_encoder_select="zlib"
  1438. vaapi_deps="va_va_h"
  1439. vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
  1440. vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  1441. # parsers
  1442. h264_parser_select="error_resilience golomb h264dsp h264pred mpegvideo"
  1443. mpeg4video_parser_select="error_resilience mpegvideo"
  1444. mpegvideo_parser_select="error_resilience mpegvideo"
  1445. vc1_parser_select="error_resilience mpegvideo"
  1446. # external libraries
  1447. libfaac_encoder_deps="libfaac"
  1448. libfdk_aac_encoder_deps="libfdk_aac"
  1449. libgsm_decoder_deps="libgsm"
  1450. libgsm_encoder_deps="libgsm"
  1451. libgsm_ms_decoder_deps="libgsm"
  1452. libgsm_ms_encoder_deps="libgsm"
  1453. libilbc_decoder_deps="libilbc"
  1454. libilbc_encoder_deps="libilbc"
  1455. libmp3lame_encoder_deps="libmp3lame"
  1456. libopencore_amrnb_decoder_deps="libopencore_amrnb"
  1457. libopencore_amrnb_encoder_deps="libopencore_amrnb"
  1458. libopencore_amrwb_decoder_deps="libopencore_amrwb"
  1459. libopenjpeg_decoder_deps="libopenjpeg"
  1460. libopenjpeg_encoder_deps="libopenjpeg"
  1461. libopus_decoder_deps="libopus"
  1462. libopus_encoder_deps="libopus"
  1463. libschroedinger_decoder_deps="libschroedinger"
  1464. libschroedinger_encoder_deps="libschroedinger"
  1465. libspeex_decoder_deps="libspeex"
  1466. libspeex_encoder_deps="libspeex"
  1467. libtheora_encoder_deps="libtheora"
  1468. libvo_aacenc_encoder_deps="libvo_aacenc"
  1469. libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
  1470. libvorbis_encoder_deps="libvorbis"
  1471. libvpx_decoder_deps="libvpx"
  1472. libvpx_encoder_deps="libvpx"
  1473. libx264_encoder_deps="libx264"
  1474. libxavs_encoder_deps="libxavs"
  1475. libxvid_encoder_deps="libxvid"
  1476. # demuxers / muxers
  1477. ac3_demuxer_select="ac3_parser"
  1478. asf_stream_muxer_select="asf_muxer"
  1479. avisynth_demuxer_deps="avisynth"
  1480. dirac_demuxer_select="dirac_parser"
  1481. eac3_demuxer_select="ac3_parser"
  1482. flac_demuxer_select="flac_parser"
  1483. ipod_muxer_select="mov_muxer"
  1484. matroska_audio_muxer_select="matroska_muxer"
  1485. matroska_demuxer_suggest="bzlib lzo zlib"
  1486. mov_demuxer_suggest="zlib"
  1487. mp3_demuxer_select="mpegaudio_parser"
  1488. mp4_muxer_select="mov_muxer"
  1489. mpegts_muxer_select="adts_muxer latm_muxer mpegvideo"
  1490. mpegtsraw_demuxer_select="mpegts_demuxer"
  1491. mxf_d10_muxer_select="mxf_muxer"
  1492. ogg_demuxer_select="golomb"
  1493. psp_muxer_select="mov_muxer"
  1494. rtp_demuxer_select="sdp_demuxer"
  1495. rtp_muxer_select="mpegvideo"
  1496. rtpdec_select="asf_demuxer rm_demuxer rtp_protocol mpegts_demuxer mov_demuxer"
  1497. rtsp_demuxer_select="http_protocol rtpdec"
  1498. rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol"
  1499. sap_demuxer_select="sdp_demuxer"
  1500. sap_muxer_select="rtp_muxer rtp_protocol"
  1501. sdp_demuxer_select="rtpdec"
  1502. smoothstreaming_muxer_select="ismv_muxer"
  1503. spdif_muxer_select="aac_parser"
  1504. tg2_muxer_select="mov_muxer"
  1505. tgp_muxer_select="mov_muxer"
  1506. w64_demuxer_deps="wav_demuxer"
  1507. # indevs / outdevs
  1508. alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
  1509. alsa_outdev_deps="alsa_asoundlib_h"
  1510. bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  1511. dv1394_indev_deps="dv1394 dv_demuxer"
  1512. fbdev_indev_deps="linux_fb_h"
  1513. jack_indev_deps="jack_jack_h"
  1514. libcdio_indev_deps="libcdio"
  1515. libdc1394_indev_deps="libdc1394"
  1516. oss_indev_deps_any="soundcard_h sys_soundcard_h"
  1517. oss_outdev_deps_any="soundcard_h sys_soundcard_h"
  1518. pulse_indev_deps="libpulse"
  1519. sndio_indev_deps="sndio_h"
  1520. sndio_outdev_deps="sndio_h"
  1521. v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
  1522. vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
  1523. vfwcap_indev_extralibs="-lavicap32"
  1524. x11grab_indev_deps="x11grab XShmCreateImage"
  1525. # protocols
  1526. ffrtmpcrypt_protocol_deps="!librtmp_protocol"
  1527. ffrtmpcrypt_protocol_deps_any="gcrypt nettle openssl"
  1528. ffrtmpcrypt_protocol_select="tcp_protocol"
  1529. ffrtmphttp_protocol_deps="!librtmp_protocol"
  1530. ffrtmphttp_protocol_select="http_protocol"
  1531. gopher_protocol_deps="network"
  1532. httpproxy_protocol_deps="network"
  1533. httpproxy_protocol_select="tcp_protocol"
  1534. http_protocol_deps="network"
  1535. http_protocol_select="tcp_protocol"
  1536. https_protocol_select="tls_protocol"
  1537. librtmp_protocol_deps="librtmp"
  1538. librtmpe_protocol_deps="librtmp"
  1539. librtmps_protocol_deps="librtmp"
  1540. librtmpt_protocol_deps="librtmp"
  1541. librtmpte_protocol_deps="librtmp"
  1542. mmsh_protocol_select="http_protocol"
  1543. mmst_protocol_deps="network"
  1544. rtmp_protocol_deps="!librtmp_protocol"
  1545. rtmp_protocol_select="tcp_protocol"
  1546. rtmpe_protocol_select="ffrtmpcrypt_protocol"
  1547. rtmps_protocol_deps="!librtmp_protocol"
  1548. rtmps_protocol_select="tls_protocol"
  1549. rtmpt_protocol_select="ffrtmphttp_protocol"
  1550. rtmpte_protocol_select="ffrtmpcrypt_protocol ffrtmphttp_protocol"
  1551. rtmpts_protocol_select="ffrtmphttp_protocol https_protocol"
  1552. rtp_protocol_select="udp_protocol"
  1553. sctp_protocol_deps="network struct_sctp_event_subscribe"
  1554. tcp_protocol_deps="network"
  1555. tls_protocol_deps_any="openssl gnutls"
  1556. tls_protocol_select="tcp_protocol"
  1557. udp_protocol_deps="network"
  1558. # filters
  1559. blackframe_filter_deps="gpl"
  1560. boxblur_filter_deps="gpl"
  1561. cropdetect_filter_deps="gpl"
  1562. delogo_filter_deps="gpl"
  1563. drawtext_filter_deps="libfreetype"
  1564. frei0r_filter_deps="frei0r dlopen strtok_r"
  1565. frei0r_filter_extralibs='$ldl'
  1566. frei0r_src_filter_deps="frei0r dlopen strtok_r"
  1567. frei0r_src_filter_extralibs='$ldl'
  1568. hqdn3d_filter_deps="gpl"
  1569. resample_filter_deps="avresample"
  1570. ocv_filter_deps="libopencv"
  1571. scale_filter_deps="swscale"
  1572. yadif_filter_deps="gpl"
  1573. # libraries
  1574. avdevice_deps="avcodec avformat"
  1575. avformat_deps="avcodec"
  1576. # programs
  1577. avconv_deps="avcodec avfilter avformat avresample swscale
  1578. aformat_filter asyncts_filter
  1579. format_filter fps_filter scale_filter setpts_filter"
  1580. avplay_deps="avcodec avformat swscale sdl"
  1581. avplay_select="rdft"
  1582. avprobe_deps="avcodec avformat"
  1583. avserver_deps="avformat ffm_muxer fork rtp_protocol rtsp_demuxer !shared"
  1584. avserver_extralibs='$ldl'
  1585. doc_deps="texi2html"
  1586. # default parameters
  1587. logfile="config.log"
  1588. # installation paths
  1589. prefix_default="/usr/local"
  1590. bindir_default='${prefix}/bin'
  1591. datadir_default='${prefix}/share/avconv'
  1592. incdir_default='${prefix}/include'
  1593. libdir_default='${prefix}/lib'
  1594. mandir_default='${prefix}/share/man'
  1595. shlibdir_default="$libdir_default"
  1596. # toolchain
  1597. ar_default="ar"
  1598. cc_default="gcc"
  1599. host_cc_default="gcc"
  1600. cp_f="cp -f"
  1601. ln_s="ln -sf"
  1602. nm_default="nm -g"
  1603. objformat="elf"
  1604. pkg_config_default=pkg-config
  1605. ranlib="ranlib"
  1606. yasmexe="yasm"
  1607. nogas=":"
  1608. # machine
  1609. arch_default=$(uname -m)
  1610. cpu="generic"
  1611. # OS
  1612. target_os_default=$(tolower $(uname -s))
  1613. host_os=$target_os_default
  1614. # configurable options
  1615. enable $PROGRAM_LIST
  1616. enable avcodec
  1617. enable avdevice
  1618. enable avfilter
  1619. enable avformat
  1620. enable avresample
  1621. enable avutil
  1622. enable swscale
  1623. enable asm
  1624. enable debug
  1625. enable doc
  1626. enable network
  1627. enable optimizations
  1628. enable safe_bitstream_reader
  1629. enable static
  1630. enable swscale_alpha
  1631. # build settings
  1632. SHFLAGS='-shared -Wl,-soname,$$(@F)'
  1633. AVSERVERLDFLAGS=-Wl,-E
  1634. LIBPREF="lib"
  1635. LIBSUF=".a"
  1636. FULLNAME='$(NAME)$(BUILDSUF)'
  1637. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  1638. SLIBPREF="lib"
  1639. SLIBSUF=".so"
  1640. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  1641. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  1642. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  1643. LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  1644. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
  1645. SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
  1646. asflags_filter=echo
  1647. cflags_filter=echo
  1648. ldflags_filter=echo
  1649. AS_C='-c'
  1650. AS_O='-o $@'
  1651. CC_C='-c'
  1652. CC_E='-E -o $@'
  1653. CC_O='-o $@'
  1654. LD_O='-o $@'
  1655. LD_LIB='-l%'
  1656. LD_PATH='-L'
  1657. HOSTCC_C='-c'
  1658. HOSTCC_O='-o $@'
  1659. HOSTLD_O='-o $@'
  1660. host_cflags='-D_ISOC99_SOURCE -D_XOPEN_SOURCE=600 -O3 -g'
  1661. host_libs='-lm'
  1662. host_cflags_filter=echo
  1663. host_ldflags_filter=echo
  1664. target_path='$(CURDIR)'
  1665. # since the object filename is not given with the -MM flag, the compiler
  1666. # is only able to print the basename, and we must add the path ourselves
  1667. DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
  1668. DEPFLAGS='-MM'
  1669. # find source path
  1670. if test -f configure; then
  1671. source_path=.
  1672. else
  1673. source_path=$(cd $(dirname "$0"); pwd)
  1674. echo "$source_path" | grep -q '[[:blank:]]' &&
  1675. die "Out of tree builds are impossible with whitespace in source path."
  1676. test -e "$source_path/config.h" &&
  1677. die "Out of tree builds are impossible with config.h in source dir."
  1678. fi
  1679. for v in "$@"; do
  1680. r=${v#*=}
  1681. l=${v%"$r"}
  1682. r=$(sh_quote "$r")
  1683. LIBAV_CONFIGURATION="${LIBAV_CONFIGURATION# } ${l}${r}"
  1684. done
  1685. find_things(){
  1686. thing=$1
  1687. pattern=$2
  1688. file=$source_path/$3
  1689. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  1690. }
  1691. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  1692. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  1693. HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
  1694. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  1695. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  1696. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  1697. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  1698. OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
  1699. INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
  1700. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  1701. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  1702. ALL_COMPONENTS="
  1703. $BSF_LIST
  1704. $DECODER_LIST
  1705. $DEMUXER_LIST
  1706. $ENCODER_LIST
  1707. $FILTER_LIST
  1708. $HWACCEL_LIST
  1709. $INDEV_LIST
  1710. $MUXER_LIST
  1711. $OUTDEV_LIST
  1712. $PARSER_LIST
  1713. $PROTOCOL_LIST
  1714. "
  1715. for n in $COMPONENT_LIST; do
  1716. v=$(toupper ${n%s})_LIST
  1717. eval enable \$$v
  1718. eval ${n}_if_any="\$$v"
  1719. done
  1720. disable snow_decoder snow_encoder
  1721. enable $ARCH_EXT_LIST
  1722. die_unknown(){
  1723. echo "Unknown option \"$1\"."
  1724. echo "See $0 --help for available options."
  1725. exit 1
  1726. }
  1727. show_list() {
  1728. suffix=_$1
  1729. shift
  1730. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
  1731. exit 0
  1732. }
  1733. rand_list(){
  1734. IFS=', '
  1735. set -- $*
  1736. unset IFS
  1737. for thing; do
  1738. comp=${thing%:*}
  1739. prob=${thing#$comp}
  1740. prob=${prob#:}
  1741. is_in ${comp} $COMPONENT_LIST && eval comp=\$$(toupper ${comp%s})_LIST
  1742. echo "prob ${prob:-0.5}"
  1743. printf '%s\n' $comp
  1744. done
  1745. }
  1746. do_random(){
  1747. action=$1
  1748. shift
  1749. random_seed=$(awk "BEGIN { srand($random_seed); print srand() }")
  1750. $action $(rand_list "$@" | awk "BEGIN { srand($random_seed) } \$1 == \"prob\" { prob = \$2; next } rand() < prob { print }")
  1751. }
  1752. for opt do
  1753. optval="${opt#*=}"
  1754. case "$opt" in
  1755. --extra-ldflags=*) add_ldflags $optval
  1756. ;;
  1757. --extra-libs=*) add_extralibs $optval
  1758. ;;
  1759. --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
  1760. ;;
  1761. --enable-debug=*) debuglevel="$optval"
  1762. ;;
  1763. --disable-everything)
  1764. map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
  1765. ;;
  1766. --enable-random|--disable-random)
  1767. action=${opt%%-random}
  1768. do_random ${action#--} $COMPONENT_LIST
  1769. ;;
  1770. --enable-random=*|--disable-random=*)
  1771. action=${opt%%-random=*}
  1772. do_random ${action#--} $optval
  1773. ;;
  1774. --enable-*=*|--disable-*=*)
  1775. eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
  1776. is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
  1777. eval list=\$$(toupper $thing)_LIST
  1778. name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
  1779. $action $(filter "$name" $list)
  1780. ;;
  1781. --enable-?*|--disable-?*)
  1782. eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
  1783. if is_in $option $COMPONENT_LIST; then
  1784. test $action = disable && action=unset
  1785. eval $action \$$(toupper ${option%s})_LIST
  1786. elif is_in $option $CMDLINE_SELECT; then
  1787. $action $option
  1788. else
  1789. die_unknown $opt
  1790. fi
  1791. ;;
  1792. --list-*)
  1793. NAME="${opt#--list-}"
  1794. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  1795. NAME=${NAME%s}
  1796. eval show_list $NAME \$$(toupper $NAME)_LIST
  1797. ;;
  1798. --help|-h) show_help
  1799. ;;
  1800. *)
  1801. optname="${opt%%=*}"
  1802. optname="${optname#--}"
  1803. optname=$(echo "$optname" | sed 's/-/_/g')
  1804. if is_in $optname $CMDLINE_SET; then
  1805. eval $optname='$optval'
  1806. elif is_in $optname $CMDLINE_APPEND; then
  1807. append $optname "$optval"
  1808. else
  1809. die_unknown $opt
  1810. fi
  1811. ;;
  1812. esac
  1813. done
  1814. disabled logging && logfile=/dev/null
  1815. echo "# $0 $LIBAV_CONFIGURATION" > $logfile
  1816. set >> $logfile
  1817. test -n "$cross_prefix" && enable cross_compile
  1818. if enabled cross_compile; then
  1819. test -n "$arch" && test -n "$target_os" ||
  1820. die "Must specify target arch and OS when cross-compiling"
  1821. fi
  1822. ar_default="${cross_prefix}${ar_default}"
  1823. cc_default="${cross_prefix}${cc_default}"
  1824. nm_default="${cross_prefix}${nm_default}"
  1825. pkg_config_default="${cross_prefix}${pkg_config_default}"
  1826. ranlib="${cross_prefix}${ranlib}"
  1827. sysinclude_default="${sysroot}/usr/include"
  1828. case "$toolchain" in
  1829. clang-asan)
  1830. cc_default="clang"
  1831. add_cflags -faddress-sanitizer
  1832. add_ldflags -faddress-sanitizer
  1833. ;;
  1834. clang-tsan)
  1835. cc_default="clang"
  1836. add_cflags -fthread-sanitizer
  1837. add_ldflags -fthread-sanitizer
  1838. ;;
  1839. msvc)
  1840. cc_default="c99wrap cl"
  1841. ld_default="c99wrap link"
  1842. nm_default="dumpbin -symbols"
  1843. ar_default="lib"
  1844. target_os_default="win32"
  1845. ;;
  1846. ?*)
  1847. die "Unknown toolchain $toolchain"
  1848. ;;
  1849. esac
  1850. set_default arch cc pkg_config sysinclude target_os
  1851. enabled cross_compile || host_cc_default=$cc
  1852. set_default host_cc
  1853. if ! $pkg_config --version >/dev/null 2>&1; then
  1854. warn "$pkg_config not found, library detection may fail."
  1855. pkg_config=false
  1856. fi
  1857. exesuf() {
  1858. case $1 in
  1859. mingw32*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
  1860. esac
  1861. }
  1862. EXESUF=$(exesuf $target_os)
  1863. HOSTEXESUF=$(exesuf $host_os)
  1864. # set temporary file name
  1865. : ${TMPDIR:=$TEMPDIR}
  1866. : ${TMPDIR:=$TMP}
  1867. : ${TMPDIR:=/tmp}
  1868. if ! check_cmd mktemp -u XXXXXX; then
  1869. # simple replacement for missing mktemp
  1870. # NOT SAFE FOR GENERAL USE
  1871. mktemp(){
  1872. echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
  1873. }
  1874. fi
  1875. tmpfile(){
  1876. tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
  1877. (set -C; exec > $tmp) 2>/dev/null ||
  1878. die "Unable to create temporary file in $TMPDIR."
  1879. append TMPFILES $tmp
  1880. eval $1=$tmp
  1881. }
  1882. trap 'rm -f -- $TMPFILES' EXIT
  1883. tmpfile TMPASM .asm
  1884. tmpfile TMPC .c
  1885. tmpfile TMPE $EXESUF
  1886. tmpfile TMPH .h
  1887. tmpfile TMPO .o
  1888. tmpfile TMPS .S
  1889. tmpfile TMPSH .sh
  1890. tmpfile TMPV .ver
  1891. unset -f mktemp
  1892. chmod +x $TMPE
  1893. # make sure we can execute files in $TMPDIR
  1894. cat > $TMPSH 2>> $logfile <<EOF
  1895. #! /bin/sh
  1896. EOF
  1897. chmod +x $TMPSH >> $logfile 2>&1
  1898. if ! $TMPSH >> $logfile 2>&1; then
  1899. cat <<EOF
  1900. Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
  1901. variable to another directory and make sure that it is not mounted noexec.
  1902. EOF
  1903. die "Sanity test failed."
  1904. fi
  1905. msvc_flags(){
  1906. for flag; do
  1907. case $flag in
  1908. -fomit-frame-pointer) echo -Oy ;;
  1909. -g) echo -Z7 ;;
  1910. -Wall) echo -W4 -wd4244 -wd4127 -wd4018 -wd4389 \
  1911. -wd4146 -wd4057 -wd4204 -wd4706 -wd4305 \
  1912. -wd4152 -wd4324 -we4013 -wd4100 -wd4214 \
  1913. -wd4996 -wd4273 ;;
  1914. -std=c99) ;;
  1915. -fno-math-errno) ;;
  1916. -fno-common) ;;
  1917. -fno-signed-zeros) ;;
  1918. -lz) echo zlib.lib ;;
  1919. -lavifil32) echo vfw32.lib ;;
  1920. -lavicap32) echo vfw32.lib user32.lib ;;
  1921. -l*) echo ${flag#-l}.lib ;;
  1922. *) echo $flag ;;
  1923. esac
  1924. done
  1925. }
  1926. pgi_flags(){
  1927. for flag; do
  1928. case $flag in
  1929. -flto) echo -Mipa=fast,libopt,libinline,vestigial ;;
  1930. -fomit-frame-pointer) echo -Mnoframe ;;
  1931. -g) echo -gopt ;;
  1932. *) echo $flag ;;
  1933. esac
  1934. done
  1935. }
  1936. suncc_flags(){
  1937. for flag; do
  1938. case $flag in
  1939. -march=*|-mcpu=*)
  1940. case "${flag#*=}" in
  1941. native) echo -xtarget=native ;;
  1942. v9|niagara) echo -xarch=sparc ;;
  1943. ultrasparc) echo -xarch=sparcvis ;;
  1944. ultrasparc3|niagara2) echo -xarch=sparcvis2 ;;
  1945. i586|pentium) echo -xchip=pentium ;;
  1946. i686|pentiumpro|pentium2) echo -xtarget=pentium_pro ;;
  1947. pentium3*|c3-2) echo -xtarget=pentium3 ;;
  1948. pentium-m) echo -xarch=sse2 -xchip=pentium3 ;;
  1949. pentium4*) echo -xtarget=pentium4 ;;
  1950. prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;;
  1951. *-sse3) echo -xarch=sse3 ;;
  1952. core2) echo -xarch=ssse3 -xchip=core2 ;;
  1953. amdfam10|barcelona|bdver*) echo -xarch=sse4_1 ;;
  1954. athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
  1955. k8|opteron|athlon64|athlon-fx)
  1956. echo -xarch=sse2a ;;
  1957. athlon*) echo -xarch=pentium_proa ;;
  1958. esac
  1959. ;;
  1960. -std=c99) echo -xc99 ;;
  1961. -fomit-frame-pointer) echo -xregs=frameptr ;;
  1962. -fPIC) echo -KPIC -xcode=pic32 ;;
  1963. -W*,*) echo $flag ;;
  1964. -f*-*|-W*) ;;
  1965. *) echo $flag ;;
  1966. esac
  1967. done
  1968. }
  1969. tms470_flags(){
  1970. for flag; do
  1971. case $flag in
  1972. -march=*|-mcpu=*)
  1973. case "${flag#*=}" in
  1974. armv7-a|cortex-a*) echo -mv=7a8 ;;
  1975. armv7-r|cortex-r*) echo -mv=7r4 ;;
  1976. armv7-m|cortex-m*) echo -mv=7m3 ;;
  1977. armv6*|arm11*) echo -mv=6 ;;
  1978. armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
  1979. echo -mv=5e ;;
  1980. armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
  1981. esac
  1982. ;;
  1983. -mfpu=neon) echo --float_support=vfpv3 --neon ;;
  1984. -mfpu=vfp) echo --float_support=vfpv2 ;;
  1985. -mfpu=vfpv3) echo --float_support=vfpv3 ;;
  1986. -mfpu=vfpv3-d16) echo --float_support=vfpv3d16 ;;
  1987. -msoft-float) echo --float_support=vfplib ;;
  1988. -O[0-3]|-mf=*) echo $flag ;;
  1989. -g) echo -g -mn ;;
  1990. -pds=*) echo $flag ;;
  1991. -D*|-I*) echo $flag ;;
  1992. --gcc|--abi=*) echo $flag ;;
  1993. -me) echo $flag ;;
  1994. esac
  1995. done
  1996. }
  1997. probe_cc(){
  1998. pfx=$1
  1999. _cc=$2
  2000. unset _type _ident _cc_c _cc_e _cc_o _flags _cflags
  2001. unset _ld_o _ldflags _ld_lib _ld_path
  2002. unset _depflags _DEPCMD _DEPFLAGS
  2003. _flags_filter=echo
  2004. if $_cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
  2005. _type=llvm_gcc
  2006. gcc_extra_ver=$(expr "$($_cc --version | head -n1)" : '.*\((.*)\)')
  2007. _ident="llvm-gcc $($_cc -dumpversion) $gcc_extra_ver"
  2008. _depflags='-MMD -MF $(@:.o=.d) -MT $@'
  2009. _cflags_speed='-O3'
  2010. _cflags_size='-Os'
  2011. elif $_cc -v 2>&1 | grep -qi ^gcc; then
  2012. _type=gcc
  2013. gcc_version=$($_cc --version | head -n1)
  2014. gcc_basever=$($_cc -dumpversion)
  2015. gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
  2016. gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
  2017. _ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
  2018. if ! $_cc -dumpversion | grep -q '^2\.'; then
  2019. _depflags='-MMD -MF $(@:.o=.d) -MT $@'
  2020. fi
  2021. _cflags_speed='-O3'
  2022. _cflags_size='-Os'
  2023. elif $_cc --version 2>/dev/null | grep -q Intel; then
  2024. _type=icc
  2025. _ident=$($_cc --version | head -n1)
  2026. _depflags='-MMD'
  2027. _cflags_speed='-O3'
  2028. _cflags_size='-Os'
  2029. _cflags_noopt='-O1'
  2030. elif $_cc -v 2>&1 | grep -q xlc; then
  2031. _type=xlc
  2032. _ident=$($_cc -qversion 2>/dev/null | head -n1)
  2033. _cflags_speed='-O5'
  2034. _cflags_size='-O5 -qcompact'
  2035. elif $_cc -V 2>/dev/null | grep -q Compaq; then
  2036. _type=ccc
  2037. _ident=$($_cc -V | head -n1 | cut -d' ' -f1-3)
  2038. _DEPFLAGS='-M'
  2039. debuglevel=3
  2040. _ldflags='-Wl,-z,now' # calls to libots crash without this
  2041. _cflags_speed='-fast'
  2042. _cflags_size='-O1'
  2043. elif $_cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
  2044. test -d "$sysroot" || die "No valid sysroot specified."
  2045. _type=armcc
  2046. _ident=$($_cc --vsn | head -n1)
  2047. armcc_conf="$PWD/armcc.conf"
  2048. $_cc --arm_linux_configure \
  2049. --arm_linux_config_file="$armcc_conf" \
  2050. --configure_sysroot="$sysroot" \
  2051. --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
  2052. die "Error creating armcc configuration file."
  2053. $_cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
  2054. _flags="--arm_linux_config_file=$armcc_conf --translate_gcc"
  2055. as_default="${cross_prefix}gcc"
  2056. _depflags='-MMD'
  2057. _cflags_speed='-O3'
  2058. _cflags_size='-Os'
  2059. elif $_cc -version 2>/dev/null | grep -Eq 'TMS470|TI ARM'; then
  2060. _type=tms470
  2061. _ident=$($_cc -version | head -n1 | tr -s ' ')
  2062. _flags='--gcc --abi=eabi -me'
  2063. _cc_e='-ppl -fe=$@'
  2064. _cc_o='-fe=$@'
  2065. _depflags='-ppa -ppd=$(@:.o=.d)'
  2066. _cflags_speed='-O3 -mf=5'
  2067. _cflags_size='-O3 -mf=2'
  2068. _flags_filter=tms470_flags
  2069. elif $_cc -v 2>&1 | grep -q clang; then
  2070. _type=clang
  2071. _ident=$($_cc --version | head -n1)
  2072. _depflags='-MMD'
  2073. _cflags_speed='-O3'
  2074. _cflags_size='-Os'
  2075. elif $_cc -V 2>&1 | grep -q Sun; then
  2076. _type=suncc
  2077. _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
  2078. _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
  2079. _DEPFLAGS='-xM1 -xc99'
  2080. _ldflags='-std=c99'
  2081. _cflags_speed='-O5'
  2082. _cflags_size='-O5 -xspace'
  2083. _flags_filter=suncc_flags
  2084. elif $_cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
  2085. _type=pathscale
  2086. _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
  2087. _depflags='-MMD -MF $(@:.o=.d) -MT $@'
  2088. _cflags_speed='-O2'
  2089. _cflags_size='-Os'
  2090. _flags_filter='filter_out -Wdisabled-optimization'
  2091. elif $_cc -v 2>&1 | grep -q Open64; then
  2092. _type=open64
  2093. _ident=$($_cc -v 2>&1 | head -n1 | tr -d :)
  2094. _depflags='-MMD -MF $(@:.o=.d) -MT $@'
  2095. _cflags_speed='-O2'
  2096. _cflags_size='-Os'
  2097. _flags_filter='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
  2098. elif $_cc -V 2>&1 | grep -q Portland; then
  2099. _type=pgi
  2100. _ident="PGI $($_cc -V 2>&1 | awk '/^pgcc/ { print $2; exit }')"
  2101. opt_common='-alias=ansi -Mdse -Mlre -Mpre'
  2102. _cflags_speed="-O3 -Mautoinline -Munroll=c:4 $opt_common"
  2103. _cflags_size="-O2 -Munroll=c:1 $opt_common"
  2104. _cflags_noopt="-O1"
  2105. _flags_filter=pgi_flags
  2106. elif $_cc 2>&1 | grep -q Microsoft; then
  2107. _type=msvc
  2108. _ident=$($cc 2>&1 | head -n1)
  2109. _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
  2110. _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
  2111. _cflags_speed="-O2"
  2112. _cflags_size="-O1"
  2113. # Nonstandard output options, to avoid msys path conversion issues, relies on wrapper to remap it
  2114. if $_cc 2>&1 | grep -q Linker; then
  2115. _ld_o='-out $@'
  2116. else
  2117. _ld_o='-Fe$@'
  2118. fi
  2119. _cc_o='-Fo $@'
  2120. _cc_e='-P -Fi $@'
  2121. _flags_filter=msvc_flags
  2122. _ld_lib='lib%.a'
  2123. _ld_path='-libpath:'
  2124. _flags='-nologo'
  2125. _cflags='-D_USE_MATH_DEFINES -Dinline=__inline -FIstdlib.h -Dstrtoll=_strtoi64'
  2126. if [ $pfx = hostcc ]; then
  2127. append _cflags -Dsnprintf=_snprintf
  2128. fi
  2129. fi
  2130. eval ${pfx}_type=\$_type
  2131. eval ${pfx}_ident=\$_ident
  2132. }
  2133. set_ccvars(){
  2134. eval ${1}_C=\${_cc_c-\${${1}_C}}
  2135. eval ${1}_E=\${_cc_e-\${${1}_E}}
  2136. eval ${1}_O=\${_cc_o-\${${1}_O}}
  2137. if [ -n "$_depflags" ]; then
  2138. eval ${1}_DEPFLAGS=\$_depflags
  2139. else
  2140. eval ${1}DEP=\${_DEPCMD:-\$DEPCMD}
  2141. eval ${1}DEP_FLAGS=\${_DEPFLAGS:-\$DEPFLAGS}
  2142. eval DEP${1}FLAGS=\$_flags
  2143. fi
  2144. }
  2145. probe_cc cc "$cc"
  2146. cflags_filter=$_flags_filter
  2147. cflags_speed=$_cflags_speed
  2148. cflags_size=$_cflags_size
  2149. cflags_noopt=$_cflags_noopt
  2150. add_cflags $_flags $_cflags
  2151. cc_ldflags=$_ldflags
  2152. set_ccvars CC
  2153. probe_cc hostcc "$host_cc"
  2154. host_cflags_filter=$_flags_filter
  2155. add_host_cflags $_flags $_cflags
  2156. set_ccvars HOSTCC
  2157. test -n "$cc_type" && enable $cc_type ||
  2158. warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
  2159. : ${as_default:=$cc}
  2160. : ${dep_cc_default:=$cc}
  2161. : ${ld_default:=$cc}
  2162. : ${host_ld_default:=$host_cc}
  2163. set_default ar as dep_cc ld host_ld
  2164. probe_cc as "$as"
  2165. asflags_filter=$_flags_filter
  2166. add_asflags $_flags $_cflags
  2167. set_ccvars AS
  2168. probe_cc ld "$ld"
  2169. ldflags_filter=$_flags_filter
  2170. add_ldflags $_flags $_ldflags
  2171. test "$cc_type" != "$ld_type" && add_ldflags $cc_ldflags
  2172. LD_O=${_ld_o-$LD_O}
  2173. LD_LIB=${_ld_lib-$LD_LIB}
  2174. LD_PATH=${_ld_path-$LD_PATH}
  2175. probe_cc hostld "$host_ld"
  2176. host_ldflags_filter=$_flags_filter
  2177. add_host_ldflags $_flags $_ldflags
  2178. HOSTLD_O=${_ld_o-$HOSTLD_O}
  2179. if [ -z "$CC_DEPFLAGS" ] && [ "$dep_cc" != "$cc" ]; then
  2180. probe_cc depcc "$dep_cc"
  2181. CCDEP=${_DEPCMD:-$DEPCMD}
  2182. CCDEP_FLAGS=${_DEPFLAGS:=$DEPFLAGS}
  2183. DEPCCFLAGS=$_flags
  2184. fi
  2185. if $ar 2>&1 | grep -q Microsoft; then
  2186. arflags="-nologo"
  2187. ar_o='-out:$@'
  2188. elif $ar 2>&1 | grep -q 'Texas Instruments'; then
  2189. arflags="rq"
  2190. ar_o='$@'
  2191. else
  2192. arflags="rc"
  2193. ar_o='$@'
  2194. fi
  2195. add_cflags $extra_cflags
  2196. add_asflags $extra_cflags
  2197. if test -n "$sysroot"; then
  2198. case "$cc_type" in
  2199. gcc|llvm_gcc|clang)
  2200. add_cppflags --sysroot="$sysroot"
  2201. add_ldflags --sysroot="$sysroot"
  2202. ;;
  2203. tms470)
  2204. add_cppflags -I"$sysinclude"
  2205. add_ldflags --sysroot="$sysroot"
  2206. ;;
  2207. esac
  2208. fi
  2209. if test "$cpu" = host; then
  2210. enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
  2211. case "$cc_type" in
  2212. gcc|llvm_gcc)
  2213. check_native(){
  2214. $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
  2215. sed -n "/cc1.*$1=/{
  2216. s/.*$1=\\([^ ]*\\).*/\\1/
  2217. p
  2218. q
  2219. }" $TMPE
  2220. }
  2221. cpu=$(check_native -march || check_native -mcpu)
  2222. ;;
  2223. esac
  2224. test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
  2225. fi
  2226. # Deal with common $arch aliases
  2227. case "$arch" in
  2228. arm*)
  2229. arch="arm"
  2230. ;;
  2231. mips*|IP*)
  2232. arch="mips"
  2233. ;;
  2234. parisc*|hppa*)
  2235. arch="parisc"
  2236. ;;
  2237. "Power Macintosh"|ppc*|powerpc*)
  2238. arch="ppc"
  2239. ;;
  2240. s390|s390x)
  2241. arch="s390"
  2242. ;;
  2243. sh4|sh)
  2244. arch="sh4"
  2245. ;;
  2246. sun4u|sparc*)
  2247. arch="sparc"
  2248. ;;
  2249. tilegx|tile-gx)
  2250. arch="tilegx"
  2251. ;;
  2252. i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64)
  2253. arch="x86"
  2254. ;;
  2255. esac
  2256. is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
  2257. enable $arch
  2258. # Add processor-specific flags
  2259. if test "$cpu" = generic; then
  2260. : do nothing
  2261. elif enabled ppc; then
  2262. case $(tolower $cpu) in
  2263. 601|ppc601|powerpc601)
  2264. cpuflags="-mcpu=601"
  2265. disable altivec
  2266. ;;
  2267. 603*|ppc603*|powerpc603*)
  2268. cpuflags="-mcpu=603"
  2269. disable altivec
  2270. ;;
  2271. 604*|ppc604*|powerpc604*)
  2272. cpuflags="-mcpu=604"
  2273. disable altivec
  2274. ;;
  2275. g3|75*|ppc75*|powerpc75*)
  2276. cpuflags="-mcpu=750 -mpowerpc-gfxopt"
  2277. disable altivec
  2278. ;;
  2279. g4|745*|ppc745*|powerpc745*)
  2280. cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
  2281. ;;
  2282. 74*|ppc74*|powerpc74*)
  2283. cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
  2284. ;;
  2285. g5|970|ppc970|powerpc970)
  2286. cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  2287. ;;
  2288. power[3-7]*)
  2289. cpuflags="-mcpu=$cpu -mpowerpc-gfxopt -mpowerpc64"
  2290. ;;
  2291. cell)
  2292. cpuflags="-mcpu=cell"
  2293. enable ldbrx
  2294. ;;
  2295. e500mc)
  2296. cpuflags="-mcpu=e500mc"
  2297. disable altivec
  2298. ;;
  2299. e500v2)
  2300. cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
  2301. disable altivec
  2302. ;;
  2303. e500)
  2304. cpuflags="-mcpu=8540 -mhard-float"
  2305. disable altivec
  2306. ;;
  2307. esac
  2308. elif enabled x86; then
  2309. case $cpu in
  2310. i[345]86|pentium)
  2311. cpuflags="-march=$cpu"
  2312. disable mmx
  2313. ;;
  2314. # targets that do NOT support conditional mov (cmov)
  2315. pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  2316. cpuflags="-march=$cpu"
  2317. disable cmov
  2318. ;;
  2319. # targets that do support conditional mov (cmov)
  2320. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|amdfam10|barcelona|atom|bdver*)
  2321. cpuflags="-march=$cpu"
  2322. enable cmov
  2323. enable fast_cmov
  2324. ;;
  2325. # targets that do support conditional mov but on which it's slow
  2326. pentium4|pentium4m|prescott|nocona)
  2327. cpuflags="-march=$cpu"
  2328. enable cmov
  2329. disable fast_cmov
  2330. ;;
  2331. esac
  2332. elif enabled sparc; then
  2333. case $cpu in
  2334. cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
  2335. cpuflags="-mcpu=$cpu"
  2336. disable vis
  2337. ;;
  2338. ultrasparc*|niagara[234])
  2339. cpuflags="-mcpu=$cpu"
  2340. ;;
  2341. esac
  2342. elif enabled arm; then
  2343. case $cpu in
  2344. armv*)
  2345. cpuflags="-march=$cpu"
  2346. subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
  2347. ;;
  2348. *)
  2349. cpuflags="-mcpu=$cpu"
  2350. case $cpu in
  2351. cortex-a*) subarch=armv7a ;;
  2352. cortex-r*) subarch=armv7r ;;
  2353. cortex-m*) enable thumb; subarch=armv7m ;;
  2354. arm11*) subarch=armv6 ;;
  2355. arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
  2356. armv4*|arm7*|arm9[24]*) subarch=armv4 ;;
  2357. esac
  2358. ;;
  2359. esac
  2360. elif enabled alpha; then
  2361. enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
  2362. elif enabled bfin; then
  2363. cpuflags="-mcpu=$cpu"
  2364. elif enabled mips; then
  2365. cpuflags="-march=$cpu"
  2366. elif enabled avr32; then
  2367. case $cpu in
  2368. ap7[02]0[0-2])
  2369. subarch="avr32_ap"
  2370. cpuflags="-mpart=$cpu"
  2371. ;;
  2372. ap)
  2373. subarch="avr32_ap"
  2374. cpuflags="-march=$cpu"
  2375. ;;
  2376. uc3[ab]*)
  2377. subarch="avr32_uc"
  2378. cpuflags="-mcpu=$cpu"
  2379. ;;
  2380. uc)
  2381. subarch="avr32_uc"
  2382. cpuflags="-march=$cpu"
  2383. ;;
  2384. esac
  2385. fi
  2386. add_cflags $cpuflags
  2387. add_asflags $cpuflags
  2388. # compiler sanity check
  2389. check_exec <<EOF
  2390. int main(void){ return 0; }
  2391. EOF
  2392. if test "$?" != 0; then
  2393. echo "$cc is unable to create an executable file."
  2394. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  2395. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  2396. echo "Only do this if you know what cross compiling means."
  2397. fi
  2398. die "C compiler test failed."
  2399. fi
  2400. add_cppflags -D_ISOC99_SOURCE
  2401. check_cflags -std=c99
  2402. check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
  2403. #include <stdlib.h>
  2404. EOF
  2405. check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
  2406. #include <stdlib.h>
  2407. EOF
  2408. check_host_cflags -std=c99
  2409. check_host_cflags -Wall
  2410. check_64bit(){
  2411. arch32=$1
  2412. arch64=$2
  2413. expr=$3
  2414. check_code cc "" "int test[2*($expr) - 1]" &&
  2415. subarch=$arch64 || subarch=$arch32
  2416. }
  2417. case "$arch" in
  2418. alpha|ia64)
  2419. spic=$shared
  2420. ;;
  2421. mips)
  2422. check_64bit mips mips64 '_MIPS_SIM > 1'
  2423. spic=$shared
  2424. ;;
  2425. parisc)
  2426. check_64bit parisc parisc64 'sizeof(void *) > 4'
  2427. spic=$shared
  2428. ;;
  2429. ppc)
  2430. check_64bit ppc ppc64 'sizeof(void *) > 4'
  2431. ;;
  2432. sparc)
  2433. check_64bit sparc sparc64 'sizeof(void *) > 4'
  2434. spic=$shared
  2435. ;;
  2436. x86)
  2437. check_64bit x86_32 x86_64 'sizeof(void *) > 4'
  2438. if test "$subarch" = "x86_64"; then
  2439. spic=$shared
  2440. fi
  2441. ;;
  2442. esac
  2443. enable $subarch
  2444. enabled spic && enable pic
  2445. # OS specific
  2446. case $target_os in
  2447. haiku)
  2448. prefix_default="/boot/common"
  2449. network_extralibs="-lnetwork"
  2450. host_libs=
  2451. ;;
  2452. sunos)
  2453. AVSERVERLDFLAGS=""
  2454. SHFLAGS='-shared -Wl,-h,$$(@F)'
  2455. enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
  2456. network_extralibs="-lsocket -lnsl"
  2457. add_cppflags -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
  2458. # When using suncc to build, the Solaris linker will mark
  2459. # an executable with each instruction set encountered by
  2460. # the Solaris assembler. As our libraries contain their own
  2461. # guards for processor-specific code, instead suppress
  2462. # generation of the HWCAPS ELF section on Solaris x86 only.
  2463. enabled_all suncc x86 && echo "hwcap_1 = OVERRIDE;" > mapfile && add_ldflags -Wl,-M,mapfile
  2464. nm_default='nm -P -g'
  2465. ;;
  2466. netbsd)
  2467. disable symver
  2468. oss_indev_extralibs="-lossaudio"
  2469. oss_outdev_extralibs="-lossaudio"
  2470. ;;
  2471. openbsd|bitrig)
  2472. # On OpenBSD 4.5. the compiler does not use PIC unless
  2473. # explicitly using -fPIC. Libav builds fine without PIC,
  2474. # however the generated executable will not do anything
  2475. # (simply quits with exit-code 1, no crash, no output).
  2476. # Thus explicitly enable PIC here.
  2477. enable pic
  2478. disable symver
  2479. SHFLAGS='-shared'
  2480. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBVERSION)'
  2481. SLIB_INSTALL_LINKS=
  2482. oss_indev_extralibs="-lossaudio"
  2483. oss_outdev_extralibs="-lossaudio"
  2484. ;;
  2485. dragonfly)
  2486. disable symver
  2487. ;;
  2488. freebsd)
  2489. ;;
  2490. bsd/os)
  2491. add_extralibs -lpoll -lgnugetopt
  2492. ;;
  2493. darwin)
  2494. gas="gas-preprocessor.pl $cc"
  2495. enabled ppc && add_asflags -force_cpusubtype_ALL
  2496. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
  2497. enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
  2498. add_ldflags -Wl,-dynamic,-search_paths_first
  2499. SLIBSUF=".dylib"
  2500. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  2501. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  2502. AVSERVERLDFLAGS=-Wl,-bind_at_load
  2503. objformat="macho"
  2504. enabled x86_64 && objformat="macho64"
  2505. enabled_any pic shared ||
  2506. { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
  2507. ;;
  2508. mingw32*)
  2509. if test $target_os = "mingw32ce"; then
  2510. disable network
  2511. else
  2512. target_os=mingw32
  2513. fi
  2514. LIBTARGET=i386
  2515. if enabled x86_64; then
  2516. LIBTARGET="i386:x86-64"
  2517. elif enabled arm; then
  2518. LIBTARGET=arm-wince
  2519. fi
  2520. shlibdir_default="$bindir_default"
  2521. SLIBPREF=""
  2522. SLIBSUF=".dll"
  2523. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2524. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2525. SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
  2526. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
  2527. SLIB_INSTALL_LINKS=
  2528. SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
  2529. SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
  2530. SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
  2531. objformat="win32"
  2532. dlltool="${cross_prefix}dlltool"
  2533. ranlib=:
  2534. enable dos_paths
  2535. add_cppflags -U__STRICT_ANSI__
  2536. ;;
  2537. win32|win64)
  2538. if enabled shared; then
  2539. # Link to the import library instead of the normal static library
  2540. # for shared libs.
  2541. LD_LIB='%.lib'
  2542. # Cannot build shared and static libraries at the same time with
  2543. # MSVC.
  2544. disable static
  2545. fi
  2546. shlibdir_default="$bindir_default"
  2547. SLIBPREF=""
  2548. SLIBSUF=".dll"
  2549. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2550. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2551. SLIB_CREATE_DEF_CMD='makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
  2552. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
  2553. SLIB_INSTALL_LINKS=
  2554. SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
  2555. SLIB_INSTALL_EXTRA_LIB='$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
  2556. SHFLAGS='-dll -def:$$(@:$(SLIBSUF)=.def) -implib:$(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib)'
  2557. objformat="win32"
  2558. ranlib=:
  2559. enable dos_paths
  2560. ;;
  2561. cygwin*)
  2562. target_os=cygwin
  2563. shlibdir_default="$bindir_default"
  2564. SLIBPREF="cyg"
  2565. SLIBSUF=".dll"
  2566. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2567. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2568. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
  2569. SLIB_INSTALL_LINKS=
  2570. SLIB_INSTALL_EXTRA_LIB='lib$(FULLNAME).dll.a'
  2571. SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(FULLNAME).dll.a'
  2572. objformat="win32"
  2573. enable dos_paths
  2574. add_cppflags -U__STRICT_ANSI__
  2575. ;;
  2576. *-dos|freedos|opendos)
  2577. network_extralibs="-lsocket"
  2578. objformat="coff"
  2579. enable dos_paths
  2580. add_cppflags -U__STRICT_ANSI__
  2581. ;;
  2582. linux)
  2583. add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
  2584. enable dv1394
  2585. ;;
  2586. irix*)
  2587. target_os=irix
  2588. ranlib="echo ignoring ranlib"
  2589. ;;
  2590. os/2*)
  2591. ln_s="cp -f"
  2592. objformat="aout"
  2593. add_cppflags -D_GNU_SOURCE
  2594. add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
  2595. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  2596. AVSERVERLDFLAGS=""
  2597. LIBSUF="_s.a"
  2598. SLIBPREF=""
  2599. SLIBSUF=".dll"
  2600. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  2601. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  2602. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  2603. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  2604. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  2605. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  2606. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  2607. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  2608. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  2609. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  2610. SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
  2611. enable dos_paths
  2612. ;;
  2613. gnu/kfreebsd)
  2614. add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
  2615. ;;
  2616. gnu)
  2617. add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
  2618. ;;
  2619. qnx)
  2620. add_cppflags -D_QNX_SOURCE
  2621. network_extralibs="-lsocket"
  2622. ;;
  2623. symbian)
  2624. SLIBSUF=".dll"
  2625. enable dos_paths
  2626. add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
  2627. add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
  2628. add_ldflags -Wl,--target1-abs,--no-undefined \
  2629. -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
  2630. -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
  2631. add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
  2632. -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
  2633. -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
  2634. ;;
  2635. osf1)
  2636. add_cppflags -D_OSF_SOURCE -D_POSIX_PII -D_REENTRANT
  2637. AVSERVERLDFLAGS=
  2638. ;;
  2639. minix)
  2640. ;;
  2641. plan9)
  2642. add_cppflags -D_C99_SNPRINTF_EXTENSION \
  2643. -D_REENTRANT_SOURCE \
  2644. -D_RESEARCH_SOURCE \
  2645. -DFD_SETSIZE=96 \
  2646. -DHAVE_SOCK_OPTS
  2647. add_compat strtod.o strtod=avpriv_strtod
  2648. network_extralibs='-lbsd'
  2649. exeobjs=compat/plan9/main.o
  2650. disable avserver
  2651. ln_s='ln -s -f'
  2652. cp_f='cp'
  2653. ;;
  2654. none)
  2655. ;;
  2656. *)
  2657. die "Unknown OS '$target_os'."
  2658. ;;
  2659. esac
  2660. # determine libc flavour
  2661. if check_cpp_condition features.h "defined __UCLIBC__"; then
  2662. libc_type=uclibc
  2663. elif check_cpp_condition features.h "defined __GLIBC__"; then
  2664. libc_type=glibc
  2665. elif check_header _mingw.h; then
  2666. libc_type=mingw
  2667. check_cpp_condition _mingw.h \
  2668. "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) || \
  2669. (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
  2670. die "ERROR: MinGW runtime version must be >= 3.15."
  2671. elif check_cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
  2672. libc_type=newlib
  2673. elif check_func_headers stdlib.h _get_doserrno; then
  2674. libc_type=msvcrt
  2675. add_compat strtod.o strtod=avpriv_strtod
  2676. add_compat msvcrt/snprintf.o snprintf=avpriv_snprintf \
  2677. _snprintf=avpriv_snprintf \
  2678. vsnprintf=avpriv_vsnprintf
  2679. elif check_cpp_condition stddef.h "defined __KLIBC__"; then
  2680. libc_type=klibc
  2681. fi
  2682. test -n "$libc_type" && enable $libc_type
  2683. # hacks for compiler/libc/os combinations
  2684. if enabled_all tms470 glibc; then
  2685. CPPFLAGS="-I${source_path}/compat/tms470 ${CPPFLAGS}"
  2686. add_cppflags -D__USER_LABEL_PREFIX__=
  2687. add_cppflags -D__builtin_memset=memset
  2688. add_cppflags -D__gnuc_va_list=va_list -D_VA_LIST_DEFINED
  2689. add_cflags -pds=48 # incompatible redefinition of macro
  2690. fi
  2691. esc(){
  2692. echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
  2693. }
  2694. echo "config:$arch:$subarch:$cpu:$target_os:$(esc $cc_ident):$(esc $LIBAV_CONFIGURATION)" >config.fate
  2695. check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
  2696. set_default $PATHS_LIST
  2697. set_default nm
  2698. # we need to build at least one lib type
  2699. if ! enabled_any static shared; then
  2700. cat <<EOF
  2701. At least one library type must be built.
  2702. Specify --enable-static to build the static libraries or --enable-shared to
  2703. build the shared libraries as well. To only build the shared libraries specify
  2704. --disable-static in addition to --enable-shared.
  2705. EOF
  2706. exit 1;
  2707. fi
  2708. die_license_disabled() {
  2709. enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
  2710. }
  2711. die_license_disabled gpl libcdio
  2712. die_license_disabled gpl libx264
  2713. die_license_disabled gpl libxavs
  2714. die_license_disabled gpl libxvid
  2715. die_license_disabled gpl x11grab
  2716. die_license_disabled nonfree libfaac
  2717. die_license_disabled nonfree libfdk_aac
  2718. die_license_disabled nonfree openssl
  2719. die_license_disabled version3 libopencore_amrnb
  2720. die_license_disabled version3 libopencore_amrwb
  2721. die_license_disabled version3 libvo_aacenc
  2722. die_license_disabled version3 libvo_amrwbenc
  2723. enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
  2724. disabled optimizations || check_cflags -fomit-frame-pointer
  2725. enable_pic() {
  2726. enable pic
  2727. add_cppflags -DPIC
  2728. add_cflags -fPIC
  2729. add_asflags -fPIC
  2730. }
  2731. enabled pic && enable_pic
  2732. check_cc <<EOF || die "Symbol mangling check failed."
  2733. int ff_extern;
  2734. EOF
  2735. sym=$($nm $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
  2736. extern_prefix=${sym%%ff_extern*}
  2737. check_cc <<EOF && enable_weak inline_asm
  2738. void foo(void) { __asm__ volatile ("" ::); }
  2739. EOF
  2740. _restrict=
  2741. for restrict_keyword in restrict __restrict__ __restrict; do
  2742. check_cc <<EOF && _restrict=$restrict_keyword && break
  2743. void foo(char * $restrict_keyword p);
  2744. EOF
  2745. done
  2746. check_cc <<EOF && enable attribute_packed
  2747. struct { int x; } __attribute__((packed)) x;
  2748. EOF
  2749. check_cc <<EOF && enable attribute_may_alias
  2750. union { int x; } __attribute__((may_alias)) x;
  2751. EOF
  2752. check_cc <<EOF || die "endian test failed"
  2753. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  2754. EOF
  2755. od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  2756. if enabled alpha; then
  2757. check_cflags -mieee
  2758. elif enabled arm; then
  2759. enabled thumb && check_cflags -mthumb || check_cflags -marm
  2760. nogas=die
  2761. if check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
  2762. enable vfp_args
  2763. elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then
  2764. case "${cross_prefix:-$cc}" in
  2765. *hardfloat*) enable vfp_args; fpabi=vfp ;;
  2766. *) check_ld <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
  2767. __asm__ (".eabi_attribute 28, 1");
  2768. int main(void) { return 0; }
  2769. EOF
  2770. esac
  2771. warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
  2772. fi
  2773. enabled armv5te && check_inline_asm armv5te '"qadd r0, r0, r0"'
  2774. enabled armv6 && check_inline_asm armv6 '"sadd16 r0, r0, r0"'
  2775. enabled armv6t2 && check_inline_asm armv6t2 '"movt r0, #0"'
  2776. enabled armvfp && check_inline_asm armvfp '"fadds s0, s0, s0"'
  2777. enabled neon && check_inline_asm neon '"vadd.i16 q0, q0, q0"'
  2778. enabled vfpv3 && check_inline_asm vfpv3 '"vmov.f32 s0, #1.0"'
  2779. check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
  2780. check_inline_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)'
  2781. enabled_all armv6t2 shared !pic && enable_pic
  2782. elif enabled mips; then
  2783. check_inline_asm loongson '"dmult.g $1, $2, $3"'
  2784. elif enabled ppc; then
  2785. enable local_aligned_8 local_aligned_16
  2786. check_inline_asm dcbzl '"dcbzl 0, %0" :: "r"(0)'
  2787. check_inline_asm ibm_asm '"add 0, 0, 0"'
  2788. check_inline_asm ppc4xx '"maclhw r10, r11, r12"'
  2789. check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
  2790. # AltiVec flags: The FSF version of GCC differs from the Apple version
  2791. if enabled altivec; then
  2792. nogas=warn
  2793. check_cflags -maltivec -mabi=altivec &&
  2794. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  2795. check_cflags -faltivec
  2796. # check if our compiler supports Motorola AltiVec C API
  2797. check_cc <<EOF || disable altivec
  2798. $inc_altivec_h
  2799. int main(void) {
  2800. vector signed int v1 = (vector signed int) { 0 };
  2801. vector signed int v2 = (vector signed int) { 1 };
  2802. v1 = vec_add(v1, v2);
  2803. return 0;
  2804. }
  2805. EOF
  2806. enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
  2807. fi
  2808. elif enabled sparc; then
  2809. enabled vis && check_inline_asm vis '"pdist %f0, %f0, %f0"'
  2810. elif enabled x86; then
  2811. check_code ld intrin.h "__rdtsc()" && enable rdtsc
  2812. check_code ld mmintrin.h "_mm_empty()" && enable mm_empty
  2813. enable local_aligned_8 local_aligned_16
  2814. # check whether EBP is available on x86
  2815. # As 'i' is stored on the stack, this program will crash
  2816. # if the base pointer is used to access it because the
  2817. # base pointer is cleared in the inline assembly code.
  2818. check_exec_crash <<EOF && enable ebp_available
  2819. volatile int i=0;
  2820. __asm__ volatile ("xorl %%ebp, %%ebp" ::: "%ebp");
  2821. return i;
  2822. EOF
  2823. # check whether EBX is available on x86
  2824. check_inline_asm ebx_available '""::"b"(0)' &&
  2825. check_inline_asm ebx_available '"":::"%ebx"'
  2826. # check whether xmm clobbers are supported
  2827. check_inline_asm xmm_clobbers '"":::"%xmm0"'
  2828. # check whether binutils is new enough to compile SSSE3/MMXEXT
  2829. enabled ssse3 && check_inline_asm ssse3_inline '"pabsw %xmm0, %xmm0"'
  2830. enabled mmxext && check_inline_asm mmxext_inline '"pmaxub %mm0, %mm1"'
  2831. if ! disabled_any asm mmx yasm; then
  2832. if check_cmd $yasmexe --version; then
  2833. enabled x86_64 && yasm_extra="-m amd64"
  2834. yasm_debug="-g dwarf2"
  2835. elif check_cmd nasm -v; then
  2836. yasmexe=nasm
  2837. yasm_debug="-g -F dwarf"
  2838. enabled x86_64 && test "$objformat" = elf && objformat=elf64
  2839. fi
  2840. YASMFLAGS="-f $objformat $yasm_extra"
  2841. enabled pic && append YASMFLAGS "-DPIC"
  2842. test -n "$extern_prefix" && append YASMFLAGS "-DPREFIX"
  2843. case "$objformat" in
  2844. elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
  2845. esac
  2846. check_yasm "vextractf128 xmm0, ymm0, 0" && enable yasm ||
  2847. die "yasm not found, use --disable-yasm for a crippled build"
  2848. check_yasm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
  2849. check_yasm "CPU amdnop" && enable cpunop
  2850. fi
  2851. case "$cpu" in
  2852. athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
  2853. disable fast_clz
  2854. ;;
  2855. esac
  2856. fi
  2857. if enabled asm; then
  2858. as=${gas:=$as}
  2859. check_inline_asm gnu_as '".macro m n\n\\n:.int 0\n.endm\nm x"' ||
  2860. $nogas "GNU assembler not found, install gas-preprocessor"
  2861. fi
  2862. check_ldflags -Wl,--as-needed
  2863. if check_func dlopen; then
  2864. ldl=
  2865. elif check_func dlopen -ldl; then
  2866. ldl=-ldl
  2867. fi
  2868. if enabled network; then
  2869. check_type "sys/types.h sys/socket.h" socklen_t
  2870. check_type netdb.h "struct addrinfo"
  2871. check_type netinet/in.h "struct group_source_req" -D_BSD_SOURCE
  2872. check_type netinet/in.h "struct ip_mreq_source" -D_BSD_SOURCE
  2873. check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
  2874. check_type netinet/in.h "struct sockaddr_in6"
  2875. check_type poll.h "struct pollfd"
  2876. check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
  2877. check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
  2878. check_type netinet/sctp.h "struct sctp_event_subscribe"
  2879. check_func getaddrinfo $network_extralibs
  2880. check_func getservbyport $network_extralibs
  2881. # Prefer arpa/inet.h over winsock2
  2882. if check_header arpa/inet.h ; then
  2883. check_func closesocket
  2884. elif check_header winsock2.h ; then
  2885. check_func_headers winsock2.h closesocket -lws2 &&
  2886. network_extralibs="-lws2" ||
  2887. { check_func_headers winsock2.h closesocket -lws2_32 &&
  2888. network_extralibs="-lws2_32"; }
  2889. check_func_headers ws2tcpip.h getaddrinfo $network_extralibs
  2890. check_type ws2tcpip.h socklen_t
  2891. check_type ws2tcpip.h "struct addrinfo"
  2892. check_type ws2tcpip.h "struct group_source_req"
  2893. check_type ws2tcpip.h "struct ip_mreq_source"
  2894. check_type ws2tcpip.h "struct ipv6_mreq"
  2895. check_type winsock2.h "struct pollfd"
  2896. check_type ws2tcpip.h "struct sockaddr_in6"
  2897. check_type ws2tcpip.h "struct sockaddr_storage"
  2898. check_struct winsock2.h "struct sockaddr" sa_len
  2899. else
  2900. disable network
  2901. fi
  2902. fi
  2903. # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
  2904. check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
  2905. check_func fcntl
  2906. check_func fork
  2907. check_func gethrtime
  2908. check_func getopt
  2909. check_func getrusage
  2910. check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
  2911. check_func gettimeofday
  2912. check_func inet_aton $network_extralibs
  2913. check_func isatty
  2914. check_func localtime_r
  2915. check_func ${malloc_prefix}memalign && enable memalign
  2916. check_func mkstemp
  2917. check_func mmap
  2918. check_func mprotect
  2919. check_func ${malloc_prefix}posix_memalign && enable posix_memalign
  2920. check_func_headers malloc.h _aligned_malloc && enable aligned_malloc
  2921. check_func setrlimit
  2922. check_func strerror_r
  2923. check_func strptime
  2924. check_func strtok_r
  2925. check_func sched_getaffinity
  2926. check_func sysconf
  2927. check_func sysctl
  2928. check_func usleep
  2929. check_func_headers io.h setmode
  2930. check_lib2 "windows.h shellapi.h" CommandLineToArgvW -lshell32
  2931. check_lib2 "windows.h wincrypt.h" CryptGenRandom -ladvapi32
  2932. check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
  2933. check_func_headers windows.h GetProcessAffinityMask
  2934. check_func_headers windows.h GetProcessTimes
  2935. check_func_headers windows.h GetSystemTimeAsFileTime
  2936. check_func_headers windows.h MapViewOfFile
  2937. check_func_headers windows.h Sleep
  2938. check_func_headers windows.h VirtualAlloc
  2939. check_header direct.h
  2940. check_header dlfcn.h
  2941. check_header dxva.h
  2942. check_header dxva2api.h
  2943. check_header io.h
  2944. check_header malloc.h
  2945. check_header poll.h
  2946. check_header sys/mman.h
  2947. check_header sys/param.h
  2948. check_header sys/resource.h
  2949. check_header sys/select.h
  2950. check_header sys/time.h
  2951. check_header unistd.h
  2952. check_header vdpau/vdpau.h
  2953. check_header vdpau/vdpau_x11.h
  2954. check_header windows.h
  2955. check_header X11/extensions/XvMClib.h
  2956. disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
  2957. disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  2958. if ! disabled w32threads && ! enabled pthreads; then
  2959. check_func _beginthreadex && enable w32threads
  2960. fi
  2961. # check for some common methods of building with pthread support
  2962. # do this before the optional library checks as some of them require pthreads
  2963. if ! disabled pthreads && ! enabled w32threads; then
  2964. enable pthreads
  2965. if check_func pthread_create; then
  2966. :
  2967. elif check_func pthread_create -pthread; then
  2968. add_cflags -pthread
  2969. add_extralibs -pthread
  2970. elif check_func pthread_create -pthreads; then
  2971. add_cflags -pthreads
  2972. add_extralibs -pthreads
  2973. elif check_func pthread_create -lpthreadGC2; then
  2974. add_extralibs -lpthreadGC2
  2975. elif ! check_lib pthread.h pthread_create -lpthread; then
  2976. disable pthreads
  2977. fi
  2978. fi
  2979. for thread in $THREADS_LIST; do
  2980. if enabled $thread; then
  2981. test -n "$thread_type" &&
  2982. die "ERROR: Only one thread type must be selected." ||
  2983. thread_type="$thread"
  2984. fi
  2985. done
  2986. check_lib math.h sin -lm && LIBM="-lm"
  2987. enabled vaapi && require vaapi va/va.h vaInitialize -lva
  2988. atan2f_args=2
  2989. ldexpf_args=2
  2990. powf_args=2
  2991. for func in $MATH_FUNCS; do
  2992. eval check_mathfunc $func \${${func}_args:-1}
  2993. done
  2994. # these are off by default, so fail if requested and not available
  2995. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
  2996. enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
  2997. enabled gnutls && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
  2998. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  2999. enabled libfdk_aac && require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac
  3000. enabled libfreetype && require_pkg_config freetype2 "ft2build.h freetype/freetype.h" FT_Init_FreeType
  3001. enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
  3002. enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
  3003. enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
  3004. enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
  3005. enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
  3006. enabled libopencv && require_pkg_config opencv opencv/cv.h cvCreateImageHeader
  3007. enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
  3008. enabled libopus && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
  3009. enabled libpulse && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new
  3010. enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
  3011. enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
  3012. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  3013. enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
  3014. enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
  3015. enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
  3016. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  3017. enabled libvpx && {
  3018. enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
  3019. die "ERROR: libvpx decoder version must be >=0.9.1"; }
  3020. enabled libvpx_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VPX_CQ" -lvpx ||
  3021. die "ERROR: libvpx encoder version must be >=0.9.6"; } }
  3022. enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
  3023. { check_cpp_condition x264.h "X264_BUILD >= 118" ||
  3024. die "ERROR: libx264 version must be >= 0.118."; }
  3025. enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs
  3026. enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
  3027. enabled openssl && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
  3028. check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
  3029. check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
  3030. die "ERROR: openssl not found"; }
  3031. if enabled gnutls; then
  3032. { check_lib nettle/bignum.h nettle_mpz_get_str_256 -lnettle -lhogweed -lgmp && enable nettle; } ||
  3033. { check_lib gcrypt.h gcry_mpi_new -lgcrypt && enable gcrypt; }
  3034. fi
  3035. # libdc1394 check
  3036. if enabled libdc1394; then
  3037. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  3038. enable libdc1394_2; } ||
  3039. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  3040. enable libdc1394_1; } ||
  3041. die "ERROR: No version of libdc1394 found "
  3042. fi
  3043. if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
  3044. check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
  3045. enable sdl &&
  3046. check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
  3047. fi
  3048. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  3049. check_header linux/fb.h
  3050. check_header linux/videodev2.h
  3051. check_struct linux/videodev2.h "struct v4l2_frmivalenum" discrete
  3052. check_header sys/videoio.h
  3053. check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
  3054. # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
  3055. # w32api 3.12 had it defined wrong
  3056. check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
  3057. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  3058. { check_header dev/bktr/ioctl_meteor.h &&
  3059. check_header dev/bktr/ioctl_bt848.h; } ||
  3060. { check_header machine/ioctl_meteor.h &&
  3061. check_header machine/ioctl_bt848.h; } ||
  3062. { check_header dev/video/meteor/ioctl_meteor.h &&
  3063. check_header dev/video/bktr/ioctl_bt848.h; } ||
  3064. check_header dev/ic/bt8xx.h
  3065. check_header sndio.h
  3066. check_header sys/soundcard.h
  3067. check_header soundcard.h
  3068. enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
  3069. enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack &&
  3070. check_func jack_port_get_latency_range -ljack
  3071. enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
  3072. enabled libcdio &&
  3073. check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio
  3074. enabled x11grab &&
  3075. require X11 X11/Xlib.h XOpenDisplay -lX11 &&
  3076. require Xext X11/extensions/XShm.h XShmCreateImage -lXext &&
  3077. require Xfixes X11/extensions/Xfixes.h XFixesGetCursorImage -lXfixes
  3078. # check for VDA header
  3079. if ! disabled vda && check_header VideoDecodeAcceleration/VDADecoder.h; then
  3080. enable vda && add_extralibs -framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore
  3081. fi
  3082. if ! disabled vdpau && enabled vdpau_vdpau_h; then
  3083. check_cpp_condition vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
  3084. { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." && disable vdpau; }
  3085. fi
  3086. enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
  3087. # add some useful compiler flags if supported
  3088. check_cflags -Wdeclaration-after-statement
  3089. check_cflags -Wall
  3090. check_cflags -Wno-parentheses
  3091. check_cflags -Wno-switch
  3092. check_cflags -Wno-format-zero-length
  3093. check_cflags -Wdisabled-optimization
  3094. check_cflags -Wpointer-arith
  3095. check_cflags -Wredundant-decls
  3096. check_cflags -Wno-pointer-sign
  3097. check_cflags -Wcast-qual
  3098. check_cflags -Wwrite-strings
  3099. check_cflags -Wtype-limits
  3100. check_cflags -Wundef
  3101. check_cflags -Wmissing-prototypes
  3102. check_cflags -Wstrict-prototypes
  3103. enabled extra_warnings && check_cflags -Winline
  3104. # add some linker flags
  3105. check_ldflags -Wl,--warn-common
  3106. check_ldflags -Wl,-rpath-link=libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil:libavresample
  3107. test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
  3108. enabled xmm_clobber_test &&
  3109. check_ldflags -Wl,--wrap,avcodec_open2 \
  3110. -Wl,--wrap,avcodec_decode_audio4 \
  3111. -Wl,--wrap,avcodec_decode_video2 \
  3112. -Wl,--wrap,avcodec_decode_subtitle2 \
  3113. -Wl,--wrap,avcodec_encode_audio2 \
  3114. -Wl,--wrap,avcodec_encode_video \
  3115. -Wl,--wrap,avcodec_encode_subtitle \
  3116. -Wl,--wrap,sws_scale ||
  3117. disable xmm_clobber_test
  3118. echo "X{};" > $TMPV
  3119. if test_ldflags -Wl,--version-script,$TMPV; then
  3120. append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
  3121. check_cc <<EOF && enable symver_asm_label
  3122. void ff_foo(void) __asm__ ("av_foo@VERSION");
  3123. void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
  3124. EOF
  3125. check_cc <<EOF && enable symver_gnu_asm
  3126. __asm__(".symver ff_foo,av_foo@VERSION");
  3127. void ff_foo(void) {}
  3128. EOF
  3129. fi
  3130. if [ -z "$optflags" ]; then
  3131. if enabled small; then
  3132. optflags=$cflags_size
  3133. elif enabled optimizations; then
  3134. optflags=$cflags_speed
  3135. else
  3136. optflags=$cflags_noopt
  3137. fi
  3138. fi
  3139. check_optflags(){
  3140. check_cflags "$@"
  3141. enabled lto && check_ldflags "$@"
  3142. }
  3143. if enabled lto; then
  3144. test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker"
  3145. check_cflags -flto
  3146. check_ldflags -flto $cpuflags
  3147. fi
  3148. check_optflags $optflags
  3149. check_optflags -fno-math-errno
  3150. check_optflags -fno-signed-zeros
  3151. if enabled icc; then
  3152. # Just warnings, no remarks
  3153. check_cflags -w1
  3154. # -wd: Disable following warnings
  3155. # 144, 167, 556: -Wno-pointer-sign
  3156. # 1292: attribute "foo" ignored
  3157. # 1419: external declaration in primary source file
  3158. # 10006: ignoring unknown option -fno-signed-zeros
  3159. # 10148: ignoring unknown option -Wno-parentheses
  3160. # 10156: ignoring option '-W'; no argument required
  3161. check_cflags -wd144,167,556,1292,1419,10006,10148,10156
  3162. # 11030: Warning unknown option --as-needed
  3163. # 10156: ignoring option '-export'; no argument required
  3164. check_ldflags -wd10156,11030
  3165. # Allow to compile with optimizations
  3166. check_ldflags -march=$cpu
  3167. # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
  3168. enable ebp_available
  3169. if enabled x86_32; then
  3170. icc_version=$($cc -dumpversion)
  3171. test ${icc_version%%.*} -ge 11 &&
  3172. check_cflags -falign-stack=maintain-16-byte ||
  3173. disable aligned_stack
  3174. fi
  3175. elif enabled ccc; then
  3176. # disable some annoying warnings
  3177. add_cflags -msg_disable cvtu32to64
  3178. add_cflags -msg_disable embedcomment
  3179. add_cflags -msg_disable needconstext
  3180. add_cflags -msg_disable nomainieee
  3181. add_cflags -msg_disable ptrmismatch1
  3182. add_cflags -msg_disable unreachcode
  3183. elif enabled gcc; then
  3184. check_optflags -fno-tree-vectorize
  3185. check_cflags -Werror=implicit-function-declaration
  3186. check_cflags -Werror=missing-prototypes
  3187. check_cflags -Werror=declaration-after-statement
  3188. check_cflags -Werror=vla
  3189. elif enabled llvm_gcc; then
  3190. check_cflags -mllvm -stack-alignment=16
  3191. elif enabled clang; then
  3192. check_cflags -mllvm -stack-alignment=16
  3193. check_cflags -Qunused-arguments
  3194. elif enabled armcc; then
  3195. # 2523: use of inline assembler is deprecated
  3196. add_cflags -W${armcc_opt},--diag_suppress=2523
  3197. add_cflags -W${armcc_opt},--diag_suppress=1207
  3198. add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
  3199. add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
  3200. add_cflags -W${armcc_opt},--diag_suppress=167 # pointer sign
  3201. add_cflags -W${armcc_opt},--diag_suppress=513 # pointer sign
  3202. elif enabled tms470; then
  3203. add_cflags -pds=824 -pds=837
  3204. elif enabled pathscale; then
  3205. add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
  3206. elif enabled msvc; then
  3207. enabled x86_32 && disable aligned_stack
  3208. fi
  3209. case $target_os in
  3210. plan9)
  3211. add_cppflags -Dmain=plan9_main
  3212. ;;
  3213. esac
  3214. enabled_any $THREADS_LIST && enable threads
  3215. enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
  3216. check_deps $CONFIG_LIST \
  3217. $CONFIG_EXTRA \
  3218. $HAVE_LIST \
  3219. $ALL_COMPONENTS \
  3220. ! enabled_any memalign posix_memalign aligned_malloc &&
  3221. enabled_any $need_memalign && enable memalign_hack
  3222. echo "install prefix $prefix"
  3223. echo "source path $source_path"
  3224. echo "C compiler $cc"
  3225. echo "ARCH $arch ($cpu)"
  3226. if test "$build_suffix" != ""; then
  3227. echo "build suffix $build_suffix"
  3228. fi
  3229. if test "$extra_version" != ""; then
  3230. echo "version string suffix $extra_version"
  3231. fi
  3232. echo "big-endian ${bigendian-no}"
  3233. echo "runtime cpu detection ${runtime_cpudetect-no}"
  3234. if enabled x86; then
  3235. echo "${yasmexe} ${yasm-no}"
  3236. echo "MMX enabled ${mmx-no}"
  3237. echo "MMXEXT enabled ${mmxext-no}"
  3238. echo "3DNow! enabled ${amd3dnow-no}"
  3239. echo "3DNow! extended enabled ${amd3dnowext-no}"
  3240. echo "SSE enabled ${sse-no}"
  3241. echo "SSSE3 enabled ${ssse3-no}"
  3242. echo "AVX enabled ${avx-no}"
  3243. echo "FMA4 enabled ${fma4-no}"
  3244. echo "CMOV enabled ${cmov-no}"
  3245. echo "CMOV is fast ${fast_cmov-no}"
  3246. echo "EBX available ${ebx_available-no}"
  3247. echo "EBP available ${ebp_available-no}"
  3248. fi
  3249. if enabled arm; then
  3250. echo "ARMv5TE enabled ${armv5te-no}"
  3251. echo "ARMv6 enabled ${armv6-no}"
  3252. echo "ARMv6T2 enabled ${armv6t2-no}"
  3253. echo "ARM VFP enabled ${armvfp-no}"
  3254. echo "NEON enabled ${neon-no}"
  3255. fi
  3256. if enabled ppc; then
  3257. echo "AltiVec enabled ${altivec-no}"
  3258. echo "PPC 4xx optimizations ${ppc4xx-no}"
  3259. echo "dcbzl available ${dcbzl-no}"
  3260. fi
  3261. if enabled sparc; then
  3262. echo "VIS enabled ${vis-no}"
  3263. fi
  3264. echo "debug symbols ${debug-no}"
  3265. echo "optimize for size ${small-no}"
  3266. echo "optimizations ${optimizations-no}"
  3267. echo "static ${static-no}"
  3268. echo "shared ${shared-no}"
  3269. echo "new filter support ${avfilter-no}"
  3270. echo "network support ${network-no}"
  3271. echo "threading support ${thread_type-no}"
  3272. echo "safe bitstream reader ${safe_bitstream_reader-no}"
  3273. echo "SDL support ${sdl-no}"
  3274. echo "libdxva2 enabled ${dxva2-no}"
  3275. echo "libva enabled ${vaapi-no}"
  3276. echo "libvdpau enabled ${vdpau-no}"
  3277. echo "AVISynth enabled ${avisynth-no}"
  3278. echo "frei0r enabled ${frei0r-no}"
  3279. echo "gnutls enabled ${gnutls-no}"
  3280. echo "libcdio support ${libcdio-no}"
  3281. echo "libdc1394 support ${libdc1394-no}"
  3282. echo "libfaac enabled ${libfaac-no}"
  3283. echo "libfdk-aac enabled ${libfdk_aac-no}"
  3284. echo "libgsm enabled ${libgsm-no}"
  3285. echo "libilbc enabled ${libilbc-no}"
  3286. echo "libmp3lame enabled ${libmp3lame-no}"
  3287. echo "libopencore-amrnb support ${libopencore_amrnb-no}"
  3288. echo "libopencore-amrwb support ${libopencore_amrwb-no}"
  3289. echo "libopencv support ${libopencv-no}"
  3290. echo "libopenjpeg enabled ${libopenjpeg-no}"
  3291. echo "libopus enabled ${libopus-no}"
  3292. echo "libpulse enabled ${libpulse-no}"
  3293. echo "librtmp enabled ${librtmp-no}"
  3294. echo "libschroedinger enabled ${libschroedinger-no}"
  3295. echo "libspeex enabled ${libspeex-no}"
  3296. echo "libtheora enabled ${libtheora-no}"
  3297. echo "libvo-aacenc support ${libvo_aacenc-no}"
  3298. echo "libvo-amrwbenc support ${libvo_amrwbenc-no}"
  3299. echo "libvorbis enabled ${libvorbis-no}"
  3300. echo "libvpx enabled ${libvpx-no}"
  3301. echo "libx264 enabled ${libx264-no}"
  3302. echo "libxavs enabled ${libxavs-no}"
  3303. echo "libxvid enabled ${libxvid-no}"
  3304. echo "openssl enabled ${openssl-no}"
  3305. echo "zlib enabled ${zlib-no}"
  3306. echo "bzlib enabled ${bzlib-no}"
  3307. test -n "$random_seed" &&
  3308. echo "random seed ${random_seed}"
  3309. echo
  3310. for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
  3311. echo "Enabled ${type}s:"
  3312. eval list=\$$(toupper $type)_LIST
  3313. print_enabled '_*' $list | sort | pr -r -3 -t
  3314. echo
  3315. done
  3316. license="LGPL version 2.1 or later"
  3317. if enabled nonfree; then
  3318. license="nonfree and unredistributable"
  3319. elif enabled gplv3; then
  3320. license="GPL version 3 or later"
  3321. elif enabled lgplv3; then
  3322. license="LGPL version 3 or later"
  3323. elif enabled gpl; then
  3324. license="GPL version 2 or later"
  3325. fi
  3326. echo "License: $license"
  3327. echo "Creating config.mak and config.h..."
  3328. test -e Makefile || $ln_s "$source_path/Makefile" .
  3329. config_files="$TMPH config.mak"
  3330. cat > config.mak <<EOF
  3331. # Automatically generated by configure - do not modify!
  3332. LIBAV_CONFIGURATION=$LIBAV_CONFIGURATION
  3333. prefix=$prefix
  3334. LIBDIR=\$(DESTDIR)$libdir
  3335. SHLIBDIR=\$(DESTDIR)$shlibdir
  3336. INCDIR=\$(DESTDIR)$incdir
  3337. BINDIR=\$(DESTDIR)$bindir
  3338. DATADIR=\$(DESTDIR)$datadir
  3339. MANDIR=\$(DESTDIR)$mandir
  3340. SRC_PATH=$source_path
  3341. CC_IDENT=$cc_ident
  3342. ARCH=$arch
  3343. CC=$cc
  3344. AS=$as
  3345. LD=$ld
  3346. DEPCC=$dep_cc
  3347. DEPCCFLAGS=$DEPCCFLAGS \$(CPPFLAGS)
  3348. DEPAS=$as
  3349. DEPASFLAGS=$DEPASFLAGS \$(CPPFLAGS)
  3350. YASM=$yasmexe
  3351. DEPYASM=$yasmexe
  3352. AR=$ar
  3353. ARFLAGS=$arflags
  3354. AR_O=$ar_o
  3355. RANLIB=$ranlib
  3356. LN_S=$ln_s
  3357. CPPFLAGS=$CPPFLAGS
  3358. CFLAGS=$CFLAGS
  3359. ASFLAGS=$ASFLAGS
  3360. AS_C=$AS_C
  3361. AS_O=$AS_O
  3362. CC_C=$CC_C
  3363. CC_O=$CC_O
  3364. LD_O=$LD_O
  3365. LD_LIB=$LD_LIB
  3366. LD_PATH=$LD_PATH
  3367. DLLTOOL=$dlltool
  3368. LDFLAGS=$LDFLAGS
  3369. LDFLAGS-avserver=$AVSERVERLDFLAGS
  3370. SHFLAGS=$SHFLAGS
  3371. YASMFLAGS=$YASMFLAGS
  3372. BUILDSUF=$build_suffix
  3373. FULLNAME=$FULLNAME
  3374. LIBPREF=$LIBPREF
  3375. LIBSUF=$LIBSUF
  3376. LIBNAME=$LIBNAME
  3377. SLIBPREF=$SLIBPREF
  3378. SLIBSUF=$SLIBSUF
  3379. EXESUF=$EXESUF
  3380. EXTRA_VERSION=$extra_version
  3381. CCDEP=$CCDEP
  3382. CCDEP_FLAGS=$CCDEP_FLAGS
  3383. ASDEP=$ASDEP
  3384. ASDEP_FLAGS=$ASDEP_FLAGS
  3385. CC_DEPFLAGS=$CC_DEPFLAGS
  3386. AS_DEPFLAGS=$AS_DEPFLAGS
  3387. HOSTCC=$host_cc
  3388. HOSTLD=$host_ld
  3389. HOSTCFLAGS=$host_cflags
  3390. HOSTEXESUF=$HOSTEXESUF
  3391. HOSTLDFLAGS=$host_ldflags
  3392. HOSTLIBS=$host_libs
  3393. DEPHOSTCC=$host_cc
  3394. DEPHOSTCCFLAGS=$DEPHOSTCCFLAGS \$(HOSTCCFLAGS)
  3395. HOSTCCDEP=$HOSTCCDEP
  3396. HOSTCCDEP_FLAGS=$HOSTCCDEP_FLAGS
  3397. HOSTCC_DEPFLAGS=$HOSTCC_DEPFLAGS
  3398. HOSTCC_C=$HOSTCC_C
  3399. HOSTCC_O=$HOSTCC_O
  3400. HOSTLD_O=$HOSTLD_O
  3401. TARGET_EXEC=$target_exec
  3402. TARGET_PATH=$target_path
  3403. LIBS-avplay=$sdl_libs
  3404. CFLAGS-avplay=$sdl_cflags
  3405. ZLIB=$($ldflags_filter -lz)
  3406. LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
  3407. EXTRALIBS=$extralibs
  3408. COMPAT_OBJS=$compat_objs
  3409. EXEOBJS=$exeobjs
  3410. INSTALL=install
  3411. LIBTARGET=${LIBTARGET}
  3412. SLIBNAME=${SLIBNAME}
  3413. SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
  3414. SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
  3415. SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
  3416. SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
  3417. SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
  3418. SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
  3419. SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
  3420. SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
  3421. SAMPLES:=${samples:-\$(LIBAV_SAMPLES)}
  3422. EOF
  3423. get_version(){
  3424. lcname=$1
  3425. name=$(toupper $lcname)
  3426. file=$source_path/$lcname/version.h
  3427. eval $(awk "/#define ${name}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file")
  3428. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  3429. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  3430. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  3431. }
  3432. get_version libavcodec
  3433. get_version libavdevice
  3434. get_version libavfilter
  3435. get_version libavformat
  3436. get_version libavresample
  3437. get_version libavutil
  3438. get_version libswscale
  3439. cat > $TMPH <<EOF
  3440. /* Automatically generated by configure - do not modify! */
  3441. #ifndef LIBAV_CONFIG_H
  3442. #define LIBAV_CONFIG_H
  3443. #define LIBAV_CONFIGURATION "$(c_escape $LIBAV_CONFIGURATION)"
  3444. #define LIBAV_LICENSE "$(c_escape $license)"
  3445. #define AVCONV_DATADIR "$(eval c_escape $datadir)"
  3446. #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
  3447. #define restrict $_restrict
  3448. #define EXTERN_PREFIX "${extern_prefix}"
  3449. #define EXTERN_ASM ${extern_prefix}
  3450. #define SLIBSUF "$SLIBSUF"
  3451. EOF
  3452. test -n "$malloc_prefix" &&
  3453. echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
  3454. if enabled yasm; then
  3455. append config_files $TMPASM
  3456. printf '' >$TMPASM
  3457. fi
  3458. print_config ARCH_ "$config_files" $ARCH_LIST
  3459. print_config HAVE_ "$config_files" $HAVE_LIST
  3460. print_config CONFIG_ "$config_files" $CONFIG_LIST \
  3461. $CONFIG_EXTRA \
  3462. $ALL_COMPONENTS \
  3463. echo "#endif /* LIBAV_CONFIG_H */" >> $TMPH
  3464. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  3465. cp_if_changed $TMPH config.h
  3466. touch .config
  3467. enabled yasm && cp_if_changed $TMPASM config.asm
  3468. cat > $TMPH <<EOF
  3469. /* Generated by ffconf */
  3470. #ifndef AVUTIL_AVCONFIG_H
  3471. #define AVUTIL_AVCONFIG_H
  3472. EOF
  3473. print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
  3474. echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
  3475. cp_if_changed $TMPH libavutil/avconfig.h
  3476. test -n "$WARNINGS" && printf "\n$WARNINGS"
  3477. # build pkg-config files
  3478. pkgconfig_generate(){
  3479. name=$1
  3480. shortname=${name#lib}${build_suffix}
  3481. comment=$2
  3482. version=$3
  3483. libs=$4
  3484. requires=$5
  3485. enabled ${name#lib} || return 0
  3486. mkdir -p $name
  3487. cat <<EOF > $name/$name.pc
  3488. prefix=$prefix
  3489. exec_prefix=\${prefix}
  3490. libdir=$libdir
  3491. includedir=$incdir
  3492. Name: $name
  3493. Description: $comment
  3494. Version: $version
  3495. Requires: $(enabled shared || echo $requires)
  3496. Requires.private: $(enabled shared && echo $requires)
  3497. Conflicts:
  3498. Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
  3499. Libs.private: $(enabled shared && echo $libs)
  3500. Cflags: -I\${includedir}
  3501. EOF
  3502. cat <<EOF > $name/$name-uninstalled.pc
  3503. prefix=
  3504. exec_prefix=
  3505. libdir=\${pcfiledir}
  3506. includedir=${source_path}
  3507. Name: $name
  3508. Description: $comment
  3509. Version: $version
  3510. Requires: $requires
  3511. Conflicts:
  3512. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  3513. Cflags: -I\${includedir}
  3514. EOF
  3515. }
  3516. pkgconfig_generate libavutil "Libav utility library" "$LIBAVUTIL_VERSION" "$LIBM"
  3517. pkgconfig_generate libavcodec "Libav codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  3518. pkgconfig_generate libavformat "Libav container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
  3519. pkgconfig_generate libavdevice "Libav device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
  3520. pkgconfig_generate libavfilter "Libav video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  3521. pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  3522. pkgconfig_generate libswscale "Libav image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION"