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.

3903 lines
113KB

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