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.

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