configure.sh 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567
  1. #!/bin/sh
  2. ##
  3. ## configure.sh
  4. ##
  5. ## This script is sourced by the main configure script and contains
  6. ## utility functions and other common bits that aren't strictly libvpx
  7. ## related.
  8. ##
  9. ## This build system is based in part on the FFmpeg configure script.
  10. ##
  11. #
  12. # Logging / Output Functions
  13. #
  14. die_unknown(){
  15. echo "Unknown option \"$1\"."
  16. echo "See $0 --help for available options."
  17. clean_temp_files
  18. exit 1
  19. }
  20. die() {
  21. echo "$@"
  22. echo
  23. echo "Configuration failed. This could reflect a misconfiguration of your"
  24. echo "toolchains, improper options selected, or another problem. If you"
  25. echo "don't see any useful error messages above, the next step is to look"
  26. echo "at the configure error log file ($logfile) to determine what"
  27. echo "configure was trying to do when it died."
  28. clean_temp_files
  29. exit 1
  30. }
  31. log(){
  32. echo "$@" >>$logfile
  33. }
  34. log_file(){
  35. log BEGIN $1
  36. cat -n $1 >>$logfile
  37. log END $1
  38. }
  39. log_echo() {
  40. echo "$@"
  41. log "$@"
  42. }
  43. fwrite () {
  44. outfile=$1
  45. shift
  46. echo "$@" >> ${outfile}
  47. }
  48. show_help_pre(){
  49. for opt in ${CMDLINE_SELECT}; do
  50. opt2=`echo $opt | sed -e 's;_;-;g'`
  51. if enabled $opt; then
  52. eval "toggle_${opt}=\"--disable-${opt2}\""
  53. else
  54. eval "toggle_${opt}=\"--enable-${opt2} \""
  55. fi
  56. done
  57. cat <<EOF
  58. Usage: configure [options]
  59. Options:
  60. Build options:
  61. --help print this message
  62. --log=yes|no|FILE file configure log is written to [config.log]
  63. --target=TARGET target platform tuple [generic-gnu]
  64. --cpu=CPU optimize for a specific cpu rather than a family
  65. --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
  66. --extra-cxxflags=ECXXFLAGS add ECXXFLAGS to CXXFLAGS [$CXXFLAGS]
  67. ${toggle_extra_warnings} emit harmless warnings (always non-fatal)
  68. ${toggle_werror} treat warnings as errors, if possible
  69. (not available with all compilers)
  70. ${toggle_optimizations} turn on/off compiler optimization flags
  71. ${toggle_pic} turn on/off Position Independent Code
  72. ${toggle_ccache} turn on/off compiler cache
  73. ${toggle_debug} enable/disable debug mode
  74. ${toggle_gprof} enable/disable gprof profiling instrumentation
  75. ${toggle_gcov} enable/disable gcov coverage instrumentation
  76. ${toggle_thumb} enable/disable building arm assembly in thumb mode
  77. ${toggle_dependency_tracking}
  78. disable to speed up one-time build
  79. Install options:
  80. ${toggle_install_docs} control whether docs are installed
  81. ${toggle_install_bins} control whether binaries are installed
  82. ${toggle_install_libs} control whether libraries are installed
  83. ${toggle_install_srcs} control whether sources are installed
  84. EOF
  85. }
  86. show_help_post(){
  87. cat <<EOF
  88. NOTES:
  89. Object files are built at the place where configure is launched.
  90. All boolean options can be negated. The default value is the opposite
  91. of that shown above. If the option --disable-foo is listed, then
  92. the default value for foo is enabled.
  93. Supported targets:
  94. EOF
  95. show_targets ${all_platforms}
  96. echo
  97. exit 1
  98. }
  99. show_targets() {
  100. while [ -n "$*" ]; do
  101. if [ "${1%%-*}" = "${2%%-*}" ]; then
  102. if [ "${2%%-*}" = "${3%%-*}" ]; then
  103. printf " %-24s %-24s %-24s\n" "$1" "$2" "$3"
  104. shift; shift; shift
  105. else
  106. printf " %-24s %-24s\n" "$1" "$2"
  107. shift; shift
  108. fi
  109. else
  110. printf " %-24s\n" "$1"
  111. shift
  112. fi
  113. done
  114. }
  115. show_help() {
  116. show_help_pre
  117. show_help_post
  118. }
  119. #
  120. # List Processing Functions
  121. #
  122. set_all(){
  123. value=$1
  124. shift
  125. for var in $*; do
  126. eval $var=$value
  127. done
  128. }
  129. is_in(){
  130. value=$1
  131. shift
  132. for var in $*; do
  133. [ $var = $value ] && return 0
  134. done
  135. return 1
  136. }
  137. add_cflags() {
  138. CFLAGS="${CFLAGS} $@"
  139. CXXFLAGS="${CXXFLAGS} $@"
  140. }
  141. add_cflags_only() {
  142. CFLAGS="${CFLAGS} $@"
  143. }
  144. add_cxxflags_only() {
  145. CXXFLAGS="${CXXFLAGS} $@"
  146. }
  147. add_ldflags() {
  148. LDFLAGS="${LDFLAGS} $@"
  149. }
  150. add_asflags() {
  151. ASFLAGS="${ASFLAGS} $@"
  152. }
  153. add_extralibs() {
  154. extralibs="${extralibs} $@"
  155. }
  156. #
  157. # Boolean Manipulation Functions
  158. #
  159. enable_feature(){
  160. set_all yes $*
  161. }
  162. disable_feature(){
  163. set_all no $*
  164. }
  165. enabled(){
  166. eval test "x\$$1" = "xyes"
  167. }
  168. disabled(){
  169. eval test "x\$$1" = "xno"
  170. }
  171. enable_codec(){
  172. enabled "${1}" || echo " enabling ${1}"
  173. enable_feature "${1}"
  174. is_in "${1}" vp8 vp9 && enable_feature "${1}_encoder" "${1}_decoder"
  175. }
  176. disable_codec(){
  177. disabled "${1}" || echo " disabling ${1}"
  178. disable_feature "${1}"
  179. is_in "${1}" vp8 vp9 && disable_feature "${1}_encoder" "${1}_decoder"
  180. }
  181. # Iterates through positional parameters, checks to confirm the parameter has
  182. # not been explicitly (force) disabled, and enables the setting controlled by
  183. # the parameter when the setting is not disabled.
  184. # Note: Does NOT alter RTCD generation options ($RTCD_OPTIONS).
  185. soft_enable() {
  186. for var in $*; do
  187. if ! disabled $var; then
  188. enabled $var || log_echo " enabling $var"
  189. enable_feature $var
  190. fi
  191. done
  192. }
  193. # Iterates through positional parameters, checks to confirm the parameter has
  194. # not been explicitly (force) enabled, and disables the setting controlled by
  195. # the parameter when the setting is not enabled.
  196. # Note: Does NOT alter RTCD generation options ($RTCD_OPTIONS).
  197. soft_disable() {
  198. for var in $*; do
  199. if ! enabled $var; then
  200. disabled $var || log_echo " disabling $var"
  201. disable_feature $var
  202. fi
  203. done
  204. }
  205. #
  206. # Text Processing Functions
  207. #
  208. toupper(){
  209. echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  210. }
  211. tolower(){
  212. echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
  213. }
  214. #
  215. # Temporary File Functions
  216. #
  217. source_path=${0%/*}
  218. enable_feature source_path_used
  219. if [ -z "$source_path" ] || [ "$source_path" = "." ]; then
  220. source_path="`pwd`"
  221. disable_feature source_path_used
  222. fi
  223. if test ! -z "$TMPDIR" ; then
  224. TMPDIRx="${TMPDIR}"
  225. elif test ! -z "$TEMPDIR" ; then
  226. TMPDIRx="${TEMPDIR}"
  227. else
  228. TMPDIRx="/tmp"
  229. fi
  230. RAND=$(awk 'BEGIN { srand(); printf "%d\n",(rand() * 32768)}')
  231. TMP_H="${TMPDIRx}/vpx-conf-$$-${RAND}.h"
  232. TMP_C="${TMPDIRx}/vpx-conf-$$-${RAND}.c"
  233. TMP_CC="${TMPDIRx}/vpx-conf-$$-${RAND}.cc"
  234. TMP_O="${TMPDIRx}/vpx-conf-$$-${RAND}.o"
  235. TMP_X="${TMPDIRx}/vpx-conf-$$-${RAND}.x"
  236. TMP_ASM="${TMPDIRx}/vpx-conf-$$-${RAND}.asm"
  237. clean_temp_files() {
  238. rm -f ${TMP_C} ${TMP_CC} ${TMP_H} ${TMP_O} ${TMP_X} ${TMP_ASM}
  239. enabled gcov && rm -f ${TMP_C%.c}.gcno ${TMP_CC%.cc}.gcno
  240. }
  241. #
  242. # Toolchain Check Functions
  243. #
  244. check_cmd() {
  245. enabled external_build && return
  246. log "$@"
  247. "$@" >>${logfile} 2>&1
  248. }
  249. check_cc() {
  250. log check_cc "$@"
  251. cat >${TMP_C}
  252. log_file ${TMP_C}
  253. check_cmd ${CC} ${CFLAGS} "$@" -c -o ${TMP_O} ${TMP_C}
  254. }
  255. check_cxx() {
  256. log check_cxx "$@"
  257. cat >${TMP_CC}
  258. log_file ${TMP_CC}
  259. check_cmd ${CXX} ${CXXFLAGS} "$@" -c -o ${TMP_O} ${TMP_CC}
  260. }
  261. check_cpp() {
  262. log check_cpp "$@"
  263. cat > ${TMP_C}
  264. log_file ${TMP_C}
  265. check_cmd ${CC} ${CFLAGS} "$@" -E -o ${TMP_O} ${TMP_C}
  266. }
  267. check_ld() {
  268. log check_ld "$@"
  269. check_cc $@ \
  270. && check_cmd ${LD} ${LDFLAGS} "$@" -o ${TMP_X} ${TMP_O} ${extralibs}
  271. }
  272. check_header(){
  273. log check_header "$@"
  274. header=$1
  275. shift
  276. var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
  277. disable_feature $var
  278. check_cpp "$@" <<EOF && enable_feature $var
  279. #include "$header"
  280. int x;
  281. EOF
  282. }
  283. check_cflags() {
  284. log check_cflags "$@"
  285. check_cc -Werror "$@" <<EOF
  286. int x;
  287. EOF
  288. }
  289. check_cxxflags() {
  290. log check_cxxflags "$@"
  291. # Catch CFLAGS that trigger CXX warnings
  292. case "$CXX" in
  293. *c++-analyzer|*clang++|*g++*)
  294. check_cxx -Werror "$@" <<EOF
  295. int x;
  296. EOF
  297. ;;
  298. *)
  299. check_cxx -Werror "$@" <<EOF
  300. int x;
  301. EOF
  302. ;;
  303. esac
  304. }
  305. check_add_cflags() {
  306. check_cxxflags "$@" && add_cxxflags_only "$@"
  307. check_cflags "$@" && add_cflags_only "$@"
  308. }
  309. check_add_cxxflags() {
  310. check_cxxflags "$@" && add_cxxflags_only "$@"
  311. }
  312. check_add_asflags() {
  313. log add_asflags "$@"
  314. add_asflags "$@"
  315. }
  316. check_add_ldflags() {
  317. log add_ldflags "$@"
  318. add_ldflags "$@"
  319. }
  320. check_asm_align() {
  321. log check_asm_align "$@"
  322. cat >${TMP_ASM} <<EOF
  323. section .rodata
  324. align 16
  325. EOF
  326. log_file ${TMP_ASM}
  327. check_cmd ${AS} ${ASFLAGS} -o ${TMP_O} ${TMP_ASM}
  328. readelf -WS ${TMP_O} >${TMP_X}
  329. log_file ${TMP_X}
  330. if ! grep -q '\.rodata .* 16$' ${TMP_X}; then
  331. die "${AS} ${ASFLAGS} does not support section alignment (nasm <=2.08?)"
  332. fi
  333. }
  334. # tests for -m$1 toggling the feature given in $2. If $2 is empty $1 is used.
  335. check_gcc_machine_option() {
  336. opt="$1"
  337. feature="$2"
  338. [ -n "$feature" ] || feature="$opt"
  339. if enabled gcc && ! disabled "$feature" && ! check_cflags "-m$opt"; then
  340. RTCD_OPTIONS="${RTCD_OPTIONS}--disable-$feature "
  341. else
  342. soft_enable "$feature"
  343. fi
  344. }
  345. write_common_config_banner() {
  346. print_webm_license config.mk "##" ""
  347. echo '# This file automatically generated by configure. Do not edit!' >> config.mk
  348. echo "TOOLCHAIN := ${toolchain}" >> config.mk
  349. case ${toolchain} in
  350. *-linux-rvct)
  351. echo "ALT_LIBC := ${alt_libc}" >> config.mk
  352. ;;
  353. esac
  354. }
  355. write_common_config_targets() {
  356. for t in ${all_targets}; do
  357. if enabled ${t}; then
  358. if enabled child; then
  359. fwrite config.mk "ALL_TARGETS += ${t}-${toolchain}"
  360. else
  361. fwrite config.mk "ALL_TARGETS += ${t}"
  362. fi
  363. fi
  364. true;
  365. done
  366. true
  367. }
  368. write_common_target_config_mk() {
  369. saved_CC="${CC}"
  370. saved_CXX="${CXX}"
  371. enabled ccache && CC="ccache ${CC}"
  372. enabled ccache && CXX="ccache ${CXX}"
  373. print_webm_license $1 "##" ""
  374. cat >> $1 << EOF
  375. # This file automatically generated by configure. Do not edit!
  376. SRC_PATH="$source_path"
  377. SRC_PATH_BARE=$source_path
  378. BUILD_PFX=${BUILD_PFX}
  379. TOOLCHAIN=${toolchain}
  380. ASM_CONVERSION=${asm_conversion_cmd:-${source_path}/build/make/ads2gas.pl}
  381. GEN_VCPROJ=${gen_vcproj_cmd}
  382. MSVS_ARCH_DIR=${msvs_arch_dir}
  383. CC=${CC}
  384. CXX=${CXX}
  385. AR=${AR}
  386. LD=${LD}
  387. AS=${AS}
  388. STRIP=${STRIP}
  389. NM=${NM}
  390. CFLAGS = ${CFLAGS}
  391. CXXFLAGS = ${CXXFLAGS}
  392. ARFLAGS = -crs\$(if \$(quiet),,v)
  393. LDFLAGS = ${LDFLAGS}
  394. ASFLAGS = ${ASFLAGS}
  395. extralibs = ${extralibs}
  396. AS_SFX = ${AS_SFX:-.asm}
  397. EXE_SFX = ${EXE_SFX}
  398. VCPROJ_SFX = ${VCPROJ_SFX}
  399. RTCD_OPTIONS = ${RTCD_OPTIONS}
  400. EOF
  401. if enabled rvct; then cat >> $1 << EOF
  402. fmt_deps = sed -e 's;^__image.axf;\${@:.d=.o} \$@;' #hide
  403. EOF
  404. else cat >> $1 << EOF
  405. fmt_deps = sed -e 's;^\([a-zA-Z0-9_]*\)\.o;\${@:.d=.o} \$@;'
  406. EOF
  407. fi
  408. print_config_mk ARCH "${1}" ${ARCH_LIST}
  409. print_config_mk HAVE "${1}" ${HAVE_LIST}
  410. print_config_mk CONFIG "${1}" ${CONFIG_LIST}
  411. print_config_mk HAVE "${1}" gnu_strip
  412. enabled msvs && echo "CONFIG_VS_VERSION=${vs_version}" >> "${1}"
  413. CC="${saved_CC}"
  414. CXX="${saved_CXX}"
  415. }
  416. write_common_target_config_h() {
  417. print_webm_license ${TMP_H} "/*" " */"
  418. cat >> ${TMP_H} << EOF
  419. /* This file automatically generated by configure. Do not edit! */
  420. #ifndef VPX_CONFIG_H
  421. #define VPX_CONFIG_H
  422. #define RESTRICT ${RESTRICT}
  423. #define INLINE ${INLINE}
  424. EOF
  425. print_config_h ARCH "${TMP_H}" ${ARCH_LIST}
  426. print_config_h HAVE "${TMP_H}" ${HAVE_LIST}
  427. print_config_h CONFIG "${TMP_H}" ${CONFIG_LIST}
  428. print_config_vars_h "${TMP_H}" ${VAR_LIST}
  429. echo "#endif /* VPX_CONFIG_H */" >> ${TMP_H}
  430. mkdir -p `dirname "$1"`
  431. cmp "$1" ${TMP_H} >/dev/null 2>&1 || mv ${TMP_H} "$1"
  432. }
  433. process_common_cmdline() {
  434. for opt in "$@"; do
  435. optval="${opt#*=}"
  436. case "$opt" in
  437. --child)
  438. enable_feature child
  439. ;;
  440. --log*)
  441. logging="$optval"
  442. if ! disabled logging ; then
  443. enabled logging || logfile="$logging"
  444. else
  445. logfile=/dev/null
  446. fi
  447. ;;
  448. --target=*)
  449. toolchain="${toolchain:-${optval}}"
  450. ;;
  451. --force-target=*)
  452. toolchain="${toolchain:-${optval}}"
  453. enable_feature force_toolchain
  454. ;;
  455. --cpu=*)
  456. tune_cpu="$optval"
  457. ;;
  458. --extra-cflags=*)
  459. extra_cflags="${optval}"
  460. ;;
  461. --extra-cxxflags=*)
  462. extra_cxxflags="${optval}"
  463. ;;
  464. --enable-?*|--disable-?*)
  465. eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
  466. if is_in ${option} ${ARCH_EXT_LIST}; then
  467. [ $action = "disable" ] && RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${option} "
  468. elif [ $action = "disable" ] && ! disabled $option ; then
  469. is_in ${option} ${CMDLINE_SELECT} || die_unknown $opt
  470. log_echo " disabling $option"
  471. elif [ $action = "enable" ] && ! enabled $option ; then
  472. is_in ${option} ${CMDLINE_SELECT} || die_unknown $opt
  473. log_echo " enabling $option"
  474. fi
  475. ${action}_feature $option
  476. ;;
  477. --require-?*)
  478. eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
  479. if is_in ${option} ${ARCH_EXT_LIST}; then
  480. RTCD_OPTIONS="${RTCD_OPTIONS}${opt} "
  481. else
  482. die_unknown $opt
  483. fi
  484. ;;
  485. --force-enable-?*|--force-disable-?*)
  486. eval `echo "$opt" | sed 's/--force-/action=/;s/-/ option=/;s/-/_/g'`
  487. ${action}_feature $option
  488. ;;
  489. --libc=*)
  490. [ -d "${optval}" ] || die "Not a directory: ${optval}"
  491. disable_feature builtin_libc
  492. alt_libc="${optval}"
  493. ;;
  494. --as=*)
  495. [ "${optval}" = yasm ] || [ "${optval}" = nasm ] \
  496. || [ "${optval}" = auto ] \
  497. || die "Must be yasm, nasm or auto: ${optval}"
  498. alt_as="${optval}"
  499. ;;
  500. --size-limit=*)
  501. w="${optval%%x*}"
  502. h="${optval##*x}"
  503. VAR_LIST="DECODE_WIDTH_LIMIT ${w} DECODE_HEIGHT_LIMIT ${h}"
  504. [ ${w} -gt 0 ] && [ ${h} -gt 0 ] || die "Invalid size-limit: too small."
  505. [ ${w} -lt 65536 ] && [ ${h} -lt 65536 ] \
  506. || die "Invalid size-limit: too big."
  507. enable_feature size_limit
  508. ;;
  509. --prefix=*)
  510. prefix="${optval}"
  511. ;;
  512. --libdir=*)
  513. libdir="${optval}"
  514. ;;
  515. --sdk-path=*)
  516. [ -d "${optval}" ] || die "Not a directory: ${optval}"
  517. sdk_path="${optval}"
  518. ;;
  519. --libc|--as|--prefix|--libdir|--sdk-path)
  520. die "Option ${opt} requires argument"
  521. ;;
  522. --help|-h)
  523. show_help
  524. ;;
  525. *)
  526. die_unknown $opt
  527. ;;
  528. esac
  529. done
  530. }
  531. process_cmdline() {
  532. for opt do
  533. optval="${opt#*=}"
  534. case "$opt" in
  535. *)
  536. process_common_cmdline $opt
  537. ;;
  538. esac
  539. done
  540. }
  541. post_process_common_cmdline() {
  542. prefix="${prefix:-/usr/local}"
  543. prefix="${prefix%/}"
  544. libdir="${libdir:-${prefix}/lib}"
  545. libdir="${libdir%/}"
  546. if [ "${libdir#${prefix}}" = "${libdir}" ]; then
  547. die "Libdir ${libdir} must be a subdirectory of ${prefix}"
  548. fi
  549. }
  550. post_process_cmdline() {
  551. true;
  552. }
  553. setup_gnu_toolchain() {
  554. CC=${CC:-${CROSS}gcc}
  555. CXX=${CXX:-${CROSS}g++}
  556. AR=${AR:-${CROSS}ar}
  557. LD=${LD:-${CROSS}${link_with_cc:-ld}}
  558. AS=${AS:-${CROSS}as}
  559. STRIP=${STRIP:-${CROSS}strip}
  560. NM=${NM:-${CROSS}nm}
  561. AS_SFX=.S
  562. EXE_SFX=
  563. }
  564. # Reliably find the newest available Darwin SDKs. (Older versions of
  565. # xcrun don't support --show-sdk-path.)
  566. show_darwin_sdk_path() {
  567. xcrun --sdk $1 --show-sdk-path 2>/dev/null ||
  568. xcodebuild -sdk $1 -version Path 2>/dev/null
  569. }
  570. # Print the major version number of the Darwin SDK specified by $1.
  571. show_darwin_sdk_major_version() {
  572. xcrun --sdk $1 --show-sdk-version 2>/dev/null | cut -d. -f1
  573. }
  574. # Print the Xcode version.
  575. show_xcode_version() {
  576. xcodebuild -version | head -n1 | cut -d' ' -f2
  577. }
  578. # Fails when Xcode version is less than 6.3.
  579. check_xcode_minimum_version() {
  580. xcode_major=$(show_xcode_version | cut -f1 -d.)
  581. xcode_minor=$(show_xcode_version | cut -f2 -d.)
  582. xcode_min_major=6
  583. xcode_min_minor=3
  584. if [ ${xcode_major} -lt ${xcode_min_major} ]; then
  585. return 1
  586. fi
  587. if [ ${xcode_major} -eq ${xcode_min_major} ] \
  588. && [ ${xcode_minor} -lt ${xcode_min_minor} ]; then
  589. return 1
  590. fi
  591. }
  592. process_common_toolchain() {
  593. if [ -z "$toolchain" ]; then
  594. gcctarget="${CHOST:-$(gcc -dumpmachine 2> /dev/null)}"
  595. # detect tgt_isa
  596. case "$gcctarget" in
  597. aarch64*)
  598. tgt_isa=arm64
  599. ;;
  600. armv7*-hardfloat* | armv7*-gnueabihf | arm-*-gnueabihf)
  601. tgt_isa=armv7
  602. float_abi=hard
  603. ;;
  604. armv7*)
  605. tgt_isa=armv7
  606. float_abi=softfp
  607. ;;
  608. *x86_64*|*amd64*)
  609. tgt_isa=x86_64
  610. ;;
  611. *i[3456]86*)
  612. tgt_isa=x86
  613. ;;
  614. *sparc*)
  615. tgt_isa=sparc
  616. ;;
  617. power*64*-*)
  618. tgt_isa=ppc64
  619. ;;
  620. power*)
  621. tgt_isa=ppc
  622. ;;
  623. *mips64el*)
  624. tgt_isa=mips64
  625. ;;
  626. *mips32el*)
  627. tgt_isa=mips32
  628. ;;
  629. esac
  630. # detect tgt_os
  631. case "$gcctarget" in
  632. *darwin10*)
  633. tgt_isa=x86_64
  634. tgt_os=darwin10
  635. ;;
  636. *darwin11*)
  637. tgt_isa=x86_64
  638. tgt_os=darwin11
  639. ;;
  640. *darwin12*)
  641. tgt_isa=x86_64
  642. tgt_os=darwin12
  643. ;;
  644. *darwin13*)
  645. tgt_isa=x86_64
  646. tgt_os=darwin13
  647. ;;
  648. *darwin14*)
  649. tgt_isa=x86_64
  650. tgt_os=darwin14
  651. ;;
  652. *darwin15*)
  653. tgt_isa=x86_64
  654. tgt_os=darwin15
  655. ;;
  656. *darwin16*)
  657. tgt_isa=x86_64
  658. tgt_os=darwin16
  659. ;;
  660. x86_64*mingw32*)
  661. tgt_os=win64
  662. ;;
  663. x86_64*cygwin*)
  664. tgt_os=win64
  665. ;;
  666. *mingw32*|*cygwin*)
  667. [ -z "$tgt_isa" ] && tgt_isa=x86
  668. tgt_os=win32
  669. ;;
  670. *linux*|*bsd*)
  671. tgt_os=linux
  672. ;;
  673. *solaris2.10)
  674. tgt_os=solaris
  675. ;;
  676. *os2*)
  677. tgt_os=os2
  678. ;;
  679. esac
  680. if [ -n "$tgt_isa" ] && [ -n "$tgt_os" ]; then
  681. toolchain=${tgt_isa}-${tgt_os}-gcc
  682. fi
  683. fi
  684. toolchain=${toolchain:-generic-gnu}
  685. is_in ${toolchain} ${all_platforms} || enabled force_toolchain \
  686. || die "Unrecognized toolchain '${toolchain}'"
  687. enabled child || log_echo "Configuring for target '${toolchain}'"
  688. #
  689. # Set up toolchain variables
  690. #
  691. tgt_isa=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $1}')
  692. tgt_os=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $2}')
  693. tgt_cc=$(echo ${toolchain} | awk 'BEGIN{FS="-"}{print $3}')
  694. # Mark the specific ISA requested as enabled
  695. soft_enable ${tgt_isa}
  696. enable_feature ${tgt_os}
  697. enable_feature ${tgt_cc}
  698. # Enable the architecture family
  699. case ${tgt_isa} in
  700. arm*)
  701. enable_feature arm
  702. ;;
  703. mips*)
  704. enable_feature mips
  705. ;;
  706. ppc*)
  707. enable_feature ppc
  708. ;;
  709. esac
  710. # PIC is probably what we want when building shared libs
  711. enabled shared && soft_enable pic
  712. # Minimum iOS version for all target platforms (darwin and iphonesimulator).
  713. # Shared library framework builds are only possible on iOS 8 and later.
  714. if enabled shared; then
  715. IOS_VERSION_OPTIONS="--enable-shared"
  716. IOS_VERSION_MIN="8.0"
  717. else
  718. IOS_VERSION_OPTIONS=""
  719. IOS_VERSION_MIN="6.0"
  720. fi
  721. # Handle darwin variants. Newer SDKs allow targeting older
  722. # platforms, so use the newest one available.
  723. case ${toolchain} in
  724. arm*-darwin*)
  725. add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
  726. iphoneos_sdk_dir="$(show_darwin_sdk_path iphoneos)"
  727. if [ -d "${iphoneos_sdk_dir}" ]; then
  728. add_cflags "-isysroot ${iphoneos_sdk_dir}"
  729. add_ldflags "-isysroot ${iphoneos_sdk_dir}"
  730. fi
  731. ;;
  732. x86*-darwin*)
  733. osx_sdk_dir="$(show_darwin_sdk_path macosx)"
  734. if [ -d "${osx_sdk_dir}" ]; then
  735. add_cflags "-isysroot ${osx_sdk_dir}"
  736. add_ldflags "-isysroot ${osx_sdk_dir}"
  737. fi
  738. ;;
  739. esac
  740. case ${toolchain} in
  741. *-darwin8-*)
  742. add_cflags "-mmacosx-version-min=10.4"
  743. add_ldflags "-mmacosx-version-min=10.4"
  744. ;;
  745. *-darwin9-*)
  746. add_cflags "-mmacosx-version-min=10.5"
  747. add_ldflags "-mmacosx-version-min=10.5"
  748. ;;
  749. *-darwin10-*)
  750. add_cflags "-mmacosx-version-min=10.6"
  751. add_ldflags "-mmacosx-version-min=10.6"
  752. ;;
  753. *-darwin11-*)
  754. add_cflags "-mmacosx-version-min=10.7"
  755. add_ldflags "-mmacosx-version-min=10.7"
  756. ;;
  757. *-darwin12-*)
  758. add_cflags "-mmacosx-version-min=10.8"
  759. add_ldflags "-mmacosx-version-min=10.8"
  760. ;;
  761. *-darwin13-*)
  762. add_cflags "-mmacosx-version-min=10.9"
  763. add_ldflags "-mmacosx-version-min=10.9"
  764. ;;
  765. *-darwin14-*)
  766. add_cflags "-mmacosx-version-min=10.10"
  767. add_ldflags "-mmacosx-version-min=10.10"
  768. ;;
  769. *-darwin15-*)
  770. add_cflags "-mmacosx-version-min=10.11"
  771. add_ldflags "-mmacosx-version-min=10.11"
  772. ;;
  773. *-darwin16-*)
  774. add_cflags "-mmacosx-version-min=10.12"
  775. add_ldflags "-mmacosx-version-min=10.12"
  776. ;;
  777. *-iphonesimulator-*)
  778. add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
  779. add_ldflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
  780. iossim_sdk_dir="$(show_darwin_sdk_path iphonesimulator)"
  781. if [ -d "${iossim_sdk_dir}" ]; then
  782. add_cflags "-isysroot ${iossim_sdk_dir}"
  783. add_ldflags "-isysroot ${iossim_sdk_dir}"
  784. fi
  785. ;;
  786. esac
  787. # Handle Solaris variants. Solaris 10 needs -lposix4
  788. case ${toolchain} in
  789. sparc-solaris-*)
  790. add_extralibs -lposix4
  791. ;;
  792. *-solaris-*)
  793. add_extralibs -lposix4
  794. ;;
  795. esac
  796. # Process ARM architecture variants
  797. case ${toolchain} in
  798. arm*)
  799. # on arm, isa versions are supersets
  800. case ${tgt_isa} in
  801. arm64|armv8)
  802. soft_enable neon
  803. ;;
  804. armv7|armv7s)
  805. soft_enable neon
  806. # Only enable neon_asm when neon is also enabled.
  807. enabled neon && soft_enable neon_asm
  808. # If someone tries to force it through, die.
  809. if disabled neon && enabled neon_asm; then
  810. die "Disabling neon while keeping neon-asm is not supported"
  811. fi
  812. ;;
  813. esac
  814. asm_conversion_cmd="cat"
  815. case ${tgt_cc} in
  816. gcc)
  817. link_with_cc=gcc
  818. setup_gnu_toolchain
  819. arch_int=${tgt_isa##armv}
  820. arch_int=${arch_int%%te}
  821. check_add_asflags --defsym ARCHITECTURE=${arch_int}
  822. tune_cflags="-mtune="
  823. if [ ${tgt_isa} = "armv7" ] || [ ${tgt_isa} = "armv7s" ]; then
  824. if [ -z "${float_abi}" ]; then
  825. check_cpp <<EOF && float_abi=hard || float_abi=softfp
  826. #ifndef __ARM_PCS_VFP
  827. #error "not hardfp"
  828. #endif
  829. EOF
  830. fi
  831. check_add_cflags -march=armv7-a -mfloat-abi=${float_abi}
  832. check_add_asflags -march=armv7-a -mfloat-abi=${float_abi}
  833. if enabled neon || enabled neon_asm; then
  834. check_add_cflags -mfpu=neon #-ftree-vectorize
  835. check_add_asflags -mfpu=neon
  836. fi
  837. elif [ ${tgt_isa} = "arm64" ] || [ ${tgt_isa} = "armv8" ]; then
  838. check_add_cflags -march=armv8-a
  839. check_add_asflags -march=armv8-a
  840. else
  841. check_add_cflags -march=${tgt_isa}
  842. check_add_asflags -march=${tgt_isa}
  843. fi
  844. enabled debug && add_asflags -g
  845. asm_conversion_cmd="${source_path}/build/make/ads2gas.pl"
  846. if enabled thumb; then
  847. asm_conversion_cmd="$asm_conversion_cmd -thumb"
  848. check_add_cflags -mthumb
  849. check_add_asflags -mthumb -mimplicit-it=always
  850. fi
  851. ;;
  852. vs*)
  853. asm_conversion_cmd="${source_path}/build/make/ads2armasm_ms.pl"
  854. AS_SFX=.S
  855. msvs_arch_dir=arm-msvs
  856. disable_feature multithread
  857. disable_feature unit_tests
  858. vs_version=${tgt_cc##vs}
  859. if [ $vs_version -ge 12 ]; then
  860. # MSVC 2013 doesn't allow doing plain .exe projects for ARM,
  861. # only "AppContainerApplication" which requires an AppxManifest.
  862. # Therefore disable the examples, just build the library.
  863. disable_feature examples
  864. disable_feature tools
  865. fi
  866. ;;
  867. rvct)
  868. CC=armcc
  869. AR=armar
  870. AS=armasm
  871. LD="${source_path}/build/make/armlink_adapter.sh"
  872. STRIP=arm-none-linux-gnueabi-strip
  873. NM=arm-none-linux-gnueabi-nm
  874. tune_cflags="--cpu="
  875. tune_asflags="--cpu="
  876. if [ -z "${tune_cpu}" ]; then
  877. if [ ${tgt_isa} = "armv7" ]; then
  878. if enabled neon || enabled neon_asm
  879. then
  880. check_add_cflags --fpu=softvfp+vfpv3
  881. check_add_asflags --fpu=softvfp+vfpv3
  882. fi
  883. check_add_cflags --cpu=Cortex-A8
  884. check_add_asflags --cpu=Cortex-A8
  885. else
  886. check_add_cflags --cpu=${tgt_isa##armv}
  887. check_add_asflags --cpu=${tgt_isa##armv}
  888. fi
  889. fi
  890. arch_int=${tgt_isa##armv}
  891. arch_int=${arch_int%%te}
  892. check_add_asflags --pd "\"ARCHITECTURE SETA ${arch_int}\""
  893. enabled debug && add_asflags -g
  894. add_cflags --gnu
  895. add_cflags --enum_is_int
  896. add_cflags --wchar32
  897. ;;
  898. esac
  899. case ${tgt_os} in
  900. none*)
  901. disable_feature multithread
  902. disable_feature os_support
  903. ;;
  904. android*)
  905. if [ -n "${sdk_path}" ]; then
  906. SDK_PATH=${sdk_path}
  907. COMPILER_LOCATION=`find "${SDK_PATH}" \
  908. -name "arm-linux-androideabi-gcc*" -print -quit`
  909. TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi-
  910. CC=${TOOLCHAIN_PATH}gcc
  911. CXX=${TOOLCHAIN_PATH}g++
  912. AR=${TOOLCHAIN_PATH}ar
  913. LD=${TOOLCHAIN_PATH}gcc
  914. AS=${TOOLCHAIN_PATH}as
  915. STRIP=${TOOLCHAIN_PATH}strip
  916. NM=${TOOLCHAIN_PATH}nm
  917. if [ -z "${alt_libc}" ]; then
  918. alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \
  919. awk '{n = split($0,a,"/"); \
  920. split(a[n-1],b,"-"); \
  921. print $0 " " b[2]}' | \
  922. sort -g -k 2 | \
  923. awk '{ print $1 }' | tail -1`
  924. fi
  925. if [ -d "${alt_libc}" ]; then
  926. add_cflags "--sysroot=${alt_libc}"
  927. add_ldflags "--sysroot=${alt_libc}"
  928. fi
  929. # linker flag that routes around a CPU bug in some
  930. # Cortex-A8 implementations (NDK Dev Guide)
  931. add_ldflags "-Wl,--fix-cortex-a8"
  932. enable_feature pic
  933. soft_enable realtime_only
  934. if [ ${tgt_isa} = "armv7" ]; then
  935. soft_enable runtime_cpu_detect
  936. fi
  937. if enabled runtime_cpu_detect; then
  938. add_cflags "-I${SDK_PATH}/sources/android/cpufeatures"
  939. fi
  940. else
  941. echo "Assuming standalone build with NDK toolchain."
  942. echo "See build/make/Android.mk for details."
  943. check_add_ldflags -static
  944. soft_enable unit_tests
  945. fi
  946. ;;
  947. darwin*)
  948. XCRUN_FIND="xcrun --sdk iphoneos --find"
  949. CXX="$(${XCRUN_FIND} clang++)"
  950. CC="$(${XCRUN_FIND} clang)"
  951. AR="$(${XCRUN_FIND} ar)"
  952. AS="$(${XCRUN_FIND} as)"
  953. STRIP="$(${XCRUN_FIND} strip)"
  954. NM="$(${XCRUN_FIND} nm)"
  955. RANLIB="$(${XCRUN_FIND} ranlib)"
  956. AS_SFX=.S
  957. LD="${CXX:-$(${XCRUN_FIND} ld)}"
  958. # ASFLAGS is written here instead of using check_add_asflags
  959. # because we need to overwrite all of ASFLAGS and purge the
  960. # options that were put in above
  961. ASFLAGS="-arch ${tgt_isa} -g"
  962. add_cflags -arch ${tgt_isa}
  963. add_ldflags -arch ${tgt_isa}
  964. alt_libc="$(show_darwin_sdk_path iphoneos)"
  965. if [ -d "${alt_libc}" ]; then
  966. add_cflags -isysroot ${alt_libc}
  967. fi
  968. if [ "${LD}" = "${CXX}" ]; then
  969. add_ldflags -miphoneos-version-min="${IOS_VERSION_MIN}"
  970. else
  971. add_ldflags -ios_version_min "${IOS_VERSION_MIN}"
  972. fi
  973. for d in lib usr/lib usr/lib/system; do
  974. try_dir="${alt_libc}/${d}"
  975. [ -d "${try_dir}" ] && add_ldflags -L"${try_dir}"
  976. done
  977. case ${tgt_isa} in
  978. armv7|armv7s|armv8|arm64)
  979. if enabled neon && ! check_xcode_minimum_version; then
  980. soft_disable neon
  981. log_echo " neon disabled: upgrade Xcode (need v6.3+)."
  982. if enabled neon_asm; then
  983. soft_disable neon_asm
  984. log_echo " neon_asm disabled: upgrade Xcode (need v6.3+)."
  985. fi
  986. fi
  987. ;;
  988. esac
  989. asm_conversion_cmd="${source_path}/build/make/ads2gas_apple.pl"
  990. if [ "$(show_darwin_sdk_major_version iphoneos)" -gt 8 ]; then
  991. check_add_cflags -fembed-bitcode
  992. check_add_asflags -fembed-bitcode
  993. check_add_ldflags -fembed-bitcode
  994. fi
  995. ;;
  996. linux*)
  997. enable_feature linux
  998. if enabled rvct; then
  999. # Check if we have CodeSourcery GCC in PATH. Needed for
  1000. # libraries
  1001. which arm-none-linux-gnueabi-gcc 2>&- || \
  1002. die "Couldn't find CodeSourcery GCC from PATH"
  1003. # Use armcc as a linker to enable translation of
  1004. # some gcc specific options such as -lm and -lpthread.
  1005. LD="armcc --translate_gcc"
  1006. # create configuration file (uses path to CodeSourcery GCC)
  1007. armcc --arm_linux_configure --arm_linux_config_file=arm_linux.cfg
  1008. add_cflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
  1009. add_asflags --no_hide_all --apcs=/interwork
  1010. add_ldflags --arm_linux_paths --arm_linux_config_file=arm_linux.cfg
  1011. enabled pic && add_cflags --apcs=/fpic
  1012. enabled pic && add_asflags --apcs=/fpic
  1013. enabled shared && add_cflags --shared
  1014. fi
  1015. ;;
  1016. esac
  1017. ;;
  1018. mips*)
  1019. link_with_cc=gcc
  1020. setup_gnu_toolchain
  1021. tune_cflags="-mtune="
  1022. if enabled dspr2; then
  1023. check_add_cflags -mips32r2 -mdspr2
  1024. fi
  1025. if enabled runtime_cpu_detect; then
  1026. disable_feature runtime_cpu_detect
  1027. fi
  1028. if [ -n "${tune_cpu}" ]; then
  1029. case ${tune_cpu} in
  1030. p5600)
  1031. check_add_cflags -mips32r5 -mload-store-pairs
  1032. check_add_cflags -msched-weight -mhard-float -mfp64
  1033. check_add_asflags -mips32r5 -mhard-float -mfp64
  1034. check_add_ldflags -mfp64
  1035. ;;
  1036. i6400|p6600)
  1037. check_add_cflags -mips64r6 -mabi=64 -msched-weight
  1038. check_add_cflags -mload-store-pairs -mhard-float -mfp64
  1039. check_add_asflags -mips64r6 -mabi=64 -mhard-float -mfp64
  1040. check_add_ldflags -mips64r6 -mabi=64 -mfp64
  1041. ;;
  1042. esac
  1043. if enabled msa; then
  1044. add_cflags -mmsa
  1045. add_asflags -mmsa
  1046. add_ldflags -mmsa
  1047. fi
  1048. fi
  1049. if enabled mmi; then
  1050. tgt_isa=loongson3a
  1051. check_add_ldflags -march=loongson3a
  1052. fi
  1053. check_add_cflags -march=${tgt_isa}
  1054. check_add_asflags -march=${tgt_isa}
  1055. check_add_asflags -KPIC
  1056. ;;
  1057. ppc*)
  1058. link_with_cc=gcc
  1059. setup_gnu_toolchain
  1060. check_gcc_machine_option "vsx"
  1061. ;;
  1062. x86*)
  1063. case ${tgt_os} in
  1064. win*)
  1065. enabled gcc && add_cflags -fno-common
  1066. ;;
  1067. solaris*)
  1068. CC=${CC:-${CROSS}gcc}
  1069. CXX=${CXX:-${CROSS}g++}
  1070. LD=${LD:-${CROSS}gcc}
  1071. CROSS=${CROSS-g}
  1072. ;;
  1073. os2)
  1074. disable_feature pic
  1075. AS=${AS:-nasm}
  1076. add_ldflags -Zhigh-mem
  1077. ;;
  1078. esac
  1079. AS="${alt_as:-${AS:-auto}}"
  1080. case ${tgt_cc} in
  1081. icc*)
  1082. CC=${CC:-icc}
  1083. LD=${LD:-icc}
  1084. setup_gnu_toolchain
  1085. add_cflags -use-msasm # remove -use-msasm too?
  1086. # add -no-intel-extensions to suppress warning #10237
  1087. # refer to http://software.intel.com/en-us/forums/topic/280199
  1088. add_ldflags -i-static -no-intel-extensions
  1089. enabled x86_64 && add_cflags -ipo -static -O3 -no-prec-div
  1090. enabled x86_64 && AR=xiar
  1091. case ${tune_cpu} in
  1092. atom*)
  1093. tune_cflags="-x"
  1094. tune_cpu="SSE3_ATOM"
  1095. ;;
  1096. *)
  1097. tune_cflags="-march="
  1098. ;;
  1099. esac
  1100. ;;
  1101. gcc*)
  1102. link_with_cc=gcc
  1103. tune_cflags="-march="
  1104. setup_gnu_toolchain
  1105. #for 32 bit x86 builds, -O3 did not turn on this flag
  1106. enabled optimizations && disabled gprof && check_add_cflags -fomit-frame-pointer
  1107. ;;
  1108. vs*)
  1109. # When building with Microsoft Visual Studio the assembler is
  1110. # invoked directly. Checking at configure time is unnecessary.
  1111. # Skip the check by setting AS arbitrarily
  1112. AS=msvs
  1113. msvs_arch_dir=x86-msvs
  1114. vc_version=${tgt_cc##vs}
  1115. case $vc_version in
  1116. 7|8|9|10)
  1117. echo "${tgt_cc} does not support avx/avx2, disabling....."
  1118. RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx --disable-avx2 "
  1119. soft_disable avx
  1120. soft_disable avx2
  1121. ;;
  1122. esac
  1123. case $vc_version in
  1124. 7|8|9)
  1125. echo "${tgt_cc} omits stdint.h, disabling webm-io..."
  1126. soft_disable webm_io
  1127. ;;
  1128. esac
  1129. ;;
  1130. esac
  1131. bits=32
  1132. enabled x86_64 && bits=64
  1133. check_cpp <<EOF && bits=x32
  1134. #if !defined(__ILP32__) || !defined(__x86_64__)
  1135. #error "not x32"
  1136. #endif
  1137. EOF
  1138. case ${tgt_cc} in
  1139. gcc*)
  1140. add_cflags -m${bits}
  1141. add_ldflags -m${bits}
  1142. ;;
  1143. esac
  1144. soft_enable runtime_cpu_detect
  1145. # We can't use 'check_cflags' until the compiler is configured and CC is
  1146. # populated.
  1147. for ext in ${ARCH_EXT_LIST_X86}; do
  1148. # disable higher order extensions to simplify asm dependencies
  1149. if [ "$disable_exts" = "yes" ]; then
  1150. if ! disabled $ext; then
  1151. RTCD_OPTIONS="${RTCD_OPTIONS}--disable-${ext} "
  1152. disable_feature $ext
  1153. fi
  1154. elif disabled $ext; then
  1155. disable_exts="yes"
  1156. else
  1157. # use the shortened version for the flag: sse4_1 -> sse4
  1158. check_gcc_machine_option ${ext%_*} $ext
  1159. fi
  1160. done
  1161. if enabled external_build; then
  1162. log_echo " skipping assembler detection"
  1163. else
  1164. case "${AS}" in
  1165. auto|"")
  1166. which nasm >/dev/null 2>&1 && AS=nasm
  1167. which yasm >/dev/null 2>&1 && AS=yasm
  1168. if [ "${AS}" = nasm ] ; then
  1169. # Apple ships version 0.98 of nasm through at least Xcode 6. Revisit
  1170. # this check if they start shipping a compatible version.
  1171. apple=`nasm -v | grep "Apple"`
  1172. [ -n "${apple}" ] \
  1173. && echo "Unsupported version of nasm: ${apple}" \
  1174. && AS=""
  1175. fi
  1176. [ "${AS}" = auto ] || [ -z "${AS}" ] \
  1177. && die "Neither yasm nor nasm have been found." \
  1178. "See the prerequisites section in the README for more info."
  1179. ;;
  1180. esac
  1181. log_echo " using $AS"
  1182. fi
  1183. [ "${AS##*/}" = nasm ] && add_asflags -Ox
  1184. AS_SFX=.asm
  1185. case ${tgt_os} in
  1186. win32)
  1187. add_asflags -f win32
  1188. enabled debug && add_asflags -g cv8
  1189. EXE_SFX=.exe
  1190. ;;
  1191. win64)
  1192. add_asflags -f x64
  1193. enabled debug && add_asflags -g cv8
  1194. EXE_SFX=.exe
  1195. ;;
  1196. linux*|solaris*|android*)
  1197. add_asflags -f elf${bits}
  1198. enabled debug && [ "${AS}" = yasm ] && add_asflags -g dwarf2
  1199. enabled debug && [ "${AS}" = nasm ] && add_asflags -g
  1200. [ "${AS##*/}" = nasm ] && check_asm_align
  1201. ;;
  1202. darwin*)
  1203. add_asflags -f macho${bits}
  1204. enabled x86 && darwin_arch="-arch i386" || darwin_arch="-arch x86_64"
  1205. add_cflags ${darwin_arch}
  1206. add_ldflags ${darwin_arch}
  1207. # -mdynamic-no-pic is still a bit of voodoo -- it was required at
  1208. # one time, but does not seem to be now, and it breaks some of the
  1209. # code that still relies on inline assembly.
  1210. # enabled icc && ! enabled pic && add_cflags -fno-pic -mdynamic-no-pic
  1211. enabled icc && ! enabled pic && add_cflags -fno-pic
  1212. ;;
  1213. iphonesimulator)
  1214. add_asflags -f macho${bits}
  1215. enabled x86 && sim_arch="-arch i386" || sim_arch="-arch x86_64"
  1216. add_cflags ${sim_arch}
  1217. add_ldflags ${sim_arch}
  1218. if [ "$(show_darwin_sdk_major_version iphonesimulator)" -gt 8 ]; then
  1219. # yasm v1.3.0 doesn't know what -fembed-bitcode means, so turning it
  1220. # on is pointless (unless building a C-only lib). Warn the user, but
  1221. # do nothing here.
  1222. log "Warning: Bitcode embed disabled for simulator targets."
  1223. fi
  1224. ;;
  1225. os2)
  1226. add_asflags -f aout
  1227. enabled debug && add_asflags -g
  1228. EXE_SFX=.exe
  1229. ;;
  1230. *)
  1231. log "Warning: Unknown os $tgt_os while setting up $AS flags"
  1232. ;;
  1233. esac
  1234. ;;
  1235. *-gcc|generic-gnu)
  1236. link_with_cc=gcc
  1237. enable_feature gcc
  1238. setup_gnu_toolchain
  1239. ;;
  1240. esac
  1241. # Try to enable CPU specific tuning
  1242. if [ -n "${tune_cpu}" ]; then
  1243. if [ -n "${tune_cflags}" ]; then
  1244. check_add_cflags ${tune_cflags}${tune_cpu} || \
  1245. die "Requested CPU '${tune_cpu}' not supported by compiler"
  1246. fi
  1247. if [ -n "${tune_asflags}" ]; then
  1248. check_add_asflags ${tune_asflags}${tune_cpu} || \
  1249. die "Requested CPU '${tune_cpu}' not supported by assembler"
  1250. fi
  1251. if [ -z "${tune_cflags}${tune_asflags}" ]; then
  1252. log_echo "Warning: CPU tuning not supported by this toolchain"
  1253. fi
  1254. fi
  1255. if enabled debug; then
  1256. check_add_cflags -g && check_add_ldflags -g
  1257. else
  1258. check_add_cflags -DNDEBUG
  1259. fi
  1260. enabled gprof && check_add_cflags -pg && check_add_ldflags -pg
  1261. enabled gcov &&
  1262. check_add_cflags -fprofile-arcs -ftest-coverage &&
  1263. check_add_ldflags -fprofile-arcs -ftest-coverage
  1264. if enabled optimizations; then
  1265. if enabled rvct; then
  1266. enabled small && check_add_cflags -Ospace || check_add_cflags -Otime
  1267. else
  1268. enabled small && check_add_cflags -O2 || check_add_cflags -O3
  1269. fi
  1270. fi
  1271. # Position Independent Code (PIC) support, for building relocatable
  1272. # shared objects
  1273. enabled gcc && enabled pic && check_add_cflags -fPIC
  1274. # Work around longjmp interception on glibc >= 2.11, to improve binary
  1275. # compatibility. See http://code.google.com/p/webm/issues/detail?id=166
  1276. enabled linux && check_add_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
  1277. # Check for strip utility variant
  1278. ${STRIP} -V 2>/dev/null | grep GNU >/dev/null && enable_feature gnu_strip
  1279. # Try to determine target endianness
  1280. check_cc <<EOF
  1281. unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E';
  1282. EOF
  1283. [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' |
  1284. grep '4f *32 *42 *45' >/dev/null 2>&1 && enable_feature big_endian
  1285. # Try to find which inline keywords are supported
  1286. check_cc <<EOF && INLINE="inline"
  1287. static inline function() {}
  1288. EOF
  1289. # Almost every platform uses pthreads.
  1290. if enabled multithread; then
  1291. case ${toolchain} in
  1292. *-win*-vs*)
  1293. ;;
  1294. *-android-gcc)
  1295. # bionic includes basic pthread functionality, obviating -lpthread.
  1296. ;;
  1297. *)
  1298. check_header pthread.h && add_extralibs -lpthread
  1299. ;;
  1300. esac
  1301. fi
  1302. # only for MIPS platforms
  1303. case ${toolchain} in
  1304. mips*)
  1305. if enabled big_endian; then
  1306. if enabled dspr2; then
  1307. echo "dspr2 optimizations are available only for little endian platforms"
  1308. disable_feature dspr2
  1309. fi
  1310. if enabled msa; then
  1311. echo "msa optimizations are available only for little endian platforms"
  1312. disable_feature msa
  1313. fi
  1314. if enabled mmi; then
  1315. echo "mmi optimizations are available only for little endian platforms"
  1316. disable_feature mmi
  1317. fi
  1318. fi
  1319. ;;
  1320. esac
  1321. # glibc needs these
  1322. if enabled linux; then
  1323. add_cflags -D_LARGEFILE_SOURCE
  1324. add_cflags -D_FILE_OFFSET_BITS=64
  1325. fi
  1326. }
  1327. process_toolchain() {
  1328. process_common_toolchain
  1329. }
  1330. print_config_mk() {
  1331. saved_prefix="${prefix}"
  1332. prefix=$1
  1333. makefile=$2
  1334. shift 2
  1335. for cfg; do
  1336. if enabled $cfg; then
  1337. upname="`toupper $cfg`"
  1338. echo "${prefix}_${upname}=yes" >> $makefile
  1339. fi
  1340. done
  1341. prefix="${saved_prefix}"
  1342. }
  1343. print_config_h() {
  1344. saved_prefix="${prefix}"
  1345. prefix=$1
  1346. header=$2
  1347. shift 2
  1348. for cfg; do
  1349. upname="`toupper $cfg`"
  1350. if enabled $cfg; then
  1351. echo "#define ${prefix}_${upname} 1" >> $header
  1352. else
  1353. echo "#define ${prefix}_${upname} 0" >> $header
  1354. fi
  1355. done
  1356. prefix="${saved_prefix}"
  1357. }
  1358. print_config_vars_h() {
  1359. header=$1
  1360. shift
  1361. while [ $# -gt 0 ]; do
  1362. upname="`toupper $1`"
  1363. echo "#define ${upname} $2" >> $header
  1364. shift 2
  1365. done
  1366. }
  1367. print_webm_license() {
  1368. saved_prefix="${prefix}"
  1369. destination=$1
  1370. prefix="$2"
  1371. suffix="$3"
  1372. shift 3
  1373. cat <<EOF > ${destination}
  1374. ${prefix} Copyright (c) 2011 The WebM project authors. All Rights Reserved.${suffix}
  1375. ${prefix} ${suffix}
  1376. ${prefix} Use of this source code is governed by a BSD-style license${suffix}
  1377. ${prefix} that can be found in the LICENSE file in the root of the source${suffix}
  1378. ${prefix} tree. An additional intellectual property rights grant can be found${suffix}
  1379. ${prefix} in the file PATENTS. All contributing project authors may${suffix}
  1380. ${prefix} be found in the AUTHORS file in the root of the source tree.${suffix}
  1381. EOF
  1382. prefix="${saved_prefix}"
  1383. }
  1384. process_targets() {
  1385. true;
  1386. }
  1387. process_detect() {
  1388. true;
  1389. }
  1390. enable_feature logging
  1391. logfile="config.log"
  1392. self=$0
  1393. process() {
  1394. cmdline_args="$@"
  1395. process_cmdline "$@"
  1396. if enabled child; then
  1397. echo "# ${self} $@" >> ${logfile}
  1398. else
  1399. echo "# ${self} $@" > ${logfile}
  1400. fi
  1401. post_process_common_cmdline
  1402. post_process_cmdline
  1403. process_toolchain
  1404. process_detect
  1405. process_targets
  1406. OOT_INSTALLS="${OOT_INSTALLS}"
  1407. if enabled source_path_used; then
  1408. # Prepare the PWD for building.
  1409. for f in ${OOT_INSTALLS}; do
  1410. install -D "${source_path}/$f" "$f"
  1411. done
  1412. fi
  1413. cp "${source_path}/build/make/Makefile" .
  1414. clean_temp_files
  1415. true
  1416. }