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.

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