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.

3938 lines
114KB

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