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

3907 lines
113KB

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