configure 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583
  1. #!/bin/bash
  2. if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
  3. cat <<EOF
  4. Usage: ./configure [options]
  5. Help:
  6. -h, --help print this message
  7. Standard options:
  8. --prefix=PREFIX install architecture-independent files in PREFIX
  9. [/usr/local]
  10. --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
  11. [PREFIX]
  12. --bindir=DIR install binaries in DIR [EPREFIX/bin]
  13. --libdir=DIR install libs in DIR [EPREFIX/lib]
  14. --includedir=DIR install includes in DIR [PREFIX/include]
  15. --extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS
  16. --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS
  17. --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS
  18. --extra-rcflags=ERCFLAGS add ERCFLAGS to RCFLAGS
  19. Configuration options:
  20. --disable-cli disable cli
  21. --system-libx264 use system libx264 instead of internal
  22. --enable-shared build shared library
  23. --enable-static build static library
  24. --disable-opencl disable OpenCL features
  25. --disable-gpl disable GPL-only features
  26. --disable-thread disable multithreaded encoding
  27. --disable-win32thread disable win32threads (windows only)
  28. --disable-interlaced disable interlaced encoding support
  29. --bit-depth=BIT_DEPTH set output bit depth (8, 10, all) [all]
  30. --chroma-format=FORMAT output chroma format (400, 420, 422, 444, all) [all]
  31. Advanced options:
  32. --disable-asm disable platform-specific assembly optimizations
  33. --enable-lto enable link-time optimization
  34. --enable-debug add -g
  35. --enable-gprof add -pg
  36. --enable-strip add -s
  37. --enable-pic build position-independent code
  38. Cross-compilation:
  39. --host=HOST build programs to run on HOST
  40. --cross-prefix=PREFIX use PREFIX for compilation tools
  41. --sysroot=SYSROOT root of cross-build tree
  42. External library support:
  43. --disable-avs disable avisynth support
  44. --disable-swscale disable swscale support
  45. --disable-lavf disable libavformat support
  46. --disable-ffms disable ffmpegsource support
  47. --disable-gpac disable gpac support
  48. --disable-lsmash disable lsmash support
  49. EOF
  50. exit 1
  51. fi
  52. log_check() {
  53. echo -n "checking $1... " >> config.log
  54. }
  55. log_ok() {
  56. echo "yes" >> config.log
  57. }
  58. log_fail() {
  59. echo "no" >> config.log
  60. }
  61. log_msg() {
  62. echo "$1" >> config.log
  63. }
  64. cc_cflags() {
  65. # several non gcc compilers issue an incredibly large number of warnings on high warning levels,
  66. # suppress them by reducing the warning level rather than having to use #pragmas
  67. for arg in $*; do
  68. [[ "$arg" = -falign-loops* ]] && arg=
  69. [ "$arg" = -fno-tree-vectorize ] && arg=
  70. [ "$arg" = -Wshadow ] && arg=
  71. [ "$arg" = -Wno-maybe-uninitialized ] && arg=
  72. [[ "$arg" = -mpreferred-stack-boundary* ]] && arg=
  73. [[ "$arg" = -l* ]] && arg=
  74. [[ "$arg" = -L* ]] && arg=
  75. if [ $compiler_style = MS ]; then
  76. [ "$arg" = -ffast-math ] && arg="-fp:fast"
  77. [ "$arg" = -Wall ] && arg=
  78. [ "$arg" = -Werror ] && arg="-W3 -WX"
  79. [ "$arg" = -g ] && arg=-Z7
  80. [ "$arg" = -fomit-frame-pointer ] && arg=
  81. [ "$arg" = -s ] && arg=
  82. [ "$arg" = -fPIC ] && arg=
  83. else
  84. [ "$arg" = -ffast-math ] && arg=
  85. [ "$arg" = -Wall ] && arg=
  86. [ "$arg" = -Werror ] && arg="-w3 -Werror"
  87. fi
  88. [ $compiler = CL -a "$arg" = -O3 ] && arg=-O2
  89. [ -n "$arg" ] && echo -n "$arg "
  90. done
  91. }
  92. cl_ldflags() {
  93. for arg in $*; do
  94. arg=${arg/LIBPATH/libpath}
  95. [ "${arg#-libpath:}" == "$arg" -a "${arg#-l}" != "$arg" ] && arg=${arg#-l}.lib
  96. [ "${arg#-L}" != "$arg" ] && arg=-libpath:${arg#-L}
  97. [ "$arg" = -Wl,--large-address-aware ] && arg=-largeaddressaware
  98. [ "$arg" = -s ] && arg=
  99. [ "$arg" = -Wl,-Bsymbolic ] && arg=
  100. [ "$arg" = -fno-tree-vectorize ] && arg=
  101. [ "$arg" = -Werror ] && arg=
  102. [ "$arg" = -Wshadow ] && arg=
  103. [ "$arg" = -Wmaybe-uninitialized ] && arg=
  104. [[ "$arg" = -Qdiag-error* ]] && arg=
  105. arg=${arg/pthreadGC/pthreadVC}
  106. [ "$arg" = avifil32.lib ] && arg=vfw32.lib
  107. [ "$arg" = gpac_static.lib ] && arg=libgpac_static.lib
  108. [ "$arg" = x264.lib ] && arg=libx264.lib
  109. [ -n "$arg" ] && echo -n "$arg "
  110. done
  111. }
  112. cc_check() {
  113. if [ -z "$3" ]; then
  114. if [ -z "$1$2" ]; then
  115. log_check "whether $CC works"
  116. elif [ -z "$1" ]; then
  117. log_check "for $2"
  118. else
  119. log_check "for $1"
  120. fi
  121. elif [ -z "$1" ]; then
  122. if [ -z "$2" ]; then
  123. log_check "whether $CC supports $3"
  124. else
  125. log_check "whether $CC supports $3 with $2"
  126. fi
  127. else
  128. log_check "for $3 in $1";
  129. fi
  130. rm -f conftest.c
  131. for arg in $1; do
  132. echo "#include <$arg>" >> conftest.c
  133. done
  134. echo "int main (void) { $3 return 0; }" >> conftest.c
  135. if [ $compiler_style = MS ]; then
  136. cc_cmd="$CC conftest.c $(cc_cflags $CFLAGS $CHECK_CFLAGS $2) -link $(cl_ldflags $2 $LDFLAGSCLI $LDFLAGS)"
  137. else
  138. cc_cmd="$CC conftest.c $CFLAGS $CHECK_CFLAGS $2 $LDFLAGSCLI $LDFLAGS -o conftest"
  139. fi
  140. if $cc_cmd >conftest.log 2>&1; then
  141. res=$?
  142. log_ok
  143. else
  144. res=$?
  145. log_fail
  146. log_msg "Failed commandline was:"
  147. log_msg "--------------------------------------------------"
  148. log_msg "$cc_cmd"
  149. cat conftest.log >> config.log
  150. log_msg "--------------------------------------------------"
  151. log_msg "Failed program was:"
  152. log_msg "--------------------------------------------------"
  153. cat conftest.c >> config.log
  154. log_msg "--------------------------------------------------"
  155. fi
  156. return $res
  157. }
  158. cpp_check() {
  159. log_check "whether $3 is true"
  160. rm -f conftest.c
  161. for arg in $1; do
  162. echo "#include <$arg>" >> conftest.c
  163. done
  164. echo -e "#if !($3) \n#error $4 \n#endif " >> conftest.c
  165. if [ $compiler_style = MS ]; then
  166. cpp_cmd="$CC conftest.c $(cc_cflags $CFLAGS $2) -P"
  167. else
  168. cpp_cmd="$CC conftest.c $CFLAGS $2 -E -o conftest"
  169. fi
  170. if $cpp_cmd >conftest.log 2>&1; then
  171. res=$?
  172. log_ok
  173. else
  174. res=$?
  175. log_fail
  176. log_msg "--------------------------------------------------"
  177. cat conftest.log >> config.log
  178. log_msg "--------------------------------------------------"
  179. log_msg "Failed program was:"
  180. log_msg "--------------------------------------------------"
  181. cat conftest.c >> config.log
  182. log_msg "--------------------------------------------------"
  183. fi
  184. return $res
  185. }
  186. as_check() {
  187. log_check "whether $AS supports $1"
  188. echo "$1" > conftest$AS_EXT
  189. as_cmd="$AS conftest$AS_EXT $ASFLAGS $2 -o conftest.o"
  190. if $as_cmd >conftest.log 2>&1; then
  191. res=$?
  192. log_ok
  193. else
  194. res=$?
  195. log_fail
  196. log_msg "Failed commandline was:"
  197. log_msg "--------------------------------------------------"
  198. log_msg "$as_cmd"
  199. cat conftest.log >> config.log
  200. log_msg "--------------------------------------------------"
  201. log_msg "Failed program was:"
  202. log_msg "--------------------------------------------------"
  203. cat conftest$AS_EXT >> config.log
  204. log_msg "--------------------------------------------------"
  205. fi
  206. return $res
  207. }
  208. rc_check() {
  209. log_check "whether $RC works"
  210. echo "$1" > conftest.rc
  211. if [ $compiler = GNU ]; then
  212. rc_cmd="$RC $RCFLAGS -o conftest.o conftest.rc"
  213. else
  214. rc_cmd="$RC $RCFLAGS -foconftest.o conftest.rc"
  215. fi
  216. if $rc_cmd >conftest.log 2>&1; then
  217. res=$?
  218. log_ok
  219. else
  220. res=$?
  221. log_fail
  222. log_msg "Failed commandline was:"
  223. log_msg "--------------------------------------------------"
  224. log_msg "$rc_cmd"
  225. cat conftest.log >> config.log
  226. log_msg "--------------------------------------------------"
  227. log_msg "Failed program was:"
  228. log_msg "--------------------------------------------------"
  229. cat conftest.rc >> config.log
  230. log_msg "--------------------------------------------------"
  231. fi
  232. return $res
  233. }
  234. pkg_check() {
  235. log_check "for packages: $1"
  236. pkg_cmd="$PKGCONFIG --exists $1"
  237. if $pkg_cmd >conftest.log 2>&1; then
  238. res=$?
  239. log_ok
  240. else
  241. res=$?
  242. log_fail
  243. log_msg "Failed commandline was:"
  244. log_msg "--------------------------------------------------"
  245. log_msg "$pkg_cmd"
  246. cat conftest.log >> config.log
  247. log_msg "--------------------------------------------------"
  248. fi
  249. return $res
  250. }
  251. define() {
  252. echo "#define $1$([ -n "$2" ] && echo " $2" || echo " 1")" >> config.h
  253. }
  254. die() {
  255. log_msg "DIED: $@"
  256. echo "$@"
  257. exit 1
  258. }
  259. configure_system_override() {
  260. log_check "system libx264 configuration"
  261. x264_config_path="$1/x264_config.h"
  262. if [ -e "$x264_config_path" ]; then
  263. res=$?
  264. log_ok
  265. arg="$(grep '#define X264_GPL ' $x264_config_path | sed -e 's/#define X264_GPL *//; s/ *$//')"
  266. if [ -n "$arg" ]; then
  267. [ "$arg" = 0 ] && arg="no" || arg="yes"
  268. [ "$arg" != "$gpl" ] && die "Incompatible license with system libx264"
  269. fi
  270. arg="$(grep '#define X264_BIT_DEPTH ' $x264_config_path | sed -e 's/#define X264_BIT_DEPTH *//; s/ *$//')"
  271. if [ -n "$arg" ]; then
  272. [ "$arg" = 0 ] && arg="all"
  273. if [ "$arg" != "$bit_depth" ]; then
  274. echo "Override output bit depth with system libx264 configuration"
  275. bit_depth="$arg"
  276. fi
  277. fi
  278. arg="$(grep '#define X264_CHROMA_FORMAT ' $x264_config_path | sed -e 's/#define X264_CHROMA_FORMAT *//; s/ *$//')"
  279. if [ -n "$arg" ]; then
  280. [ "$arg" = 0 ] && arg="all" || arg="${arg#X264_CSP_I}"
  281. if [ "$arg" != "$chroma_format" ]; then
  282. echo "Override output chroma format with system libx264 configuration"
  283. chroma_format="$arg"
  284. fi
  285. fi
  286. arg="$(grep '#define X264_INTERLACED ' $x264_config_path | sed -e 's/#define X264_INTERLACED *//; s/ *$//')"
  287. if [ -n "$arg" ]; then
  288. [ "$arg" = 0 ] && arg="no" || arg="yes"
  289. if [ "$arg" != "$interlaced" ]; then
  290. echo "Override interlaced encoding support with system libx264 configuration"
  291. interlaced="$arg"
  292. fi
  293. fi
  294. else
  295. res=$?
  296. log_fail
  297. log_msg "Failed search path was: $x264_config_path"
  298. fi
  299. return $res
  300. }
  301. rm -f x264_config.h config.h config.mak config.log x264.pc x264.def
  302. rm -rf conftest*
  303. # Construct a path to the specified directory relative to the working directory
  304. relative_path() {
  305. local base="${PWD%/}"
  306. local path="$(cd "$1" >/dev/null; printf '%s/.' "${PWD%/}")"
  307. local up=''
  308. while [[ $path != "$base/"* ]]; do
  309. base="${base%/*}"
  310. up="../$up"
  311. done
  312. dirname "$up${path#"$base/"}"
  313. }
  314. SRCPATH="$(relative_path "$(dirname "$0")")"
  315. echo "$SRCPATH" | grep -q ' ' && die "Out of tree builds are impossible with whitespace in source path."
  316. [ -e "$SRCPATH/config.h" -o -e "$SRCPATH/x264_config.h" ] && die "Out of tree builds are impossible with config.h/x264_config.h in source dir."
  317. prefix='/usr/local'
  318. exec_prefix='${prefix}'
  319. bindir='${exec_prefix}/bin'
  320. libdir='${exec_prefix}/lib'
  321. includedir='${prefix}/include'
  322. DEVNULL='/dev/null'
  323. cli="yes"
  324. cli_libx264="internal"
  325. shared="no"
  326. static="no"
  327. avs="auto"
  328. lavf="auto"
  329. ffms="auto"
  330. gpac="auto"
  331. lsmash="auto"
  332. mp4="no"
  333. gpl="yes"
  334. thread="auto"
  335. swscale="auto"
  336. asm="auto"
  337. interlaced="yes"
  338. lto="no"
  339. debug="no"
  340. gprof="no"
  341. strip="no"
  342. pic="no"
  343. bit_depth="all"
  344. chroma_format="all"
  345. compiler="GNU"
  346. compiler_style="GNU"
  347. opencl="yes"
  348. vsx="auto"
  349. CFLAGS="$CFLAGS -Wall -I. -I\$(SRCPATH)"
  350. LDFLAGS="$LDFLAGS"
  351. LDFLAGSCLI="$LDFLAGSCLI"
  352. ASFLAGS="$ASFLAGS -I. -I\$(SRCPATH)"
  353. RCFLAGS="$RCFLAGS"
  354. CHECK_CFLAGS=""
  355. HAVE_GETOPT_LONG=1
  356. cross_prefix=""
  357. EXE=""
  358. AS_EXT=".S"
  359. NL="
  360. "
  361. # list of all preprocessor HAVE values we can define
  362. CONFIG_HAVE="MALLOC_H ALTIVEC ALTIVEC_H MMX ARMV6 ARMV6T2 NEON BEOSTHREAD POSIXTHREAD WIN32THREAD THREAD LOG2F SWSCALE \
  363. LAVF FFMS GPAC AVS GPL VECTOREXT INTERLACED CPU_COUNT OPENCL THP LSMASH X86_INLINE_ASM AS_FUNC INTEL_DISPATCHER \
  364. MSA MMAP WINRT VSX ARM_INLINE_ASM STRTOK_R CLOCK_GETTIME BITDEPTH8 BITDEPTH10"
  365. # parse options
  366. for opt do
  367. optarg="${opt#*=}"
  368. case "$opt" in
  369. --prefix=*)
  370. prefix="$optarg"
  371. ;;
  372. --exec-prefix=*)
  373. exec_prefix="$optarg"
  374. ;;
  375. --bindir=*)
  376. bindir="$optarg"
  377. ;;
  378. --libdir=*)
  379. libdir="$optarg"
  380. ;;
  381. --includedir=*)
  382. includedir="$optarg"
  383. ;;
  384. --disable-cli)
  385. cli="no"
  386. ;;
  387. --system-libx264)
  388. cli_libx264="system"
  389. ;;
  390. --enable-shared)
  391. shared="yes"
  392. ;;
  393. --enable-static)
  394. static="yes"
  395. ;;
  396. --disable-asm)
  397. asm="no"
  398. ;;
  399. --disable-interlaced)
  400. interlaced="no"
  401. ;;
  402. --disable-avs)
  403. avs="no"
  404. ;;
  405. --disable-lavf)
  406. lavf="no"
  407. ;;
  408. --disable-ffms)
  409. ffms="no"
  410. ;;
  411. --disable-gpac)
  412. gpac="no"
  413. ;;
  414. --disable-lsmash)
  415. lsmash="no"
  416. ;;
  417. --disable-gpl)
  418. gpl="no"
  419. ;;
  420. --extra-asflags=*)
  421. ASFLAGS="$ASFLAGS $optarg"
  422. ;;
  423. --extra-cflags=*)
  424. CFLAGS="$CFLAGS $optarg"
  425. ;;
  426. --extra-ldflags=*)
  427. LDFLAGS="$LDFLAGS $optarg"
  428. ;;
  429. --extra-rcflags=*)
  430. RCFLAGS="$RCFLAGS $optarg"
  431. ;;
  432. --disable-thread)
  433. thread="no"
  434. ;;
  435. --disable-win32thread)
  436. [ "$thread" != "no" ] && thread="posix"
  437. ;;
  438. --disable-swscale)
  439. swscale="no"
  440. ;;
  441. --enable-lto)
  442. lto="auto"
  443. ;;
  444. --enable-debug)
  445. debug="yes"
  446. ;;
  447. --enable-gprof)
  448. CFLAGS="$CFLAGS -pg"
  449. LDFLAGS="$LDFLAGS -pg"
  450. gprof="yes"
  451. ;;
  452. --enable-strip)
  453. strip="yes"
  454. ;;
  455. --enable-pic)
  456. pic="yes"
  457. ;;
  458. --host=*)
  459. host="$optarg"
  460. ;;
  461. --disable-vsx)
  462. vsx="no"
  463. ;;
  464. --disable-opencl)
  465. opencl="no"
  466. ;;
  467. --cross-prefix=*)
  468. cross_prefix="$optarg"
  469. ;;
  470. --sysroot=*)
  471. CFLAGS="$CFLAGS --sysroot=$optarg"
  472. LDFLAGS="$LDFLAGS --sysroot=$optarg"
  473. ;;
  474. --bit-depth=*)
  475. bit_depth="$optarg"
  476. if [ "$bit_depth" != "8" -a "$bit_depth" != "10" -a "$bit_depth" != "all" ]; then
  477. echo "Supplied bit depth must be 8, 10 or all."
  478. exit 1
  479. fi
  480. ;;
  481. --chroma-format=*)
  482. chroma_format="$optarg"
  483. if [ $chroma_format != "400" -a $chroma_format != "420" -a $chroma_format != "422" -a $chroma_format != "444" -a $chroma_format != "all" ]; then
  484. echo "Supplied chroma format must be 400, 420, 422, 444 or all."
  485. exit 1
  486. fi
  487. ;;
  488. *)
  489. echo "Unknown option $opt, ignored"
  490. ;;
  491. esac
  492. done
  493. [ "$cli" = "no" -a "$shared" = "no" -a "$static" = "no" ] && die "Nothing to build. Enable cli, shared or static."
  494. CC="${CC-${cross_prefix}gcc}"
  495. STRIP="${STRIP-${cross_prefix}strip}"
  496. INSTALL="${INSTALL-install}"
  497. PKGCONFIG="${PKGCONFIG-${cross_prefix}pkg-config}"
  498. # ar and ranlib doesn't load the LTO plugin by default, prefer the gcc-prefixed wrappers which does.
  499. if ${cross_prefix}gcc-ar --version >/dev/null 2>&1; then
  500. AR="${AR-${cross_prefix}gcc-ar}"
  501. else
  502. AR="${AR-${cross_prefix}ar}"
  503. fi
  504. if ${cross_prefix}gcc-ranlib --version >/dev/null 2>&1; then
  505. RANLIB="${RANLIB-${cross_prefix}gcc-ranlib}"
  506. else
  507. RANLIB="${RANLIB-${cross_prefix}ranlib}"
  508. fi
  509. if [ "x$host" = x ]; then
  510. host="$(${SRCPATH}/config.guess)"
  511. fi
  512. # normalize a triplet into a quadruplet
  513. host="$(${SRCPATH}/config.sub $host)"
  514. # split $host
  515. host_cpu="${host%%-*}"
  516. host="${host#*-}"
  517. host_vendor="${host%%-*}"
  518. host_os="${host#*-}"
  519. trap 'rm -rf conftest*' EXIT
  520. # test for use of compilers that require specific handling
  521. cc_base="$(basename "$CC")"
  522. QPRE="-"
  523. if [[ $host_os = mingw* || $host_os = cygwin* ]]; then
  524. if [[ "$cc_base" = icl || "$cc_base" = icl[\ .]* ]]; then
  525. # Windows Intel Compiler creates dependency generation with absolute Windows paths, Cygwin's make does not support Windows paths.
  526. [[ $host_os = cygwin* ]] && die "Windows Intel Compiler support requires MSYS"
  527. compiler=ICL
  528. compiler_style=MS
  529. CFLAGS="$CFLAGS -Qstd=c99 -nologo -Qms0 -DHAVE_STRING_H -I\$(SRCPATH)/extras"
  530. QPRE="-Q"
  531. cpp_check '' '' '_MSC_VER >= 1400' || die "Windows Intel Compiler support requires Visual Studio 2005 or newer"
  532. if cpp_check '' '' 'defined(_M_AMD64) || defined(_M_X64)' ; then
  533. host_cpu=x86_64
  534. elif cpp_check '' '' 'defined(_M_IX86)' ; then
  535. host_cpu=i486
  536. fi
  537. if cc_check '' -Qdiag-error:10006,10157 ; then
  538. CHECK_CFLAGS="$CHECK_CFLAGS -Qdiag-error:10006,10157"
  539. fi
  540. elif [[ "$cc_base" = cl || "$cc_base" = cl[\ .]* ]]; then
  541. # Standard Microsoft Visual Studio
  542. compiler=CL
  543. compiler_style=MS
  544. CFLAGS="$CFLAGS -nologo -GS- -DHAVE_STRING_H -I\$(SRCPATH)/extras"
  545. cpp_check '' '' '_MSC_VER > 1800 || (_MSC_VER == 1800 && _MSC_FULL_VER >= 180030324)' || die "Microsoft Visual Studio support requires Visual Studio 2013 Update 2 or newer"
  546. if cpp_check '' '' 'defined(_M_AMD64) || defined(_M_X64)' ; then
  547. host_cpu=x86_64
  548. elif cpp_check '' '' 'defined(_M_IX86)' ; then
  549. host_cpu=i486
  550. elif cpp_check '' '' 'defined(_M_ARM64)' ; then
  551. host_cpu=aarch64
  552. elif cpp_check '' '' 'defined(_M_ARM)' ; then
  553. host_cpu=arm
  554. fi
  555. else
  556. # MinGW uses broken pre-VS2015 Microsoft printf functions unless it's told to use the POSIX ones.
  557. CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L"
  558. fi
  559. else
  560. if [[ "$cc_base" = icc || "$cc_base" = icc[\ .]* ]]; then
  561. AR="xiar"
  562. compiler=ICC
  563. fi
  564. fi
  565. if [ $compiler = GNU ]; then
  566. if cc_check '' -Werror=unknown-warning-option ; then
  567. CHECK_CFLAGS="$CHECK_CFLAGS -Werror=unknown-warning-option"
  568. fi
  569. fi
  570. libm=""
  571. case $host_os in
  572. beos*)
  573. SYS="BEOS"
  574. define HAVE_MALLOC_H
  575. ;;
  576. darwin*)
  577. SYS="MACOSX"
  578. libm="-lm"
  579. if [ "$pic" = "no" ]; then
  580. cc_check "" -mdynamic-no-pic && CFLAGS="$CFLAGS -mdynamic-no-pic"
  581. fi
  582. ;;
  583. freebsd*)
  584. SYS="FREEBSD"
  585. libm="-lm"
  586. ;;
  587. kfreebsd*-gnu)
  588. SYS="FREEBSD"
  589. define HAVE_MALLOC_H
  590. libm="-lm"
  591. ;;
  592. netbsd*)
  593. SYS="NETBSD"
  594. libm="-lm"
  595. ;;
  596. openbsd*)
  597. SYS="OPENBSD"
  598. libm="-lm"
  599. ;;
  600. *linux*)
  601. SYS="LINUX"
  602. define HAVE_MALLOC_H
  603. libm="-lm"
  604. ;;
  605. gnu*)
  606. SYS="HURD"
  607. define HAVE_MALLOC_H
  608. libm="-lm"
  609. ;;
  610. cygwin*|mingw*|msys*)
  611. EXE=".exe"
  612. if [[ $host_os = cygwin* ]] && cpp_check "" "" "defined(__CYGWIN__)" ; then
  613. SYS="CYGWIN"
  614. define HAVE_MALLOC_H
  615. else
  616. SYS="WINDOWS"
  617. DEVNULL="NUL"
  618. cc_check '' -lshell32 && LDFLAGSCLI="$LDFLAGSCLI -lshell32"
  619. [ $compiler = GNU ] && RC="${RC-${cross_prefix}windres}" || RC="${RC-rc.exe}"
  620. fi
  621. ;;
  622. sunos*|solaris*)
  623. SYS="SunOS"
  624. define HAVE_MALLOC_H
  625. libm="-lm"
  626. if cc_check "" /usr/lib/64/values-xpg6.o; then
  627. LDFLAGS="$LDFLAGS /usr/lib/64/values-xpg6.o"
  628. else
  629. LDFLAGS="$LDFLAGS /usr/lib/values-xpg6.o"
  630. fi
  631. if test -x /usr/ucb/install ; then
  632. INSTALL=/usr/ucb/install
  633. elif test -x /usr/bin/ginstall ; then
  634. # OpenSolaris
  635. INSTALL=/usr/bin/ginstall
  636. elif test -x /usr/gnu/bin/install ; then
  637. # OpenSolaris
  638. INSTALL=/usr/gnu/bin/install
  639. fi
  640. HAVE_GETOPT_LONG=0
  641. ;;
  642. *qnx*)
  643. SYS="QNX"
  644. define HAVE_MALLOC_H
  645. libm="-lm"
  646. HAVE_GETOPT_LONG=0
  647. CFLAGS="$CFLAGS -I\$(SRCPATH)/extras"
  648. ;;
  649. *haiku*)
  650. SYS="HAIKU"
  651. ;;
  652. *)
  653. die "Unknown system $host, edit the configure"
  654. ;;
  655. esac
  656. LDFLAGS="$LDFLAGS $libm"
  657. stack_alignment=4
  658. case $host_cpu in
  659. i*86)
  660. ARCH="X86"
  661. AS="${AS-nasm}"
  662. AS_EXT=".asm"
  663. ASFLAGS="$ASFLAGS -DARCH_X86_64=0 -I\$(SRCPATH)/common/x86/"
  664. if [ $compiler = GNU ]; then
  665. if [[ "$asm" == auto && "$CFLAGS" != *-march* ]]; then
  666. CFLAGS="$CFLAGS -march=i686"
  667. fi
  668. if [[ "$asm" == auto && "$CFLAGS" != *-mfpmath* ]]; then
  669. CFLAGS="$CFLAGS -mfpmath=sse -msse -msse2"
  670. fi
  671. CFLAGS="-m32 $CFLAGS"
  672. LDFLAGS="-m32 $LDFLAGS"
  673. fi
  674. if [ "$SYS" = MACOSX ]; then
  675. ASFLAGS="$ASFLAGS -f macho32 -DPREFIX"
  676. elif [ "$SYS" = WINDOWS -o "$SYS" = CYGWIN ]; then
  677. ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
  678. LDFLAGS="$LDFLAGS -Wl,--large-address-aware"
  679. [ $compiler = GNU ] && LDFLAGS="$LDFLAGS -Wl,--dynamicbase,--nxcompat,--tsaware"
  680. [ $compiler = GNU ] && RCFLAGS="--target=pe-i386 $RCFLAGS"
  681. else
  682. ASFLAGS="$ASFLAGS -f elf32"
  683. fi
  684. ;;
  685. x86_64)
  686. ARCH="X86_64"
  687. AS="${AS-nasm}"
  688. AS_EXT=".asm"
  689. ASFLAGS="$ASFLAGS -DARCH_X86_64=1 -I\$(SRCPATH)/common/x86/"
  690. stack_alignment=16
  691. [ $compiler = GNU ] && CFLAGS="-m64 $CFLAGS" && LDFLAGS="-m64 $LDFLAGS"
  692. if [ "$SYS" = MACOSX ]; then
  693. ASFLAGS="$ASFLAGS -f macho64 -DPIC -DPREFIX"
  694. if cc_check '' "-arch x86_64"; then
  695. CFLAGS="$CFLAGS -arch x86_64"
  696. LDFLAGS="$LDFLAGS -arch x86_64"
  697. fi
  698. elif [ "$SYS" = WINDOWS -o "$SYS" = CYGWIN ]; then
  699. ASFLAGS="$ASFLAGS -f win64"
  700. if [ $compiler = GNU ]; then
  701. # only the GNU toolchain is inconsistent in prefixing function names with _
  702. cc_check "" "-S" && grep -q "_main:" conftest && ASFLAGS="$ASFLAGS -DPREFIX"
  703. cc_check "" "-Wl,--high-entropy-va" && LDFLAGS="$LDFLAGS -Wl,--high-entropy-va"
  704. LDFLAGS="$LDFLAGS -Wl,--dynamicbase,--nxcompat,--tsaware"
  705. LDFLAGSCLI="$LDFLAGSCLI -Wl,--image-base,0x140000000"
  706. SOFLAGS="$SOFLAGS -Wl,--image-base,0x180000000"
  707. RCFLAGS="--target=pe-x86-64 $RCFLAGS"
  708. fi
  709. else
  710. ASFLAGS="$ASFLAGS -f elf64"
  711. fi
  712. ;;
  713. powerpc*)
  714. ARCH="PPC"
  715. if [ $asm = auto ] ; then
  716. define HAVE_ALTIVEC
  717. AS="${AS-${CC}}"
  718. AS_EXT=".c"
  719. if [ $SYS = MACOSX ] ; then
  720. CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4"
  721. else
  722. CFLAGS="$CFLAGS -maltivec -mabi=altivec"
  723. define HAVE_ALTIVEC_H
  724. fi
  725. if [ "$vsx" != "no" ] ; then
  726. vsx="no"
  727. if cc_check "" "-mvsx" ; then
  728. CFLAGS="$CFLAGS -mvsx"
  729. define HAVE_VSX
  730. vsx="yes"
  731. fi
  732. fi
  733. fi
  734. ;;
  735. sparc)
  736. ARCH="SPARC"
  737. ;;
  738. mips*)
  739. ARCH="MIPS"
  740. AS="${AS-${CC}}"
  741. AS_EXT=".c"
  742. ;;
  743. arm*)
  744. ARCH="ARM"
  745. if [ "$SYS" = MACOSX ] ; then
  746. AS="${AS-${CC}}"
  747. ASFLAGS="$ASFLAGS -DPREFIX -DPIC" # apple's ld doesn't support movw/movt relocations at all
  748. # build for armv7 by default
  749. if ! echo $CFLAGS | grep -Eq '\-arch' ; then
  750. CFLAGS="$CFLAGS -arch armv7"
  751. LDFLAGS="$LDFLAGS -arch armv7"
  752. fi
  753. elif [ "$SYS" = WINDOWS ] && [ "$compiler" = CL ] ; then
  754. AS="${AS-${SRCPATH}/tools/gas-preprocessor.pl -arch arm -as-type armasm -force-thumb -- armasm -nologo -ignore 4509}"
  755. elif [ "$SYS" = WINDOWS ] ; then
  756. AS="${AS-${SRCPATH}/tools/gas-preprocessor.pl -arch arm -as-type clang -force-thumb -- ${CC} -mimplicit-it=always}"
  757. else
  758. AS="${AS-${CC}}"
  759. fi
  760. ;;
  761. aarch64)
  762. ARCH="AARCH64"
  763. stack_alignment=16
  764. if [ "$SYS" = MACOSX ] ; then
  765. AS="${AS-${CC}}"
  766. ASFLAGS="$ASFLAGS -DPREFIX -DPIC"
  767. elif [ "$SYS" = WINDOWS ] && [ "$compiler" = CL ] ; then
  768. AS="${AS-${SRCPATH}/tools/gas-preprocessor.pl -arch aarch64 -as-type armasm -- armasm64 -nologo}"
  769. else
  770. AS="${AS-${CC}}"
  771. fi
  772. ;;
  773. s390|s390x)
  774. ARCH="S390"
  775. ;;
  776. hppa*|parisc*)
  777. ARCH="PARISC"
  778. ;;
  779. ia64)
  780. ARCH="IA64"
  781. ;;
  782. alpha*)
  783. ARCH="ALPHA"
  784. ;;
  785. *)
  786. ARCH="$(echo $host_cpu | tr a-z A-Z)"
  787. ;;
  788. esac
  789. [ "$vsx" != "yes" ] && vsx="no"
  790. if [ $SYS = WINDOWS ]; then
  791. if ! rc_check "0 RCDATA {0}" ; then
  792. RC=""
  793. fi
  794. if cpp_check "winapifamily.h" "" "!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)" ; then
  795. [ $compiler = CL ] || die "WinRT requires MSVC"
  796. define HAVE_WINRT
  797. CFLAGS="$CFLAGS -MD"
  798. LDFLAGS="$LDFLAGS -appcontainer"
  799. if ! cpp_check "" "" "defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0603" ; then
  800. die "_WIN32_WINNT must be defined to at least 0x0603 (Windows 8.1) for WinRT"
  801. elif cpp_check "" "" "_WIN32_WINNT >= 0x0A00" ; then
  802. # Universal Windows Platform (Windows 10)
  803. LDFLAGS="$LDFLAGS -lWindowsApp"
  804. fi
  805. cli="no"
  806. opencl="no"
  807. fi
  808. fi
  809. log_msg "x264 configure script"
  810. if [ -n "$*" ]; then
  811. msg="Command line options:"
  812. for i in $@; do
  813. msg="$msg \"$i\""
  814. done
  815. log_msg "$msg"
  816. fi
  817. log_msg ""
  818. # check requirements
  819. cc_check || die "No working C compiler found."
  820. if [ $compiler_style = GNU ]; then
  821. if cc_check '' -std=gnu99 'for( int i = 0; i < 9; i++ );' ; then
  822. CFLAGS="$CFLAGS -std=gnu99 -D_GNU_SOURCE"
  823. elif cc_check '' -std=c99 'for( int i = 0; i < 9; i++ );' ; then
  824. CFLAGS="$CFLAGS -std=c99 -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE"
  825. elif ! cc_check '' '' 'for( int i = 0; i < 9; i++ );' ; then
  826. die "C99 compiler is needed for compilation."
  827. fi
  828. fi
  829. if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" -o $ARCH = "IA64" -o $ARCH = "PARISC" -o $ARCH = "MIPS" -o $ARCH = "AARCH64" \) ] ; then
  830. pic="yes"
  831. fi
  832. if [ $compiler = GNU -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
  833. if cc_check '' -mpreferred-stack-boundary=6 ; then
  834. CFLAGS="$CFLAGS -mpreferred-stack-boundary=6"
  835. stack_alignment=64
  836. elif cc_check '' -mstack-alignment=64 ; then
  837. CFLAGS="$CFLAGS -mstack-alignment=64"
  838. stack_alignment=64
  839. elif [ $stack_alignment -lt 16 ] ; then
  840. if cc_check '' -mpreferred-stack-boundary=4 ; then
  841. CFLAGS="$CFLAGS -mpreferred-stack-boundary=4"
  842. stack_alignment=16
  843. elif cc_check '' -mstack-alignment=16 ; then
  844. CFLAGS="$CFLAGS -mstack-alignment=16"
  845. stack_alignment=16
  846. fi
  847. fi
  848. elif [ $compiler = ICC -a $ARCH = X86 ]; then
  849. # icc on linux has various degrees of mod16 stack support
  850. if [ $SYS = LINUX ]; then
  851. # >= 12 defaults to a mod16 stack
  852. if cpp_check "" "" "__INTEL_COMPILER >= 1200" ; then
  853. stack_alignment=16
  854. # 11 <= x < 12 is capable of keeping a mod16 stack, but defaults to not doing so.
  855. elif cpp_check "" "" "__INTEL_COMPILER >= 1100" ; then
  856. CFLAGS="$CFLAGS -falign-stack=assume-16-byte"
  857. stack_alignment=16
  858. fi
  859. # < 11 is completely incapable of keeping a mod16 stack
  860. fi
  861. fi
  862. if [ $asm = auto -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
  863. if ! as_check "vmovdqa32 [eax]{k1}{z}, zmm0" ; then
  864. VER="$( ($AS --version || echo no assembler) 2>/dev/null | head -n 1 )"
  865. echo "Found $VER"
  866. echo "Minimum version is nasm-2.13"
  867. echo "If you really want to compile without asm, configure with --disable-asm."
  868. exit 1
  869. fi
  870. cc_check '' '' '__asm__("pabsw %xmm0, %xmm0");' && define HAVE_X86_INLINE_ASM
  871. define HAVE_MMX
  872. fi
  873. if [ $asm = auto -a $ARCH = ARM ] ; then
  874. # set flags so neon is built by default
  875. [ $compiler == CL ] || echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon"
  876. cc_check '' '' '__asm__("add r0, r1, r2");' && define HAVE_ARM_INLINE_ASM
  877. if [ $compiler = CL ] && cpp_check '' '' 'defined(_M_ARM) && _M_ARM >= 7' ; then
  878. define HAVE_ARMV6
  879. define HAVE_ARMV6T2
  880. define HAVE_NEON
  881. elif cc_check '' '' '__asm__("rev ip, ip");' ; then define HAVE_ARMV6
  882. cc_check '' '' '__asm__("movt r0, #0");' && define HAVE_ARMV6T2
  883. cc_check '' '' '__asm__("vadd.i16 q0, q0, q0");' && define HAVE_NEON
  884. ASFLAGS="$ASFLAGS -c"
  885. else
  886. echo "You specified a pre-ARMv6 or Thumb-1 CPU in your CFLAGS."
  887. echo "If you really want to run on such a CPU, configure with --disable-asm."
  888. exit 1
  889. fi
  890. fi
  891. if [ $asm = auto -a $ARCH = AARCH64 ] ; then
  892. if [ $compiler = CL ] && cpp_check '' '' 'defined(_M_ARM64)' ; then
  893. define HAVE_NEON
  894. elif cc_check '' '' '__asm__("cmeq v0.8h, v0.8h, #0");' ; then
  895. define HAVE_NEON
  896. ASFLAGS="$ASFLAGS -c"
  897. else
  898. echo "no NEON support, try adding -mfpu=neon to CFLAGS"
  899. echo "If you really want to run on such a CPU, configure with --disable-asm."
  900. exit 1
  901. fi
  902. fi
  903. if [ $asm = auto -a \( $ARCH = ARM -o $ARCH = AARCH64 \) ] ; then
  904. # check if the assembler supports '.func' (clang 3.5 does not)
  905. as_check ".func test${NL}.endfunc" && define HAVE_AS_FUNC 1
  906. fi
  907. if [ $asm = auto -a $ARCH = MIPS ] ; then
  908. if ! echo $CFLAGS | grep -Eq '(-march|-mmsa|-mno-msa)' ; then
  909. cc_check '' '-mmsa -mfp64 -mhard-float' && CFLAGS="-mmsa -mfp64 -mhard-float $CFLAGS"
  910. fi
  911. if cc_check '' '' '__asm__("addvi.b $w0, $w1, 1");' ; then
  912. define HAVE_MSA
  913. else
  914. echo "You specified a pre-MSA CPU in your CFLAGS."
  915. echo "If you really want to run on such a CPU, configure with --disable-asm."
  916. exit 1
  917. fi
  918. fi
  919. [ $asm = no ] && AS=""
  920. [ "x$AS" = x ] && asm="no" || asm="yes"
  921. define ARCH_$ARCH
  922. define SYS_$SYS
  923. define STACK_ALIGNMENT $stack_alignment
  924. ASFLAGS="$ASFLAGS -DSTACK_ALIGNMENT=$stack_alignment"
  925. # skip endianness check for Intel Compiler and MSVS, as all supported platforms are little. each have flags that will cause the check to fail as well
  926. CPU_ENDIAN="little-endian"
  927. if [ $compiler = GNU ]; then
  928. echo "int i[2] = {0x42494745,0}; double f[2] = {0x1.0656e6469616ep+102,0};" > conftest.c
  929. $CC $CFLAGS conftest.c -c -o conftest.o 2>/dev/null || die "endian test failed"
  930. if (${cross_prefix}strings -a conftest.o | grep -q BIGE) && (${cross_prefix}strings -a conftest.o | grep -q FPendian) ; then
  931. define WORDS_BIGENDIAN
  932. CPU_ENDIAN="big-endian"
  933. elif !(${cross_prefix}strings -a conftest.o | grep -q EGIB && ${cross_prefix}strings -a conftest.o | grep -q naidnePF) ; then
  934. die "endian test failed"
  935. fi
  936. fi
  937. if [ "$cli_libx264" = "system" -a "$shared" != "yes" ] ; then
  938. [ "$static" = "yes" ] && die "Option --system-libx264 can not be used together with --enable-static"
  939. if pkg_check x264 ; then
  940. X264_LIBS="$($PKGCONFIG --libs x264)"
  941. X264_INCLUDE_DIR="${X264_INCLUDE_DIR-$($PKGCONFIG --variable=includedir x264)}"
  942. configure_system_override "$X264_INCLUDE_DIR" || die "Detection of system libx264 configuration failed"
  943. else
  944. die "Can not find system libx264"
  945. fi
  946. fi
  947. # autodetect options that weren't forced nor disabled
  948. libpthread=""
  949. if [ "$SYS" = "WINDOWS" -a "$thread" = "posix" ] ; then
  950. if [ "$gpl" = "no" ] ; then
  951. echo "Warning: pthread-win32 is LGPL and is therefore not supported with --disable-gpl"
  952. thread="no"
  953. elif cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
  954. libpthread="-lpthread"
  955. elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
  956. libpthread="-lpthreadGC2"
  957. elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
  958. libpthread="-lpthreadGC2 -lwsock32"
  959. define PTW32_STATIC_LIB
  960. elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
  961. libpthread="-lpthreadGC2 -lws2_32"
  962. define PTW32_STATIC_LIB
  963. else
  964. thread="no"
  965. fi
  966. elif [ "$thread" != "no" ] ; then
  967. thread="no"
  968. case $SYS in
  969. BEOS)
  970. thread="beos"
  971. define HAVE_BEOSTHREAD
  972. ;;
  973. WINDOWS)
  974. thread="win32"
  975. define HAVE_WIN32THREAD
  976. ;;
  977. QNX)
  978. cc_check pthread.h -lc "pthread_create(0,0,0,0);" && thread="posix" && libpthread="-lc"
  979. ;;
  980. *)
  981. if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
  982. thread="posix"
  983. libpthread="-lpthread"
  984. else
  985. cc_check pthread.h "" "pthread_create(0,0,0,0);" && thread="posix" && libpthread=""
  986. fi
  987. ;;
  988. esac
  989. fi
  990. if [ "$thread" = "posix" ]; then
  991. LDFLAGS="$LDFLAGS $libpthread"
  992. define HAVE_POSIXTHREAD
  993. if [ "$SYS" = "LINUX" ] && cc_check sched.h "-D_GNU_SOURCE -Werror" "cpu_set_t p_aff; return CPU_COUNT(&p_aff);" ; then
  994. define HAVE_CPU_COUNT
  995. fi
  996. fi
  997. [ "$thread" != "no" ] && define HAVE_THREAD
  998. if cc_check 'math.h' '' 'volatile float x = 2; return log2f(x);' ; then
  999. define HAVE_LOG2F
  1000. fi
  1001. if cc_check 'string.h' '' 'strtok_r(0, 0, 0);' ; then
  1002. define HAVE_STRTOK_R
  1003. fi
  1004. if cc_check 'time.h' '' 'clock_gettime(CLOCK_MONOTONIC, 0);' ; then
  1005. define HAVE_CLOCK_GETTIME
  1006. elif cc_check 'time.h' '-lrt' 'clock_gettime(CLOCK_MONOTONIC, 0);' ; then
  1007. define HAVE_CLOCK_GETTIME
  1008. LDFLAGS="$LDFLAGS -lrt"
  1009. fi
  1010. if [ "$SYS" != "WINDOWS" ] && cpp_check "sys/mman.h unistd.h" "" "defined(MAP_PRIVATE)"; then
  1011. define HAVE_MMAP
  1012. fi
  1013. if [ "$SYS" = "LINUX" -a \( "$ARCH" = "X86" -o "$ARCH" = "X86_64" \) ] && cc_check "sys/mman.h" "" "MADV_HUGEPAGE;" ; then
  1014. define HAVE_THP
  1015. fi
  1016. if [ "$cli" = "no" ] ; then
  1017. avs="no"
  1018. lavf="no"
  1019. ffms="no"
  1020. gpac="no"
  1021. lsmash="no"
  1022. mp4="no"
  1023. swscale="no"
  1024. fi
  1025. if [ "$swscale" = "auto" ] ; then
  1026. swscale="no"
  1027. if pkg_check 'libswscale libavutil' ; then
  1028. SWSCALE_LIBS="$SWSCALE_LIBS $($PKGCONFIG --libs libswscale libavutil)"
  1029. SWSCALE_CFLAGS="$SWSCALE_CFLAGS $($PKGCONFIG --cflags libswscale libavutil)"
  1030. fi
  1031. [ -z "$SWSCALE_LIBS" ] && SWSCALE_LIBS="-lswscale -lavutil"
  1032. if cc_check "libswscale/swscale.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "sws_init_context(0,0,0);" ; then
  1033. if cc_check "libavutil/pixdesc.h" "$SWSCALE_CFLAGS $SWSCALE_LIBS" "AVComponentDescriptor x; x.depth = 8;" ; then
  1034. swscale="yes"
  1035. else
  1036. echo "Warning: libswscale is too old"
  1037. fi
  1038. fi
  1039. fi
  1040. if [ "$lavf" = "auto" ] ; then
  1041. lavf="no"
  1042. if pkg_check 'libavformat libavcodec libavutil' ; then
  1043. LAVF_LIBS="$LAVF_LIBS $($PKGCONFIG --libs libavformat libavcodec libavutil)"
  1044. LAVF_CFLAGS="$LAVF_CFLAGS $($PKGCONFIG --cflags libavformat libavcodec libavutil)"
  1045. fi
  1046. if [ -z "$LAVF_LIBS" ] && cc_check '' -lavformat ; then
  1047. LAVF_LIBS="-lavformat"
  1048. for lib in -lavcodec -lavresample -lswresample -lavutil -lbz2 -lz $libpthread -lole32 -luser32 -lws2_32 -lsecur32 ; do
  1049. cc_check "" $lib && LAVF_LIBS="$LAVF_LIBS $lib"
  1050. done
  1051. fi
  1052. if cc_check libavformat/avformat.h "$LAVF_CFLAGS $LAVF_LIBS" "av_register_all();" ; then
  1053. if cc_check libavcodec/avcodec.h "$LAVF_CFLAGS $LAVF_LIBS" "avcodec_send_packet(0,0);" ; then
  1054. lavf="yes"
  1055. else
  1056. echo "Warning: libavformat is too old"
  1057. fi
  1058. fi
  1059. if [ "$lavf" = "yes" -a "$swscale" = "no" ]; then
  1060. echo "Warning: libavformat is not supported without swscale support"
  1061. lavf="no"
  1062. fi
  1063. fi
  1064. if [ "$ffms" = "auto" ] ; then
  1065. ffms_major="2"; ffms_minor="21"; ffms_micro="0"; ffms_bump="0"
  1066. ffms="no"
  1067. if pkg_check ffms2 ; then
  1068. FFMS2_LIBS="$FFMS2_LIBS $($PKGCONFIG --libs ffms2)"
  1069. FFMS2_CFLAGS="$FFMS2_CFLAGS $($PKGCONFIG --cflags ffms2)"
  1070. fi
  1071. [ -z "$FFMS2_LIBS" ] && FFMS2_LIBS="-lffms2"
  1072. if cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS" "FFMS_DestroyVideoSource(0);" ; then
  1073. ffms="yes"
  1074. elif cc_check ffms.h "$FFMS2_CFLAGS $FFMS2_LIBS -lstdc++ $LAVF_LIBS" "FFMS_DestroyVideoSource(0);" ; then
  1075. ffms="yes"
  1076. FFMS2_LIBS="$FFMS2_LIBS -lstdc++ $LAVF_LIBS"
  1077. fi
  1078. error="ffms must be at least version $ffms_major.$ffms_minor.$ffms_micro.$ffms_bump"
  1079. if [ $ffms = "yes" ] && ! cpp_check "ffms.h" "$FFMS2_CFLAGS" "FFMS_VERSION >= (($ffms_major << 24) | ($ffms_minor << 16) | ($ffms_micro << 8) | $ffms_bump)" "$error"; then
  1080. ffms="no"
  1081. echo "Warning: $error"
  1082. fi
  1083. if [ "$ffms" = "yes" -a "$swscale" = "no" ]; then
  1084. echo "Warning: ffms is not supported without swscale support"
  1085. ffms="no"
  1086. fi
  1087. fi
  1088. if [ "$swscale" = "yes" ]; then
  1089. LDFLAGSCLI="$SWSCALE_LIBS $LDFLAGSCLI"
  1090. CFLAGS="$CFLAGS $SWSCALE_CFLAGS"
  1091. define HAVE_SWSCALE
  1092. if [ "$lavf" = "yes" ]; then
  1093. LDFLAGSCLI="$LAVF_LIBS $LDFLAGSCLI"
  1094. CFLAGS="$CFLAGS $LAVF_CFLAGS"
  1095. define HAVE_LAVF
  1096. fi
  1097. if [ "$ffms" = "yes" ]; then
  1098. LDFLAGSCLI="$FFMS2_LIBS $LDFLAGSCLI"
  1099. CFLAGS="$CFLAGS $FFMS2_CFLAGS"
  1100. define HAVE_FFMS
  1101. fi
  1102. fi
  1103. if [ "$lsmash" = "auto" ] ; then
  1104. lsmash="no"
  1105. if pkg_check liblsmash ; then
  1106. LSMASH_LIBS="$LSMASH_LIBS $($PKGCONFIG --libs liblsmash)"
  1107. LSMASH_CFLAGS="$LSMASH_CFLAGS $($PKGCONFIG --cflags liblsmash)"
  1108. fi
  1109. [ -z "$LSMASH_LIBS" ] && LSMASH_LIBS="-llsmash"
  1110. if cc_check lsmash.h "$LSMASH_CFLAGS $LSMASH_LIBS" "lsmash_destroy_root(0);" ; then
  1111. if cpp_check lsmash.h "$LSMASH_CFLAGS" "LSMASH_VERSION_MAJOR > 1 || (LSMASH_VERSION_MAJOR == 1 && LSMASH_VERSION_MINOR >= 5)" ; then
  1112. lsmash="yes"
  1113. else
  1114. echo "Warning: lsmash is too old, update to rev.895 or later"
  1115. fi
  1116. fi
  1117. fi
  1118. if [ "$gpac" = "auto" -a "$lsmash" != "yes" ] ; then
  1119. gpac="no"
  1120. GPAC_LIBS="-lgpac_static"
  1121. cc_check "" -lz && GPAC_LIBS="$GPAC_LIBS -lz"
  1122. if [ "$SYS" = "WINDOWS" ] ; then
  1123. cc_check "" -lws2_32 && GPAC_LIBS="$GPAC_LIBS -lws2_32"
  1124. cc_check "" -lwinmm && GPAC_LIBS="$GPAC_LIBS -lwinmm"
  1125. fi
  1126. if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_close(0);" ; then
  1127. if cc_check gpac/isomedia.h "$GPAC_LIBS" "gf_isom_set_pixel_aspect_ratio(0,0,0,0,0);" ; then
  1128. gpac="yes"
  1129. else
  1130. echo "Warning: gpac is too old, update to 2007-06-21 UTC or later"
  1131. fi
  1132. fi
  1133. fi
  1134. if [ "$lsmash" = "yes" ] ; then
  1135. mp4="lsmash"
  1136. LDFLAGSCLI="$LSMASH_LIBS $LDFLAGSCLI"
  1137. CFLAGS="$CFLAGS $LSMASH_CFLAGS"
  1138. define HAVE_LSMASH
  1139. elif [ "$gpac" = "yes" ] ; then
  1140. mp4="gpac"
  1141. LDFLAGSCLI="$GPAC_LIBS $LDFLAGSCLI"
  1142. define HAVE_GPAC
  1143. fi
  1144. if [ "$avs" = "auto" ] ; then
  1145. avs="no"
  1146. # cygwin can use avisynth if it can use LoadLibrary
  1147. if [ $SYS = WINDOWS ] || ([ $SYS = CYGWIN ] && cc_check windows.h "" "LoadLibraryW(0);") ; then
  1148. avs="avisynth"
  1149. define HAVE_AVS
  1150. define USE_AVXSYNTH 0
  1151. elif [ "$SYS" = "LINUX" -o "$SYS" = "MACOSX" ] ; then
  1152. # AvxSynth currently only supports Linux and OSX
  1153. avs="avxsynth"
  1154. define HAVE_AVS
  1155. define USE_AVXSYNTH 1
  1156. AVS_LIBS="-ldl"
  1157. LDFLAGSCLI="$AVS_LIBS $LDFLAGSCLI"
  1158. fi
  1159. fi
  1160. cc_check "stdint.h" "" "uint32_t test_vec __attribute__ ((vector_size (16))) = {0,1,2,3};" && define HAVE_VECTOREXT
  1161. if [ "$pic" = "yes" ] ; then
  1162. [ "$SYS" != WINDOWS -a "$SYS" != CYGWIN ] && CFLAGS="$CFLAGS -fPIC"
  1163. ASFLAGS="$ASFLAGS -DPIC"
  1164. # resolve textrels in the x86 asm
  1165. cc_check stdio.h "-shared -Wl,-Bsymbolic" && SOFLAGS="$SOFLAGS -Wl,-Bsymbolic"
  1166. [ $SYS = SunOS -a "$ARCH" = "X86" ] && SOFLAGS="$SOFLAGS -mimpure-text"
  1167. fi
  1168. if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
  1169. CFLAGS="$CFLAGS -fomit-frame-pointer"
  1170. fi
  1171. if [ "$strip" = "yes" ]; then
  1172. LDFLAGS="$LDFLAGS -s"
  1173. fi
  1174. if [ "$debug" = "yes" ]; then
  1175. CFLAGS="-O1 -g $CFLAGS"
  1176. RCFLAGS="$RCFLAGS -DDEBUG"
  1177. else
  1178. CFLAGS="-O3 -ffast-math $CFLAGS"
  1179. if [ "$lto" = "auto" ] && [ $compiler = GNU ] && cc_check "" "-flto" ; then
  1180. lto="yes"
  1181. CFLAGS="$CFLAGS -flto"
  1182. LDFLAGS="$LDFLAGS -O3 -flto"
  1183. fi
  1184. fi
  1185. [ "$lto" = "auto" ] && lto="no"
  1186. if cc_check '' -fno-tree-vectorize ; then
  1187. CFLAGS="$CFLAGS -fno-tree-vectorize"
  1188. fi
  1189. if [ $SYS = WINDOWS -a $ARCH = X86 -a $compiler = GNU ] ; then
  1190. # workaround gcc/ld bug with alignment of static variables/arrays that are initialized to zero
  1191. cc_check '' -fno-zero-initialized-in-bss && CFLAGS="$CFLAGS -fno-zero-initialized-in-bss"
  1192. fi
  1193. if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
  1194. define fseek fseeko
  1195. define ftell ftello
  1196. elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
  1197. define fseek fseeko64
  1198. define ftell ftello64
  1199. elif cc_check "stdio.h" "" "_fseeki64(stdin,0,0);" ; then
  1200. define fseek _fseeki64
  1201. define ftell _ftelli64
  1202. fi
  1203. if cc_check '' -Wshadow ; then
  1204. CFLAGS="-Wshadow $CFLAGS"
  1205. fi
  1206. if cc_check '' -Wmaybe-uninitialized ; then
  1207. CFLAGS="-Wno-maybe-uninitialized $CFLAGS"
  1208. fi
  1209. if [ $compiler = ICC -o $compiler = ICL ] ; then
  1210. if cc_check 'extras/intel_dispatcher.h' '' 'x264_intel_dispatcher_override();' ; then
  1211. define HAVE_INTEL_DISPATCHER
  1212. fi
  1213. fi
  1214. if [ "$bit_depth" = "all" ]; then
  1215. define HAVE_BITDEPTH8
  1216. define HAVE_BITDEPTH10
  1217. elif [ "$bit_depth" -eq "8" ]; then
  1218. define HAVE_BITDEPTH8
  1219. elif [ "$bit_depth" -eq "10" ]; then
  1220. define HAVE_BITDEPTH10
  1221. opencl="no"
  1222. fi
  1223. if [ "$chroma_format" != "all" ]; then
  1224. define CHROMA_FORMAT CHROMA_$chroma_format
  1225. fi
  1226. [ $gpl = yes ] && define HAVE_GPL && x264_gpl=1 || x264_gpl=0
  1227. [ $interlaced = yes ] && define HAVE_INTERLACED && x264_interlaced=1 || x264_interlaced=0
  1228. libdl=""
  1229. if [ "$opencl" = "yes" ]; then
  1230. opencl="no"
  1231. # cygwin can use opencl if it can use LoadLibrary
  1232. if [ $SYS = WINDOWS ] || ([ $SYS = CYGWIN ] && cc_check windows.h "" "LoadLibraryW(0);") ; then
  1233. opencl="yes"
  1234. define HAVE_OPENCL "(BIT_DEPTH==8)"
  1235. elif [ "$SYS" = "LINUX" -o "$SYS" = "MACOSX" ] ; then
  1236. opencl="yes"
  1237. define HAVE_OPENCL "(BIT_DEPTH==8)"
  1238. libdl="-ldl"
  1239. fi
  1240. LDFLAGS="$LDFLAGS $libdl"
  1241. fi
  1242. #define undefined vars as 0
  1243. for var in $CONFIG_HAVE; do
  1244. grep -q "HAVE_$var " config.h || define HAVE_$var 0
  1245. done
  1246. # generate exported config file
  1247. [ "$bit_depth" = "all" ] && config_bit_depth="0" || config_bit_depth="$bit_depth"
  1248. [ "$chroma_format" = "all" ] && config_chroma_format="0" || config_chroma_format="X264_CSP_I$chroma_format"
  1249. cat > x264_config.h << EOF
  1250. #define X264_GPL $x264_gpl
  1251. #define X264_INTERLACED $x264_interlaced
  1252. #define X264_BIT_DEPTH $config_bit_depth
  1253. #define X264_CHROMA_FORMAT $config_chroma_format
  1254. EOF
  1255. ${SRCPATH}/version.sh >> x264_config.h
  1256. if [ "$cli_libx264" = "system" ] ; then
  1257. if [ "$shared" = "yes" ]; then
  1258. CLI_LIBX264='$(SONAME)'
  1259. else
  1260. CLI_LIBX264=
  1261. LDFLAGSCLI="$X264_LIBS $LDFLAGSCLI"
  1262. cc_check 'stdint.h x264.h' '' 'x264_encoder_open(0);' || die "System libx264 can't be used for compilation of this version"
  1263. fi
  1264. else
  1265. CLI_LIBX264='$(LIBX264)'
  1266. fi
  1267. DEPMM="${QPRE}MM"
  1268. DEPMT="${QPRE}MT"
  1269. if [ $compiler_style = MS ]; then
  1270. AR="lib.exe -nologo -out:"
  1271. LD="link.exe -out:"
  1272. if [ $compiler = ICL ]; then
  1273. AR="xi$AR"
  1274. LD="xi$LD"
  1275. else
  1276. mslink="$(dirname "$(command -v cl.exe 2>/dev/null)")/link.exe"
  1277. [ -x "$mslink" ] && LD="\"$mslink\" -out:"
  1278. fi
  1279. HAVE_GETOPT_LONG=0
  1280. LDFLAGS="-nologo -incremental:no $(cl_ldflags $LDFLAGS)"
  1281. LDFLAGSCLI="$(cl_ldflags $LDFLAGSCLI)"
  1282. LIBX264=libx264.lib
  1283. RANLIB=
  1284. [ -n "$RC" ] && RCFLAGS="$RCFLAGS -nologo -I. -I\$(SRCPATH)/extras -fo"
  1285. STRIP=
  1286. if [ $debug = yes ]; then
  1287. LDFLAGS="-debug $LDFLAGS"
  1288. CFLAGS="-D_DEBUG $CFLAGS"
  1289. else
  1290. CFLAGS="-DNDEBUG $CFLAGS"
  1291. fi
  1292. else # gcc/icc
  1293. DEPMM="$DEPMM -g0"
  1294. AR="$AR rc "
  1295. LD="$CC -o "
  1296. LIBX264=libx264.a
  1297. [ -n "$RC" ] && RCFLAGS="$RCFLAGS -I. -o "
  1298. fi
  1299. [ $compiler != GNU ] && CFLAGS="$(cc_cflags $CFLAGS)"
  1300. if [ $compiler = ICC -o $compiler = ICL ]; then
  1301. # icc does not define __SSE__ until SSE2 optimization and icl never defines it or _M_IX86_FP
  1302. [ \( $ARCH = X86_64 -o $ARCH = X86 \) -a $asm = yes ] && ! cpp_check "" "" "defined(__SSE__)" && define __SSE__
  1303. PROF_GEN_CC="${QPRE}prof-gen ${QPRE}prof-dir."
  1304. PROF_GEN_LD=
  1305. PROF_USE_CC="${QPRE}prof-use ${QPRE}prof-dir."
  1306. PROF_USE_LD=
  1307. elif [ $compiler = CL ]; then
  1308. # Visual Studio
  1309. # _M_IX86_FP is only defined on x86
  1310. [ $ARCH = X86 ] && cpp_check '' '' '_M_IX86_FP >= 1' && define __SSE__
  1311. [ $ARCH = X86_64 ] && define __SSE__
  1312. # As long as the cli application can't link against the dll, the dll can not be pgo'd.
  1313. # pgds are link flag specific and the -dll flag for creating the dll makes it unshareable with the cli
  1314. PROF_GEN_CC="-GL"
  1315. PROF_GEN_LD="-LTCG:PGINSTRUMENT"
  1316. PROF_USE_CC="-GL"
  1317. PROF_USE_LD="-LTCG:PGOPTIMIZE"
  1318. else
  1319. PROF_GEN_CC="-fprofile-generate"
  1320. PROF_GEN_LD="-fprofile-generate"
  1321. PROF_USE_CC="-fprofile-use"
  1322. PROF_USE_LD="-fprofile-use"
  1323. fi
  1324. # generate config files
  1325. cat > config.mak << EOF
  1326. SRCPATH=$SRCPATH
  1327. prefix=$prefix
  1328. exec_prefix=$exec_prefix
  1329. bindir=$bindir
  1330. libdir=$libdir
  1331. includedir=$includedir
  1332. SYS_ARCH=$ARCH
  1333. SYS=$SYS
  1334. CC=$CC
  1335. CFLAGS=$CFLAGS
  1336. COMPILER=$compiler
  1337. COMPILER_STYLE=$compiler_style
  1338. DEPMM=$DEPMM
  1339. DEPMT=$DEPMT
  1340. LD=$LD
  1341. LDFLAGS=$LDFLAGS
  1342. LIBX264=$LIBX264
  1343. AR=$AR
  1344. RANLIB=$RANLIB
  1345. STRIP=$STRIP
  1346. INSTALL=$INSTALL
  1347. AS=$AS
  1348. ASFLAGS=$ASFLAGS
  1349. RC=$RC
  1350. RCFLAGS=$RCFLAGS
  1351. EXE=$EXE
  1352. HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
  1353. DEVNULL=$DEVNULL
  1354. PROF_GEN_CC=$PROF_GEN_CC
  1355. PROF_GEN_LD=$PROF_GEN_LD
  1356. PROF_USE_CC=$PROF_USE_CC
  1357. PROF_USE_LD=$PROF_USE_LD
  1358. HAVE_OPENCL=$opencl
  1359. EOF
  1360. if [ $compiler_style = MS ]; then
  1361. echo 'CC_O=-Fo$@' >> config.mak
  1362. else
  1363. echo 'CC_O=-o $@' >> config.mak
  1364. fi
  1365. if [ "$cli" = "yes" ]; then
  1366. echo 'default: cli' >> config.mak
  1367. echo 'install: install-cli' >> config.mak
  1368. fi
  1369. if [ "$shared" = "yes" ]; then
  1370. API=$(grep '#define X264_BUILD' < ${SRCPATH}/x264.h | cut -f 3 -d ' ')
  1371. if [ "$SYS" = "WINDOWS" -o "$SYS" = "CYGWIN" ]; then
  1372. echo "SONAME=libx264-$API.dll" >> config.mak
  1373. if [ $compiler_style = MS ]; then
  1374. echo 'IMPLIBNAME=libx264.dll.lib' >> config.mak
  1375. # GNU ld on windows defaults to exporting all global functions if there are no explicit __declspec(dllexport) declarations
  1376. # MSVC link does not act similarly, so it is required to make an export definition out of x264.h and use it at link time
  1377. echo "SOFLAGS=-dll -def:x264.def -implib:\$(IMPLIBNAME) $SOFLAGS" >> config.mak
  1378. echo "EXPORTS" > x264.def
  1379. # export API functions
  1380. grep "^\(int\|void\|x264_t\).*x264" ${SRCPATH}/x264.h | sed -e "s/.*\(x264.*\)(.*/\1/;s/open/open_$API/g" >> x264.def
  1381. # export API variables/data. must be flagged with the DATA keyword
  1382. grep "extern.*x264" ${SRCPATH}/x264.h | sed -e "s/.*\(x264\w*\)\W.*/\1 DATA/;" >> x264.def
  1383. else
  1384. echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
  1385. echo "SOFLAGS=-shared -Wl,--out-implib,\$(IMPLIBNAME) $SOFLAGS" >> config.mak
  1386. fi
  1387. elif [ "$SYS" = "MACOSX" ]; then
  1388. echo "SOSUFFIX=dylib" >> config.mak
  1389. echo "SONAME=libx264.$API.dylib" >> config.mak
  1390. echo "SOFLAGS=-shared -dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name \$(DESTDIR)\$(libdir)/\$(SONAME) $SOFLAGS" >> config.mak
  1391. elif [ "$SYS" = "SunOS" ]; then
  1392. echo "SOSUFFIX=so" >> config.mak
  1393. echo "SONAME=libx264.so.$API" >> config.mak
  1394. echo "SOFLAGS=-shared -Wl,-h,\$(SONAME) $SOFLAGS" >> config.mak
  1395. else
  1396. echo "SOSUFFIX=so" >> config.mak
  1397. echo "SONAME=libx264.so.$API" >> config.mak
  1398. echo "SOFLAGS=-shared -Wl,-soname,\$(SONAME) $SOFLAGS" >> config.mak
  1399. fi
  1400. echo 'default: lib-shared' >> config.mak
  1401. echo 'install: install-lib-shared' >> config.mak
  1402. fi
  1403. if [ "$static" = "yes" ]; then
  1404. echo 'default: lib-static' >> config.mak
  1405. echo 'install: install-lib-static' >> config.mak
  1406. fi
  1407. echo "LDFLAGSCLI = $LDFLAGSCLI" >> config.mak
  1408. echo "CLI_LIBX264 = $CLI_LIBX264" >> config.mak
  1409. cat > x264.pc << EOF
  1410. prefix=$prefix
  1411. exec_prefix=$exec_prefix
  1412. libdir=$libdir
  1413. includedir=$includedir
  1414. Name: x264
  1415. Description: H.264 (MPEG4 AVC) encoder library
  1416. Version: $(grep POINTVER < x264_config.h | sed -e 's/.* "//; s/".*//')
  1417. Libs: -L$libdir -lx264 $([ "$shared" = "yes" ] || echo $libpthread $libm $libdl)
  1418. Libs.private: $([ "$shared" = "yes" ] && echo $libpthread $libm $libdl)
  1419. Cflags: -I$includedir
  1420. EOF
  1421. filters="crop select_every"
  1422. [ $swscale = yes ] && filters="resize $filters"
  1423. cat > conftest.log <<EOF
  1424. platform: $ARCH
  1425. byte order: $CPU_ENDIAN
  1426. system: $SYS
  1427. cli: $cli
  1428. libx264: $cli_libx264
  1429. shared: $shared
  1430. static: $static
  1431. asm: $asm
  1432. interlaced: $interlaced
  1433. avs: $avs
  1434. lavf: $lavf
  1435. ffms: $ffms
  1436. mp4: $mp4
  1437. gpl: $gpl
  1438. thread: $thread
  1439. opencl: $opencl
  1440. filters: $filters
  1441. lto: $lto
  1442. debug: $debug
  1443. gprof: $gprof
  1444. strip: $strip
  1445. PIC: $pic
  1446. bit depth: $bit_depth
  1447. chroma format: $chroma_format
  1448. EOF
  1449. echo >> config.log
  1450. cat conftest.log >> config.log
  1451. cat conftest.log
  1452. [ "$SRCPATH" != "." ] && ln -sf ${SRCPATH}/Makefile ./Makefile
  1453. mkdir -p common/{aarch64,arm,mips,ppc,x86} encoder extras filters/video input output tools
  1454. echo
  1455. echo "You can run 'make' or 'make fprofiled' now."