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.

3712 lines
108KB

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