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.

3475 lines
103KB

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