configure 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870
  1. #!/bin/sh
  2. #
  3. # qemu configure script (c) 2003 Fabrice Bellard
  4. #
  5. # Unset some variables known to interfere with behavior of common tools,
  6. # just as autoconf does. Unlike autoconf, we assume that unset exists.
  7. unset CLICOLOR_FORCE GREP_OPTIONS BASH_ENV ENV MAIL MAILPATH CDPATH
  8. # Don't allow CCACHE, if present, to use cached results of compile tests!
  9. export CCACHE_RECACHE=yes
  10. # make source path absolute
  11. source_path=$(cd "$(dirname -- "$0")"; pwd)
  12. if test "$PWD" = "$source_path"
  13. then
  14. echo "Using './build' as the directory for build output"
  15. MARKER=build/auto-created-by-configure
  16. if test -e build
  17. then
  18. if test -f $MARKER
  19. then
  20. rm -rf build
  21. else
  22. echo "ERROR: ./build dir already exists and was not previously created by configure"
  23. exit 1
  24. fi
  25. fi
  26. if ! mkdir build || ! touch $MARKER
  27. then
  28. echo "ERROR: Could not create ./build directory. Check the permissions on"
  29. echo "your source directory, or try doing an out-of-tree build."
  30. exit 1
  31. fi
  32. cat > GNUmakefile <<'EOF'
  33. # This file is auto-generated by configure to support in-source tree
  34. # 'make' command invocation
  35. build:
  36. @echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
  37. @$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
  38. @if test "$(MAKECMDGOALS)" = "distclean" && \
  39. test -e build/auto-created-by-configure ; \
  40. then \
  41. rm -rf build GNUmakefile ; \
  42. fi
  43. %: build
  44. @
  45. .PHONY: build
  46. GNUmakefile: ;
  47. EOF
  48. cd build
  49. exec "$source_path/configure" "$@"
  50. fi
  51. # Temporary directory used for files created while
  52. # configure runs. Since it is in the build directory
  53. # we can safely blow away any previous version of it
  54. # (and we need not jump through hoops to try to delete
  55. # it when configure exits.)
  56. TMPDIR1="config-temp"
  57. rm -rf "${TMPDIR1}"
  58. if ! mkdir -p "${TMPDIR1}"; then
  59. echo "ERROR: failed to create temporary directory"
  60. exit 1
  61. fi
  62. TMPB="qemu-conf"
  63. TMPC="${TMPDIR1}/${TMPB}.c"
  64. TMPO="${TMPDIR1}/${TMPB}.o"
  65. TMPE="${TMPDIR1}/${TMPB}.exe"
  66. rm -f config.log
  67. # Print a helpful header at the top of config.log
  68. echo "# QEMU configure log $(date)" >> config.log
  69. printf "# Configured with:" >> config.log
  70. # repeat the invocation to log and stdout for CI
  71. invoke=$(printf " '%s'" "$0" "$@")
  72. test -n "$GITLAB_CI" && echo "configuring with: $invoke"
  73. { echo "$invoke"; echo; echo "#"; } >> config.log
  74. quote_sh() {
  75. printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
  76. }
  77. error_exit() {
  78. (echo
  79. echo "ERROR: $1"
  80. while test -n "$2"; do
  81. echo " $2"
  82. shift
  83. done
  84. echo) >&2
  85. exit 1
  86. }
  87. do_compiler() {
  88. # Run the compiler, capturing its output to the log. First argument
  89. # is compiler binary to execute.
  90. compiler="$1"
  91. shift
  92. if test -n "$BASH_VERSION"; then eval '
  93. echo >>config.log "
  94. funcs: ${FUNCNAME[*]}
  95. lines: ${BASH_LINENO[*]}"
  96. '; fi
  97. echo $compiler "$@" >> config.log
  98. $compiler "$@" >> config.log 2>&1 || return $?
  99. }
  100. do_cc() {
  101. do_compiler "$cc" $CPU_CFLAGS "$@"
  102. }
  103. compile_object() {
  104. local_cflags="$1"
  105. do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -c -o $TMPO $TMPC
  106. }
  107. compile_prog() {
  108. local_cflags="$1"
  109. local_ldflags="$2"
  110. do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -o $TMPE $TMPC \
  111. $LDFLAGS $EXTRA_LDFLAGS $local_ldflags
  112. }
  113. # symbolically link $1 to $2. Portable version of "ln -sf".
  114. symlink() {
  115. rm -rf "$2"
  116. mkdir -p "$(dirname "$2")"
  117. ln -s "$1" "$2"
  118. }
  119. # check whether a command is available to this shell (may be either an
  120. # executable or a builtin)
  121. has() {
  122. type "$1" >/dev/null 2>&1
  123. }
  124. version_ge () {
  125. local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
  126. local_ver2=$(echo "$2" | tr . ' ')
  127. while true; do
  128. set x $local_ver1
  129. local_first=${2-0}
  130. # 'shift 2' if $2 is set, or 'shift' if $2 is not set
  131. shift ${2:+2}
  132. local_ver1=$*
  133. set x $local_ver2
  134. # the second argument finished, the first must be greater or equal
  135. test $# = 1 && return 0
  136. test $local_first -lt $2 && return 1
  137. test $local_first -gt $2 && return 0
  138. shift ${2:+2}
  139. local_ver2=$*
  140. done
  141. }
  142. if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
  143. then
  144. error_exit "main directory cannot contain spaces nor colons"
  145. fi
  146. # parse CC options first; some compiler tests are used to establish
  147. # some defaults, based on the host environment
  148. # default parameters
  149. container_engine="auto"
  150. cpu=""
  151. cross_compile="no"
  152. cross_prefix=""
  153. host_cc="cc"
  154. EXTRA_CFLAGS=""
  155. EXTRA_CXXFLAGS=""
  156. EXTRA_OBJCFLAGS=""
  157. EXTRA_LDFLAGS=""
  158. # Default value for a variable defining feature "foo".
  159. # * foo="no" feature will only be used if --enable-foo arg is given
  160. # * foo="" feature will be searched for, and if found, will be used
  161. # unless --disable-foo is given
  162. # * foo="yes" this value will only be set by --enable-foo flag.
  163. # feature will searched for,
  164. # if not found, configure exits with error
  165. #
  166. # Always add --enable-foo and --disable-foo command line args.
  167. # Distributions want to ensure that several features are compiled in, and it
  168. # is impossible without a --enable-foo that exits if a feature is not found.
  169. default_feature=""
  170. for opt do
  171. optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
  172. case "$opt" in
  173. --cross-prefix=*) cross_prefix="$optarg"
  174. cross_compile="yes"
  175. ;;
  176. --cc=*) CC="$optarg"
  177. ;;
  178. --cxx=*) CXX="$optarg"
  179. ;;
  180. --objcc=*) objcc="$optarg"
  181. ;;
  182. --cpu=*) cpu="$optarg"
  183. ;;
  184. --extra-cflags=*)
  185. EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
  186. EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
  187. EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
  188. ;;
  189. --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
  190. ;;
  191. --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
  192. ;;
  193. --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
  194. ;;
  195. --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
  196. ;;
  197. --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
  198. eval "cross_cc_cflags_${cc_arch}=\$optarg"
  199. ;;
  200. --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
  201. eval "cross_cc_${cc_arch}=\$optarg"
  202. ;;
  203. --cross-prefix-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-prefix-FOO option"
  204. ;;
  205. --cross-prefix-*) cc_arch=${opt#--cross-prefix-}; cc_arch=${cc_arch%%=*}
  206. eval "cross_prefix_${cc_arch}=\$optarg"
  207. ;;
  208. --without-default-features) default_feature="no"
  209. ;;
  210. esac
  211. done
  212. default_cflags='-O2 -g'
  213. git_submodules_action="update"
  214. docs="auto"
  215. EXESUF=""
  216. system="yes"
  217. linux_user=""
  218. bsd_user=""
  219. plugins="$default_feature"
  220. subdirs=""
  221. ninja=""
  222. python=
  223. download="enabled"
  224. skip_meson=no
  225. use_containers="yes"
  226. gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
  227. gdb_arches=""
  228. # Don't accept a target_list environment variable.
  229. unset target_list
  230. unset target_list_exclude
  231. # The following Meson options are handled manually (still they
  232. # are included in the automatically generated help message)
  233. # because they automatically enable/disable other options
  234. tcg="auto"
  235. cfi="false"
  236. # Meson has PIE as a boolean rather than enabled/disabled/auto,
  237. # and we also need to check for -static-pie before Meson runs
  238. # which requires knowing whether --static is enabled.
  239. pie=""
  240. static="no"
  241. # Preferred compiler:
  242. # ${CC} (if set)
  243. # ${cross_prefix}gcc (if cross-prefix specified)
  244. # system compiler
  245. if test -z "${CC}${cross_prefix}"; then
  246. cc="cc"
  247. else
  248. cc="${CC-${cross_prefix}gcc}"
  249. fi
  250. if test -z "${CXX}${cross_prefix}"; then
  251. cxx="c++"
  252. else
  253. cxx="${CXX-${cross_prefix}g++}"
  254. fi
  255. # Preferred ObjC compiler:
  256. # $objcc (if set, i.e. via --objcc option)
  257. # ${cross_prefix}clang (if cross-prefix specified)
  258. # clang (if available)
  259. # $cc
  260. if test -z "${objcc}${cross_prefix}"; then
  261. if has clang; then
  262. objcc=clang
  263. else
  264. objcc="$cc"
  265. fi
  266. else
  267. objcc="${objcc-${cross_prefix}clang}"
  268. fi
  269. ar="${AR-${cross_prefix}ar}"
  270. as="${AS-${cross_prefix}as}"
  271. ccas="${CCAS-$cc}"
  272. dlltool="${DLLTOOL-${cross_prefix}dlltool}"
  273. objcopy="${OBJCOPY-${cross_prefix}objcopy}"
  274. ld="${LD-${cross_prefix}ld}"
  275. ranlib="${RANLIB-${cross_prefix}ranlib}"
  276. nm="${NM-${cross_prefix}nm}"
  277. strip="${STRIP-${cross_prefix}strip}"
  278. widl="${WIDL-${cross_prefix}widl}"
  279. windres="${WINDRES-${cross_prefix}windres}"
  280. windmc="${WINDMC-${cross_prefix}windmc}"
  281. pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}"
  282. sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
  283. check_define() {
  284. cat > $TMPC <<EOF
  285. #if !defined($1)
  286. #error $1 not defined
  287. #endif
  288. int main(void) { return 0; }
  289. EOF
  290. compile_object
  291. }
  292. write_c_skeleton() {
  293. cat > $TMPC <<EOF
  294. int main(void) { return 0; }
  295. EOF
  296. }
  297. if check_define __linux__ ; then
  298. host_os=linux
  299. elif check_define _WIN32 ; then
  300. host_os=windows
  301. elif check_define __OpenBSD__ ; then
  302. host_os=openbsd
  303. elif check_define __sun__ ; then
  304. host_os=sunos
  305. elif check_define __HAIKU__ ; then
  306. host_os=haiku
  307. elif check_define __FreeBSD__ ; then
  308. host_os=freebsd
  309. elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
  310. host_os=gnu/kfreebsd
  311. elif check_define __DragonFly__ ; then
  312. host_os=dragonfly
  313. elif check_define __NetBSD__; then
  314. host_os=netbsd
  315. elif check_define __APPLE__; then
  316. host_os=darwin
  317. else
  318. # This is a fatal error, but don't report it yet, because we
  319. # might be going to just print the --help text, or it might
  320. # be the result of a missing compiler.
  321. host_os=bogus
  322. fi
  323. if test ! -z "$cpu" ; then
  324. # command line argument
  325. :
  326. elif check_define __i386__ ; then
  327. cpu="i386"
  328. elif check_define __x86_64__ ; then
  329. if check_define __ILP32__ ; then
  330. cpu="x32"
  331. else
  332. cpu="x86_64"
  333. fi
  334. elif check_define __sparc__ ; then
  335. if check_define __arch64__ ; then
  336. cpu="sparc64"
  337. else
  338. cpu="sparc"
  339. fi
  340. elif check_define _ARCH_PPC ; then
  341. if check_define _ARCH_PPC64 ; then
  342. if check_define _LITTLE_ENDIAN ; then
  343. cpu="ppc64le"
  344. else
  345. cpu="ppc64"
  346. fi
  347. else
  348. cpu="ppc"
  349. fi
  350. elif check_define __mips__ ; then
  351. cpu="mips"
  352. elif check_define __s390__ ; then
  353. if check_define __s390x__ ; then
  354. cpu="s390x"
  355. else
  356. cpu="s390"
  357. fi
  358. elif check_define __riscv ; then
  359. if check_define _LP64 ; then
  360. cpu="riscv64"
  361. else
  362. cpu="riscv32"
  363. fi
  364. elif check_define __arm__ ; then
  365. cpu="arm"
  366. elif check_define __aarch64__ ; then
  367. cpu="aarch64"
  368. elif check_define __loongarch64 ; then
  369. cpu="loongarch64"
  370. else
  371. # Using uname is really broken, but it is just a fallback for architectures
  372. # that are going to use TCI anyway
  373. cpu=$(uname -m)
  374. if test "$host_os" != "bogus"; then
  375. echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
  376. fi
  377. fi
  378. # Normalise host CPU name to the values used by Meson cross files and in source
  379. # directories, and set multilib cflags. The canonicalization isn't really
  380. # necessary, because the architectures that we check for should not hit the
  381. # 'uname -m' case, but better safe than sorry in case --cpu= is used.
  382. #
  383. # Note that this case should only have supported host CPUs, not guests.
  384. # Please keep it sorted and synchronized with meson.build's host_arch.
  385. host_arch=
  386. linux_arch=
  387. case "$cpu" in
  388. aarch64)
  389. host_arch=aarch64
  390. linux_arch=arm64
  391. ;;
  392. armv*b|armv*l|arm)
  393. cpu=arm
  394. host_arch=arm
  395. linux_arch=arm
  396. ;;
  397. i386|i486|i586|i686)
  398. cpu="i386"
  399. host_arch=i386
  400. linux_arch=x86
  401. CPU_CFLAGS="-m32"
  402. ;;
  403. loongarch*)
  404. cpu=loongarch64
  405. host_arch=loongarch64
  406. linux_arch=loongarch
  407. ;;
  408. mips64*|mipsisa64*)
  409. cpu=mips64
  410. host_arch=mips
  411. linux_arch=mips
  412. ;;
  413. mips*)
  414. cpu=mips
  415. host_arch=mips
  416. linux_arch=mips
  417. ;;
  418. ppc)
  419. host_arch=ppc
  420. linux_arch=powerpc
  421. CPU_CFLAGS="-m32"
  422. ;;
  423. ppc64)
  424. host_arch=ppc64
  425. linux_arch=powerpc
  426. CPU_CFLAGS="-m64 -mbig-endian"
  427. ;;
  428. ppc64le)
  429. cpu=ppc64
  430. host_arch=ppc64
  431. linux_arch=powerpc
  432. CPU_CFLAGS="-m64 -mlittle-endian"
  433. ;;
  434. riscv32 | riscv64)
  435. host_arch=riscv
  436. linux_arch=riscv
  437. ;;
  438. s390)
  439. linux_arch=s390
  440. CPU_CFLAGS="-m31"
  441. ;;
  442. s390x)
  443. host_arch=s390x
  444. linux_arch=s390
  445. CPU_CFLAGS="-m64"
  446. ;;
  447. sparc|sun4[cdmuv])
  448. cpu=sparc
  449. CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
  450. ;;
  451. sparc64)
  452. host_arch=sparc64
  453. CPU_CFLAGS="-m64 -mcpu=ultrasparc"
  454. ;;
  455. x32)
  456. cpu="x86_64"
  457. host_arch=x86_64
  458. linux_arch=x86
  459. CPU_CFLAGS="-mx32"
  460. ;;
  461. x86_64|amd64)
  462. cpu="x86_64"
  463. host_arch=x86_64
  464. linux_arch=x86
  465. CPU_CFLAGS="-m64"
  466. ;;
  467. esac
  468. if test -n "$host_arch" && {
  469. ! test -d "$source_path/linux-user/include/host/$host_arch" ||
  470. ! test -d "$source_path/common-user/host/$host_arch"; }; then
  471. error_exit "linux-user/include/host/$host_arch does not exist." \
  472. "This is a bug in the configure script, please report it."
  473. fi
  474. if test -n "$linux_arch" && ! test -d "$source_path/linux-headers/asm-$linux_arch"; then
  475. error_exit "linux-headers/asm-$linux_arch does not exist." \
  476. "This is a bug in the configure script, please report it."
  477. fi
  478. check_py_version() {
  479. # We require python >= 3.8.
  480. # NB: a True python conditional creates a non-zero return code (Failure)
  481. "$1" -c 'import sys; sys.exit(sys.version_info < (3,8))'
  482. }
  483. first_python=
  484. if test -z "${PYTHON}"; then
  485. # A bare 'python' is traditionally python 2.x, but some distros
  486. # have it as python 3.x, so check in both places.
  487. for binary in python3 python python3.12 python3.11 \
  488. python3.10 python3.9 python3.8; do
  489. if has "$binary"; then
  490. python=$(command -v "$binary")
  491. if check_py_version "$python"; then
  492. # This one is good.
  493. first_python=
  494. break
  495. else
  496. first_python=$python
  497. fi
  498. fi
  499. done
  500. else
  501. # Same as above, but only check the environment variable.
  502. has "${PYTHON}" || error_exit "The PYTHON environment variable does not point to an executable"
  503. python=$(command -v "$PYTHON")
  504. if check_py_version "$python"; then
  505. # This one is good.
  506. first_python=
  507. else
  508. first_python=$first_python
  509. fi
  510. fi
  511. # Check for ancillary tools used in testing
  512. genisoimage=
  513. for binary in genisoimage mkisofs
  514. do
  515. if has $binary
  516. then
  517. genisoimage=$(command -v "$binary")
  518. break
  519. fi
  520. done
  521. if test "$host_os" = "windows" ; then
  522. EXESUF=".exe"
  523. fi
  524. meson_option_build_array() {
  525. printf '['
  526. (if test "$host_os" = windows; then
  527. IFS=\;
  528. else
  529. IFS=:
  530. fi
  531. for e in $1; do
  532. printf '"""'
  533. # backslash escape any '\' and '"' characters
  534. printf "%s" "$e" | sed -e 's/\([\"]\)/\\\1/g'
  535. printf '""",'
  536. done)
  537. printf ']\n'
  538. }
  539. . "$source_path/scripts/meson-buildoptions.sh"
  540. meson_options=
  541. meson_option_add() {
  542. local arg
  543. for arg; do
  544. meson_options="$meson_options $(quote_sh "$arg")"
  545. done
  546. }
  547. meson_option_parse() {
  548. meson_options="$meson_options $(_meson_option_parse "$@")"
  549. if test $? -eq 1; then
  550. echo "ERROR: unknown option $1"
  551. echo "Try '$0 --help' for more information"
  552. exit 1
  553. fi
  554. }
  555. meson_add_machine_file() {
  556. if test "$cross_compile" = "yes"; then
  557. meson_option_add --cross-file "$1"
  558. else
  559. meson_option_add --native-file "$1"
  560. fi
  561. }
  562. for opt do
  563. optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
  564. case "$opt" in
  565. --help|-h) show_help=yes
  566. ;;
  567. --version|-V) exec cat "$source_path/VERSION"
  568. ;;
  569. --cross-prefix=*)
  570. ;;
  571. --cc=*)
  572. ;;
  573. --host-cc=*) host_cc="$optarg"
  574. ;;
  575. --cxx=*)
  576. ;;
  577. --objcc=*)
  578. ;;
  579. --make=*)
  580. ;;
  581. --install=*)
  582. ;;
  583. --python=*) python="$optarg"
  584. ;;
  585. --skip-meson) skip_meson=yes
  586. ;;
  587. --ninja=*) ninja="$optarg"
  588. ;;
  589. --extra-cflags=*)
  590. ;;
  591. --extra-cxxflags=*)
  592. ;;
  593. --extra-objcflags=*)
  594. ;;
  595. --extra-ldflags=*)
  596. ;;
  597. --cross-cc-*)
  598. ;;
  599. --cross-prefix-*)
  600. ;;
  601. --enable-docs) docs=enabled
  602. ;;
  603. --disable-docs) docs=disabled
  604. ;;
  605. --cpu=*)
  606. ;;
  607. --target-list=*) target_list="$optarg"
  608. if test "$target_list_exclude"; then
  609. error_exit "Can't mix --target-list with --target-list-exclude"
  610. fi
  611. ;;
  612. --target-list-exclude=*) target_list_exclude="$optarg"
  613. if test "$target_list"; then
  614. error_exit "Can't mix --target-list-exclude with --target-list"
  615. fi
  616. ;;
  617. --with-default-devices) meson_option_add -Ddefault_devices=true
  618. ;;
  619. --without-default-devices) meson_option_add -Ddefault_devices=false
  620. ;;
  621. --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
  622. ;;
  623. --with-devices-*) device_arch=${opt#--with-devices-};
  624. device_arch=${device_arch%%=*}
  625. cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
  626. if test -f "$cf"; then
  627. device_archs="$device_archs $device_arch"
  628. eval "devices_${device_arch}=\$optarg"
  629. else
  630. error_exit "File $cf does not exist"
  631. fi
  632. ;;
  633. --without-default-features) # processed above
  634. ;;
  635. --static) static="yes"
  636. ;;
  637. --host=*|--build=*|\
  638. --disable-dependency-tracking|\
  639. --sbindir=*|--sharedstatedir=*|\
  640. --oldincludedir=*|--datarootdir=*|--infodir=*|\
  641. --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
  642. # These switches are silently ignored, for compatibility with
  643. # autoconf-generated configure scripts. This allows QEMU's
  644. # configure to be used by RPM and similar macros that set
  645. # lots of directory switches by default.
  646. ;;
  647. --enable-debug)
  648. # Enable debugging options that aren't excessively noisy
  649. meson_option_parse --enable-debug-tcg ""
  650. meson_option_parse --enable-debug-graph-lock ""
  651. meson_option_parse --enable-debug-mutex ""
  652. meson_option_add -Doptimization=0
  653. default_cflags='-O0 -g'
  654. ;;
  655. --disable-tcg) tcg="disabled"
  656. ;;
  657. --enable-tcg) tcg="enabled"
  658. ;;
  659. --disable-system) system="no"
  660. ;;
  661. --enable-system) system="yes"
  662. ;;
  663. --disable-user)
  664. linux_user="no" ;
  665. bsd_user="no" ;
  666. ;;
  667. --enable-user) ;;
  668. --disable-linux-user) linux_user="no"
  669. ;;
  670. --enable-linux-user) linux_user="yes"
  671. ;;
  672. --disable-bsd-user) bsd_user="no"
  673. ;;
  674. --enable-bsd-user) bsd_user="yes"
  675. ;;
  676. --enable-pie) pie="yes"
  677. ;;
  678. --disable-pie) pie="no"
  679. ;;
  680. --enable-cfi) cfi=true
  681. ;;
  682. --disable-cfi) cfi=false
  683. ;;
  684. --disable-download) download="disabled"; git_submodules_action=validate;
  685. ;;
  686. --enable-download) download="enabled"; git_submodules_action=update;
  687. ;;
  688. --enable-plugins) plugins="yes"
  689. ;;
  690. --disable-plugins) plugins="no"
  691. ;;
  692. --enable-containers) use_containers="yes"
  693. ;;
  694. --disable-containers) use_containers="no"
  695. ;;
  696. --container-engine=*) container_engine="$optarg"
  697. ;;
  698. --gdb=*) gdb_bin="$optarg"
  699. ;;
  700. # everything else has the same name in configure and meson
  701. --*) meson_option_parse "$opt" "$optarg"
  702. ;;
  703. # Pass through -Dxxxx options to meson
  704. -D*) meson_option_add "$opt"
  705. ;;
  706. esac
  707. done
  708. if ! test -e "$source_path/.git"
  709. then
  710. git_submodules_action="validate"
  711. fi
  712. if ! test -f "$source_path/subprojects/keycodemapdb/README" \
  713. && test "$download" = disabled
  714. then
  715. echo
  716. echo "ERROR: missing subprojects"
  717. echo
  718. if test -e "$source_path/.git"; then
  719. echo "--disable-download specified but subprojects were not"
  720. echo 'checked out. Please invoke "meson subprojects download"'
  721. echo "before configuring QEMU, or remove --disable-download"
  722. echo "from the command line."
  723. else
  724. echo "This is not a GIT checkout but subproject content appears to"
  725. echo "be missing. Do not use 'git archive' or GitHub download links"
  726. echo "to acquire QEMU source archives. Non-GIT builds are only"
  727. echo "supported with source archives linked from:"
  728. echo
  729. echo " https://www.qemu.org/download/#source"
  730. echo
  731. echo "Developers working with GIT can use scripts/archive-source.sh"
  732. echo "if they need to create valid source archives."
  733. fi
  734. echo
  735. exit 1
  736. fi
  737. default_target_list=""
  738. mak_wilds=""
  739. if [ -n "$host_arch" ] && [ -d "$source_path/common-user/host/$host_arch" ]; then
  740. if [ "$linux_user" != no ]; then
  741. if [ "$host_os" = linux ]; then
  742. linux_user=yes
  743. elif [ "$linux_user" = yes ]; then
  744. error_exit "linux-user not supported on this architecture"
  745. fi
  746. if [ "$linux_user" = "yes" ]; then
  747. mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
  748. fi
  749. fi
  750. if [ "$bsd_user" != no ]; then
  751. if [ "$bsd_user" = "" ]; then
  752. test $host_os = freebsd && bsd_user=yes
  753. fi
  754. if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$host_os" ]; then
  755. error_exit "bsd-user not supported on this host OS"
  756. fi
  757. if [ "$bsd_user" = "yes" ]; then
  758. mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
  759. fi
  760. fi
  761. else
  762. if [ "$linux_user" = yes ] || [ "$bsd_user" = yes ]; then
  763. error_exit "user mode emulation not supported on this architecture"
  764. fi
  765. fi
  766. if [ "$system" = "yes" ]; then
  767. mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
  768. fi
  769. for config in $mak_wilds; do
  770. target="$(basename "$config" .mak)"
  771. if echo "$target_list_exclude" | grep -vq "$target"; then
  772. default_target_list="${default_target_list} $target"
  773. fi
  774. done
  775. if test x"$show_help" = x"yes" ; then
  776. cat << EOF
  777. Usage: configure [options]
  778. Options: [defaults in brackets after descriptions]
  779. Standard options:
  780. --help print this message
  781. --target-list=LIST set target list (default: build all)
  782. $(echo Available targets: $default_target_list | \
  783. fold -s -w 53 | sed -e 's/^/ /')
  784. --target-list-exclude=LIST exclude a set of targets from the default target-list
  785. Advanced options (experts only):
  786. -Dmesonoptname=val passthrough option to meson unmodified
  787. --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
  788. --cc=CC use C compiler CC [$cc]
  789. --host-cc=CC when cross compiling, use C compiler CC for code run
  790. at build time [$host_cc]
  791. --cxx=CXX use C++ compiler CXX [$cxx]
  792. --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
  793. --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
  794. --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
  795. --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
  796. --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
  797. --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
  798. --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests
  799. --cross-prefix-ARCH=PREFIX cross compiler prefix when building ARCH guest test cases
  800. --python=PYTHON use specified python [$python]
  801. --ninja=NINJA use specified ninja [$ninja]
  802. --static enable static build [$static]
  803. --without-default-features default all --enable-* options to "disabled"
  804. --without-default-devices do not include any device that is not needed to
  805. start the emulator (only use if you are including
  806. desired devices in configs/devices/)
  807. --with-devices-ARCH=NAME override default configs/devices
  808. --enable-debug enable common debug build options
  809. --cpu=CPU Build for host CPU [$cpu]
  810. --disable-containers don't use containers for cross-building
  811. --container-engine=TYPE which container engine to use [$container_engine]
  812. --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
  813. EOF
  814. meson_options_help
  815. cat << EOF
  816. system all system emulation targets
  817. user supported user emulation targets
  818. linux-user all linux usermode emulation targets
  819. bsd-user all BSD usermode emulation targets
  820. pie Position Independent Executables
  821. NOTE: The object files are built at the place where configure is launched
  822. EOF
  823. exit 0
  824. fi
  825. # Now that we are sure that the user did not only want to print the --help
  826. # information, we should double-check that the C compiler really works:
  827. write_c_skeleton
  828. if ! compile_object ; then
  829. error_exit "C compiler \"$cc\" either does not exist or does not work."
  830. fi
  831. # Remove old dependency files to make sure that they get properly regenerated
  832. rm -f ./*/config-devices.mak.d
  833. if test -z "$python"
  834. then
  835. # If first_python is set, there was a binary somewhere even though
  836. # it was not suitable. Use it for the error message.
  837. if test -n "$first_python"; then
  838. error_exit "Cannot use '$first_python', Python >= 3.8 is required." \
  839. "Use --python=/path/to/python to specify a supported Python."
  840. else
  841. error_exit "Python not found. Use --python=/path/to/python"
  842. fi
  843. fi
  844. if ! check_py_version "$python"; then
  845. error_exit "Cannot use '$python', Python >= 3.8 is required." \
  846. "Use --python=/path/to/python to specify a supported Python." \
  847. "Maybe try:" \
  848. " openSUSE Leap 15.3+: zypper install python39" \
  849. " CentOS 8: dnf install python38"
  850. fi
  851. # Resolve PATH
  852. python="$(command -v "$python")"
  853. # Create a Python virtual environment using our configured python.
  854. # The stdout of this script will be the location of a symlink that
  855. # points to the configured Python.
  856. # Entry point scripts for pip, meson, and sphinx are generated if those
  857. # packages are present.
  858. # Defaults assumed for now:
  859. # - venv is cleared if it exists already;
  860. # - venv is allowed to use system packages;
  861. # - all setup can be performed offline;
  862. # - missing packages may be fetched from PyPI,
  863. # unless --disable-download is passed.
  864. # - pip is not installed into the venv when possible,
  865. # but ensurepip is called as a fallback when necessary.
  866. echo "python determined to be '$python'"
  867. echo "python version: $($python --version)"
  868. python="$($python -B "${source_path}/python/scripts/mkvenv.py" create pyvenv)"
  869. if test "$?" -ne 0 ; then
  870. error_exit "python venv creation failed"
  871. fi
  872. # Suppress writing compiled files
  873. python="$python -B"
  874. mkvenv="$python ${source_path}/python/scripts/mkvenv.py"
  875. # Finish preparing the virtual environment using vendored .whl files
  876. $mkvenv ensuregroup --dir "${source_path}/python/wheels" \
  877. ${source_path}/pythondeps.toml meson || exit 1
  878. # At this point, we expect Meson to be installed and available.
  879. # We expect mkvenv or pip to have created pyvenv/bin/meson for us.
  880. # We ignore PATH completely here: we want to use the venv's Meson
  881. # *exclusively*.
  882. meson="$(cd pyvenv/bin; pwd)/meson"
  883. # Conditionally ensure Sphinx is installed.
  884. mkvenv_online_flag=""
  885. if test "$download" = "enabled" ; then
  886. mkvenv_online_flag=" --online"
  887. fi
  888. if test "$docs" != "disabled" ; then
  889. if ! $mkvenv ensuregroup \
  890. $(test "$docs" = "enabled" && echo "$mkvenv_online_flag") \
  891. ${source_path}/pythondeps.toml docs;
  892. then
  893. if test "$docs" = "enabled" ; then
  894. exit 1
  895. fi
  896. echo "Sphinx not found/usable, disabling docs."
  897. docs=disabled
  898. else
  899. docs=enabled
  900. fi
  901. fi
  902. # Probe for ninja
  903. if test -z "$ninja"; then
  904. for c in ninja ninja-build samu; do
  905. if has $c; then
  906. ninja=$(command -v "$c")
  907. break
  908. fi
  909. done
  910. if test -z "$ninja"; then
  911. error_exit "Cannot find Ninja"
  912. fi
  913. fi
  914. if test "$host_os" = "bogus"; then
  915. # Now that we know that we're not printing the help and that
  916. # the compiler works (so the results of the check_defines we used
  917. # to identify the OS are reliable), if we didn't recognize the
  918. # host OS we should stop now.
  919. error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
  920. fi
  921. # test for any invalid configuration combinations
  922. if test "$host_os" = "windows" && ! has "$dlltool"; then
  923. if test "$plugins" = "yes"; then
  924. error_exit "TCG plugins requires dlltool to build on Windows platforms"
  925. fi
  926. plugins="no"
  927. fi
  928. if test "$tcg" = "disabled" ; then
  929. if test "$plugins" = "yes"; then
  930. error_exit "Can't enable plugins on non-TCG builds"
  931. fi
  932. plugins="no"
  933. fi
  934. if test "$static" = "yes" ; then
  935. if test "$plugins" = "yes"; then
  936. error_exit "static and plugins are mutually incompatible"
  937. fi
  938. plugins="no"
  939. fi
  940. if test "$plugins" != "no"; then
  941. plugins=yes
  942. subdirs="$subdirs contrib/plugins"
  943. fi
  944. cat > $TMPC << EOF
  945. #ifdef __linux__
  946. # define THREAD __thread
  947. #else
  948. # define THREAD
  949. #endif
  950. static THREAD int tls_var;
  951. int main(void) { return tls_var; }
  952. EOF
  953. if test "$host_os" = windows || test "$host_os" = haiku; then
  954. if test "$pie" = "yes"; then
  955. error_exit "PIE not available due to missing OS support"
  956. fi
  957. pie=no
  958. fi
  959. if test "$pie" != "no"; then
  960. if test "$static" = "yes"; then
  961. pie_ldflags=-static-pie
  962. else
  963. pie_ldflags=-pie
  964. fi
  965. if compile_prog "-Werror -fPIE -DPIE" "$pie_ldflags"; then
  966. pie="yes"
  967. elif test "$pie" = "yes"; then
  968. error_exit "-static-pie not available due to missing toolchain support"
  969. else
  970. echo "Disabling PIE due to missing toolchain support"
  971. pie="no"
  972. fi
  973. fi
  974. ##########################################
  975. if test -z "${target_list+xxx}" ; then
  976. default_targets=yes
  977. for target in $default_target_list; do
  978. target_list="$target_list $target"
  979. done
  980. target_list="${target_list# }"
  981. else
  982. default_targets=no
  983. target_list=$(echo "$target_list" | sed -e 's/,/ /g')
  984. for target in $target_list; do
  985. # Check that we recognised the target name; this allows a more
  986. # friendly error message than if we let it fall through.
  987. case " $default_target_list " in
  988. *" $target "*)
  989. ;;
  990. *)
  991. error_exit "Unknown target name '$target'"
  992. ;;
  993. esac
  994. done
  995. fi
  996. if test "$tcg" = "auto"; then
  997. if test -z "$target_list"; then
  998. tcg="disabled"
  999. else
  1000. tcg="enabled"
  1001. fi
  1002. fi
  1003. #########################################
  1004. # gdb test
  1005. if test -n "$gdb_bin"; then
  1006. gdb_version=$($gdb_bin --version | head -n 1)
  1007. if version_ge ${gdb_version##* } 9.1; then
  1008. gdb_arches=$($python "$source_path/scripts/probe-gdb-support.py" $gdb_bin)
  1009. else
  1010. gdb_bin=""
  1011. fi
  1012. fi
  1013. ##########################################
  1014. # big/little endian test
  1015. cat > $TMPC << EOF
  1016. #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  1017. # error LITTLE
  1018. #endif
  1019. int main(void) { return 0; }
  1020. EOF
  1021. if ! compile_prog ; then
  1022. bigendian="no"
  1023. else
  1024. cat > $TMPC << EOF
  1025. #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
  1026. # error BIG
  1027. #endif
  1028. int main(void) { return 0; }
  1029. EOF
  1030. if ! compile_prog ; then
  1031. bigendian="yes"
  1032. else
  1033. echo big/little test failed
  1034. exit 1
  1035. fi
  1036. fi
  1037. ##########################################
  1038. # functions to probe cross compilers
  1039. container="no"
  1040. runc=""
  1041. if test $use_containers = "yes" && (has "docker" || has "podman"); then
  1042. case $($python "$source_path"/tests/docker/docker.py --engine "$container_engine" probe) in
  1043. *docker) container=docker ;;
  1044. podman) container=podman ;;
  1045. no) container=no ;;
  1046. esac
  1047. if test "$container" != "no"; then
  1048. docker_py="$python $source_path/tests/docker/docker.py --engine $container"
  1049. runc=$container
  1050. fi
  1051. fi
  1052. # cross compilers defaults, can be overridden with --cross-cc-ARCH
  1053. : ${cross_prefix_aarch64="aarch64-linux-gnu-"}
  1054. : ${cross_prefix_aarch64_be="$cross_prefix_aarch64"}
  1055. : ${cross_prefix_alpha="alpha-linux-gnu-"}
  1056. : ${cross_prefix_arm="arm-linux-gnueabihf-"}
  1057. : ${cross_prefix_armeb="$cross_prefix_arm"}
  1058. : ${cross_prefix_hexagon="hexagon-unknown-linux-musl-"}
  1059. : ${cross_prefix_loongarch64="loongarch64-unknown-linux-gnu-"}
  1060. : ${cross_prefix_hppa="hppa-linux-gnu-"}
  1061. : ${cross_prefix_i386="i686-linux-gnu-"}
  1062. : ${cross_prefix_m68k="m68k-linux-gnu-"}
  1063. : ${cross_prefix_microblaze="microblaze-linux-musl-"}
  1064. : ${cross_prefix_mips64el="mips64el-linux-gnuabi64-"}
  1065. : ${cross_prefix_mips64="mips64-linux-gnuabi64-"}
  1066. : ${cross_prefix_mipsel="mipsel-linux-gnu-"}
  1067. : ${cross_prefix_mips="mips-linux-gnu-"}
  1068. : ${cross_prefix_ppc="powerpc-linux-gnu-"}
  1069. : ${cross_prefix_ppc64="powerpc64-linux-gnu-"}
  1070. : ${cross_prefix_ppc64le="$cross_prefix_ppc64"}
  1071. : ${cross_prefix_riscv64="riscv64-linux-gnu-"}
  1072. : ${cross_prefix_s390x="s390x-linux-gnu-"}
  1073. : ${cross_prefix_sh4="sh4-linux-gnu-"}
  1074. : ${cross_prefix_sparc64="sparc64-linux-gnu-"}
  1075. : ${cross_prefix_sparc="$cross_prefix_sparc64"}
  1076. : ${cross_prefix_tricore="tricore-"}
  1077. : ${cross_prefix_x86_64="x86_64-linux-gnu-"}
  1078. : ${cross_cc_aarch64_be="$cross_cc_aarch64"}
  1079. : ${cross_cc_cflags_aarch64_be="-mbig-endian"}
  1080. : ${cross_cc_armeb="$cross_cc_arm"}
  1081. : ${cross_cc_cflags_armeb="-mbig-endian"}
  1082. : ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
  1083. : ${cross_cc_cflags_hexagon="-mv73 -O2 -static"}
  1084. : ${cross_cc_cflags_i386="-m32"}
  1085. : ${cross_cc_cflags_ppc="-m32 -mbig-endian"}
  1086. : ${cross_cc_cflags_ppc64="-m64 -mbig-endian"}
  1087. : ${cross_cc_ppc64le="$cross_cc_ppc64"}
  1088. : ${cross_cc_cflags_ppc64le="-m64 -mlittle-endian"}
  1089. : ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"}
  1090. : ${cross_cc_sparc="$cross_cc_sparc64"}
  1091. : ${cross_cc_cflags_sparc="-m32 -mcpu=supersparc"}
  1092. : ${cross_cc_cflags_x86_64="-m64 -mcx16"}
  1093. compute_target_variable() {
  1094. eval "$2="
  1095. if eval test -n "\"\${cross_prefix_$1}\""; then
  1096. if eval has "\"\${cross_prefix_$1}\$3\""; then
  1097. eval "$2=\"\${cross_prefix_$1}\$3\""
  1098. fi
  1099. fi
  1100. }
  1101. have_target() {
  1102. for i; do
  1103. case " $target_list " in
  1104. *" $i "*) return 0;;
  1105. *) ;;
  1106. esac
  1107. done
  1108. return 1
  1109. }
  1110. # probe_target_compiler TARGET
  1111. #
  1112. # Look for a compiler for the given target, either native or cross.
  1113. # Set variables target_* if a compiler is found, and container_cross_*
  1114. # if a Docker-based cross-compiler image is known for the target.
  1115. # Set got_cross_cc to yes/no depending on whether a non-container-based
  1116. # compiler was found.
  1117. #
  1118. # If TARGET is a user-mode emulation target, also set build_static to
  1119. # "y" if static linking is possible.
  1120. #
  1121. probe_target_compiler() {
  1122. # reset all output variables
  1123. got_cross_cc=no
  1124. container_image=
  1125. container_hosts=
  1126. container_cross_prefix=
  1127. container_cross_cc=
  1128. container_cross_ar=
  1129. container_cross_as=
  1130. container_cross_ld=
  1131. container_cross_nm=
  1132. container_cross_objcopy=
  1133. container_cross_ranlib=
  1134. container_cross_strip=
  1135. target_arch=${1%%-*}
  1136. case $target_arch in
  1137. aarch64) container_hosts="x86_64 aarch64" ;;
  1138. alpha) container_hosts=x86_64 ;;
  1139. arm) container_hosts="x86_64 aarch64" ;;
  1140. cris) container_hosts=x86_64 ;;
  1141. hexagon) container_hosts=x86_64 ;;
  1142. hppa) container_hosts=x86_64 ;;
  1143. i386) container_hosts=x86_64 ;;
  1144. loongarch64) container_hosts=x86_64 ;;
  1145. m68k) container_hosts=x86_64 ;;
  1146. microblaze) container_hosts=x86_64 ;;
  1147. mips64el) container_hosts=x86_64 ;;
  1148. mips64) container_hosts=x86_64 ;;
  1149. mipsel) container_hosts=x86_64 ;;
  1150. mips) container_hosts=x86_64 ;;
  1151. ppc) container_hosts=x86_64 ;;
  1152. ppc64|ppc64le) container_hosts=x86_64 ;;
  1153. riscv64) container_hosts=x86_64 ;;
  1154. s390x) container_hosts=x86_64 ;;
  1155. sh4) container_hosts=x86_64 ;;
  1156. sparc64) container_hosts=x86_64 ;;
  1157. tricore) container_hosts=x86_64 ;;
  1158. x86_64) container_hosts="aarch64 ppc64le x86_64" ;;
  1159. xtensa*) container_hosts=x86_64 ;;
  1160. esac
  1161. for host in $container_hosts; do
  1162. test "$container" != no || continue
  1163. test "$host" = "$cpu" || continue
  1164. case $target_arch in
  1165. # debian-all-test-cross architectures
  1166. hppa|m68k|mips|riscv64|sparc64)
  1167. container_image=debian-all-test-cross
  1168. ;;
  1169. mips64)
  1170. container_image=debian-all-test-cross
  1171. container_cross_prefix=mips64-linux-gnuabi64-
  1172. ;;
  1173. ppc|ppc64|ppc64le)
  1174. container_image=debian-all-test-cross
  1175. container_cross_prefix=powerpc${target_arch#ppc}-linux-gnu-
  1176. ;;
  1177. # debian-legacy-test-cross architectures (need Debian 11)
  1178. # - libc6.1-dev-alpha-cross: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1054412
  1179. # - sh4-linux-user: binaries don't run with bookworm compiler
  1180. alpha|sh4)
  1181. container_image=debian-legacy-test-cross
  1182. ;;
  1183. # architectures with individual containers
  1184. aarch64)
  1185. # We don't have any bigendian build tools so we only use this for AArch64
  1186. container_image=debian-arm64-cross
  1187. ;;
  1188. arm)
  1189. # We don't have any bigendian build tools so we only use this for ARM
  1190. container_image=debian-armhf-cross
  1191. container_cross_prefix=arm-linux-gnueabihf-
  1192. ;;
  1193. cris)
  1194. container_image=fedora-cris-cross
  1195. ;;
  1196. hexagon)
  1197. container_cross_prefix=hexagon-unknown-linux-musl-
  1198. container_cross_cc=${container_cross_prefix}clang
  1199. ;;
  1200. i386)
  1201. container_image=debian-i686-cross
  1202. container_cross_prefix=i686-linux-gnu-
  1203. ;;
  1204. loongarch64)
  1205. container_image=debian-loongarch-cross
  1206. container_cross_prefix=loongarch64-unknown-linux-gnu-
  1207. ;;
  1208. microblaze)
  1209. container_cross_prefix=microblaze-linux-musl-
  1210. ;;
  1211. mips64el)
  1212. container_image=debian-mips64el-cross
  1213. container_cross_prefix=mips64el-linux-gnuabi64-
  1214. ;;
  1215. tricore)
  1216. container_image=debian-tricore-cross
  1217. container_cross_prefix=tricore-
  1218. ;;
  1219. x86_64)
  1220. container_image=debian-amd64-cross
  1221. ;;
  1222. xtensa*)
  1223. container_image=debian-xtensa-cross
  1224. # default to the dc232b cpu
  1225. container_cross_prefix=/opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-
  1226. ;;
  1227. esac
  1228. # Debian and GNU architecture names usually match
  1229. : ${container_image:=debian-$target_arch-cross}
  1230. : ${container_cross_prefix:=$target_arch-linux-gnu-}
  1231. : ${container_cross_cc:=${container_cross_prefix}gcc}
  1232. : ${container_cross_ar:=${container_cross_prefix}ar}
  1233. : ${container_cross_as:=${container_cross_prefix}as}
  1234. : ${container_cross_ld:=${container_cross_prefix}ld}
  1235. : ${container_cross_nm:=${container_cross_prefix}nm}
  1236. : ${container_cross_objcopy:=${container_cross_prefix}objcopy}
  1237. : ${container_cross_ranlib:=${container_cross_prefix}ranlib}
  1238. : ${container_cross_strip:=${container_cross_prefix}strip}
  1239. done
  1240. try=cross
  1241. # For softmmu/roms also look for a bi-endian or multilib-enabled host compiler
  1242. if [ "${1%softmmu}" != "$1" ] || test "$target_arch" = "$cpu"; then
  1243. case "$target_arch:$cpu" in
  1244. aarch64_be:aarch64 | \
  1245. armeb:arm | \
  1246. i386:x86_64 | \
  1247. mips*:mips64 | \
  1248. ppc*:ppc64 | \
  1249. sparc:sparc64 | \
  1250. "$cpu:$cpu")
  1251. try='native cross' ;;
  1252. esac
  1253. fi
  1254. eval "target_cflags=\${cross_cc_cflags_$target_arch}"
  1255. for thistry in $try; do
  1256. case $thistry in
  1257. native)
  1258. target_cc=$cc
  1259. target_ccas=$ccas
  1260. target_ar=$ar
  1261. target_as=$as
  1262. target_ld=$ld
  1263. target_nm=$nm
  1264. target_objcopy=$objcopy
  1265. target_ranlib=$ranlib
  1266. target_strip=$strip
  1267. ;;
  1268. cross)
  1269. target_cc=
  1270. if eval test -n "\"\${cross_cc_$target_arch}\""; then
  1271. if eval has "\"\${cross_cc_$target_arch}\""; then
  1272. eval "target_cc=\"\${cross_cc_$target_arch}\""
  1273. fi
  1274. else
  1275. compute_target_variable $target_arch target_cc gcc
  1276. fi
  1277. target_ccas=$target_cc
  1278. compute_target_variable $target_arch target_ar ar
  1279. compute_target_variable $target_arch target_as as
  1280. compute_target_variable $target_arch target_ld ld
  1281. compute_target_variable $target_arch target_nm nm
  1282. compute_target_variable $target_arch target_objcopy objcopy
  1283. compute_target_variable $target_arch target_ranlib ranlib
  1284. compute_target_variable $target_arch target_strip strip
  1285. ;;
  1286. esac
  1287. if test -n "$target_cc"; then
  1288. case $target_arch in
  1289. i386|x86_64)
  1290. if $target_cc --version | grep -qi "clang"; then
  1291. continue
  1292. fi
  1293. ;;
  1294. esac
  1295. elif test -n "$target_as" && test -n "$target_ld"; then
  1296. # Special handling for assembler only targets
  1297. case $target in
  1298. tricore-softmmu)
  1299. build_static=
  1300. got_cross_cc=yes
  1301. break
  1302. ;;
  1303. *)
  1304. continue
  1305. ;;
  1306. esac
  1307. else
  1308. continue
  1309. fi
  1310. write_c_skeleton
  1311. case $1 in
  1312. *-softmmu)
  1313. if do_compiler "$target_cc" $target_cflags -o $TMPO -c $TMPC &&
  1314. do_compiler "$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" -lgcc; then
  1315. got_cross_cc=yes
  1316. break
  1317. fi
  1318. ;;
  1319. *)
  1320. if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC -static ; then
  1321. build_static=y
  1322. got_cross_cc=yes
  1323. break
  1324. fi
  1325. if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC ; then
  1326. build_static=
  1327. got_cross_cc=yes
  1328. break
  1329. fi
  1330. ;;
  1331. esac
  1332. done
  1333. if test $got_cross_cc != yes; then
  1334. build_static=
  1335. target_cc=
  1336. target_ccas=
  1337. target_ar=
  1338. target_as=
  1339. target_ld=
  1340. target_nm=
  1341. target_objcopy=
  1342. target_ranlib=
  1343. target_strip=
  1344. fi
  1345. test -n "$target_cc"
  1346. }
  1347. write_target_makefile() {
  1348. echo "EXTRA_CFLAGS=$target_cflags"
  1349. if test -z "$target_cc" && test -z "$target_as"; then
  1350. test -z "$container_image" && error_exit "Internal error: could not find cross compiler for $1?"
  1351. echo "$1: docker-image-$container_image" >> Makefile.prereqs
  1352. if test -n "$container_cross_cc"; then
  1353. echo "CC=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
  1354. echo "CCAS=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
  1355. fi
  1356. echo "AR=$docker_py cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --"
  1357. echo "AS=$docker_py cc --cc $container_cross_as -i qemu/$container_image -s $source_path --"
  1358. echo "LD=$docker_py cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --"
  1359. echo "NM=$docker_py cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --"
  1360. echo "OBJCOPY=$docker_py cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --"
  1361. echo "RANLIB=$docker_py cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --"
  1362. echo "STRIP=$docker_py cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --"
  1363. else
  1364. if test -n "$target_cc"; then
  1365. echo "CC=$target_cc"
  1366. echo "CCAS=$target_ccas"
  1367. fi
  1368. if test -n "$target_ar"; then
  1369. echo "AR=$target_ar"
  1370. fi
  1371. if test -n "$target_as"; then
  1372. echo "AS=$target_as"
  1373. fi
  1374. if test -n "$target_ld"; then
  1375. echo "LD=$target_ld"
  1376. fi
  1377. if test -n "$target_nm"; then
  1378. echo "NM=$target_nm"
  1379. fi
  1380. if test -n "$target_objcopy"; then
  1381. echo "OBJCOPY=$target_objcopy"
  1382. fi
  1383. if test -n "$target_ranlib"; then
  1384. echo "RANLIB=$target_ranlib"
  1385. fi
  1386. if test -n "$target_strip"; then
  1387. echo "STRIP=$target_strip"
  1388. fi
  1389. fi
  1390. }
  1391. #######################################
  1392. # cross-compiled firmware targets
  1393. # Set up build tree symlinks that point back into the source tree
  1394. # (these can be both files and directories).
  1395. # Caution: avoid adding files or directories here using wildcards. This
  1396. # will result in problems later if a new file matching the wildcard is
  1397. # added to the source tree -- nothing will cause configure to be rerun
  1398. # so the build tree will be missing the link back to the new file, and
  1399. # tests might fail. Prefer to keep the relevant files in their own
  1400. # directory and symlink the directory instead.
  1401. LINKS="Makefile"
  1402. LINKS="$LINKS docs/config"
  1403. LINKS="$LINKS pc-bios/optionrom/Makefile"
  1404. LINKS="$LINKS pc-bios/s390-ccw/Makefile"
  1405. LINKS="$LINKS pc-bios/vof/Makefile"
  1406. LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
  1407. LINKS="$LINKS tests/avocado tests/data"
  1408. LINKS="$LINKS tests/qemu-iotests/check tests/qemu-iotests/Makefile"
  1409. LINKS="$LINKS python"
  1410. LINKS="$LINKS contrib/plugins/Makefile "
  1411. for f in $LINKS ; do
  1412. if [ -e "$source_path/$f" ]; then
  1413. symlink "$source_path/$f" "$f"
  1414. fi
  1415. done
  1416. # use included Linux headers for KVM architectures
  1417. if test "$host_os" = "linux" && test -n "$linux_arch"; then
  1418. symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
  1419. fi
  1420. echo "# Automatically generated by configure - do not modify" > Makefile.prereqs
  1421. # Mac OS X ships with a broken assembler
  1422. if have_target i386-softmmu x86_64-softmmu && \
  1423. test "$host_os" != "darwin" && test "$host_os" != "sunos" && \
  1424. test "$host_os" != "haiku" && \
  1425. probe_target_compiler i386-softmmu; then
  1426. subdirs="$subdirs pc-bios/optionrom"
  1427. config_mak=pc-bios/optionrom/config.mak
  1428. echo "# Automatically generated by configure - do not modify" > $config_mak
  1429. echo "TOPSRC_DIR=$source_path" >> $config_mak
  1430. write_target_makefile >> $config_mak
  1431. fi
  1432. if have_target ppc-softmmu ppc64-softmmu && \
  1433. probe_target_compiler ppc-softmmu; then
  1434. subdirs="$subdirs pc-bios/vof"
  1435. config_mak=pc-bios/vof/config.mak
  1436. echo "# Automatically generated by configure - do not modify" > $config_mak
  1437. echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak
  1438. write_target_makefile >> $config_mak
  1439. fi
  1440. # Only build s390-ccw bios if the compiler has -march=z900 or -march=z10
  1441. # (which is the lowest architecture level that Clang supports)
  1442. if have_target s390x-softmmu && probe_target_compiler s390x-softmmu && \
  1443. GIT=git "$source_path/scripts/git-submodule.sh" "$git_submodules_action" roms/SLOF >> config.log 2>&1; then
  1444. write_c_skeleton
  1445. do_compiler "$target_cc" $target_cc_cflags -march=z900 -o $TMPO -c $TMPC
  1446. has_z900=$?
  1447. if [ $has_z900 = 0 ] || do_compiler "$target_cc" $target_cc_cflags -march=z10 -msoft-float -Werror -o $TMPO -c $TMPC; then
  1448. if [ $has_z900 != 0 ]; then
  1449. echo "WARNING: Your compiler does not support the z900!"
  1450. echo " The s390-ccw bios will only work with guest CPUs >= z10."
  1451. fi
  1452. subdirs="$subdirs pc-bios/s390-ccw"
  1453. config_mak=pc-bios/s390-ccw/config-host.mak
  1454. echo "# Automatically generated by configure - do not modify" > $config_mak
  1455. echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak
  1456. echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_mak
  1457. write_target_makefile >> $config_mak
  1458. fi
  1459. fi
  1460. #######################################
  1461. # generate config-host.mak
  1462. config_host_mak="config-host.mak"
  1463. echo "# Automatically generated by configure - do not modify" > $config_host_mak
  1464. echo >> $config_host_mak
  1465. echo all: >> $config_host_mak
  1466. echo "SRC_PATH=$source_path" >> $config_host_mak
  1467. echo "TARGET_DIRS=$target_list" >> $config_host_mak
  1468. echo "GDB=$gdb_bin" >> $config_host_mak
  1469. if test "$container" != no; then
  1470. echo "RUNC=$runc" >> $config_host_mak
  1471. fi
  1472. echo "SUBDIRS=$subdirs" >> $config_host_mak
  1473. echo "PYTHON=$python" >> $config_host_mak
  1474. echo "MKVENV_ENSUREGROUP=$mkvenv ensuregroup $mkvenv_online_flag" >> $config_host_mak
  1475. echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
  1476. echo "MESON=$meson" >> $config_host_mak
  1477. echo "NINJA=$ninja" >> $config_host_mak
  1478. echo "EXESUF=$EXESUF" >> $config_host_mak
  1479. if test "$default_targets" = "yes"; then
  1480. echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
  1481. fi
  1482. # contrib/plugins configuration
  1483. echo "# Automatically generated by configure - do not modify" > contrib/plugins/$config_host_mak
  1484. echo "SRC_PATH=$source_path/contrib/plugins" >> contrib/plugins/$config_host_mak
  1485. echo "PKG_CONFIG=${pkg_config}" >> contrib/plugins/$config_host_mak
  1486. echo "CC=$cc $CPU_CFLAGS" >> contrib/plugins/$config_host_mak
  1487. echo "CFLAGS=${CFLAGS-$default_cflags} $EXTRA_CFLAGS" >> contrib/plugins/$config_host_mak
  1488. if test "$host_os" = windows; then
  1489. echo "DLLTOOL=$dlltool" >> contrib/plugins/$config_host_mak
  1490. fi
  1491. if test "$host_os" = darwin; then
  1492. echo "CONFIG_DARWIN=y" >> contrib/plugins/$config_host_mak
  1493. fi
  1494. if test "$host_os" = windows; then
  1495. echo "CONFIG_WIN32=y" >> contrib/plugins/$config_host_mak
  1496. fi
  1497. # tests/tcg configuration
  1498. mkdir -p tests/tcg
  1499. echo "# Automatically generated by configure - do not modify" > tests/tcg/$config_host_mak
  1500. echo "SRC_PATH=$source_path" >> tests/tcg/$config_host_mak
  1501. if test "$plugins" = "yes" ; then
  1502. echo "CONFIG_PLUGIN=y" >> tests/tcg/$config_host_mak
  1503. fi
  1504. tcg_tests_targets=
  1505. for target in $target_list; do
  1506. arch=${target%%-*}
  1507. case $target in
  1508. xtensa*-linux-user)
  1509. # the toolchain is not complete with headers, only build system tests
  1510. continue
  1511. ;;
  1512. *-softmmu)
  1513. test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" || continue
  1514. qemu="qemu-system-$arch"
  1515. ;;
  1516. *-linux-user|*-bsd-user)
  1517. qemu="qemu-$arch"
  1518. ;;
  1519. esac
  1520. if probe_target_compiler $target || test -n "$container_image"; then
  1521. test -n "$container_image" && build_static=y
  1522. mkdir -p "tests/tcg/$target"
  1523. config_target_mak=tests/tcg/$target/config-target.mak
  1524. ln -sf "$source_path/tests/tcg/Makefile.target" "tests/tcg/$target/Makefile"
  1525. echo "# Automatically generated by configure - do not modify" > "$config_target_mak"
  1526. echo "TARGET_NAME=$arch" >> "$config_target_mak"
  1527. echo "TARGET=$target" >> "$config_target_mak"
  1528. write_target_makefile "build-tcg-tests-$target" >> "$config_target_mak"
  1529. echo "BUILD_STATIC=$build_static" >> "$config_target_mak"
  1530. echo "QEMU=$PWD/$qemu" >> "$config_target_mak"
  1531. # will GDB work with these binaries?
  1532. if test "${gdb_arches#*$arch}" != "$gdb_arches"; then
  1533. echo "GDB=$gdb_bin" >> $config_target_mak
  1534. fi
  1535. echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs
  1536. tcg_tests_targets="$tcg_tests_targets $target"
  1537. fi
  1538. done
  1539. if test "$tcg" = "enabled"; then
  1540. echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> $config_host_mak
  1541. fi
  1542. if test "$skip_meson" = no; then
  1543. cross="config-meson.cross.new"
  1544. meson_quote() {
  1545. test $# = 0 && return
  1546. echo "'$(echo $* | sed "s/ /','/g")'"
  1547. }
  1548. echo "# Automatically generated by configure - do not modify" > $cross
  1549. echo "[properties]" >> $cross
  1550. # unroll any custom device configs
  1551. for a in $device_archs; do
  1552. eval "c=\$devices_${a}"
  1553. echo "${a}-softmmu = '$c'" >> $cross
  1554. done
  1555. echo "[built-in options]" >> $cross
  1556. echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
  1557. echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
  1558. test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
  1559. echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
  1560. echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
  1561. # Only enable by default for git builds and on select OSes
  1562. echo "# environment defaults, can still be overridden on " >> $cross
  1563. echo "# the command line" >> $cross
  1564. if test -e "$source_path/.git" && \
  1565. { test "$host_os" = linux || test "$host_os" = "windows"; }; then
  1566. echo 'werror = true' >> $cross
  1567. fi
  1568. echo "[project options]" >> $cross
  1569. if test "$SMBD" != ''; then
  1570. echo "smbd = $(meson_quote "$SMBD")" >> $cross
  1571. fi
  1572. if test "${QEMU_GA_MANUFACTURER}" != ''; then
  1573. echo "qemu_ga_manufacturer = $(meson_quote "${QEMU_GA_MANUFACTURER}")" >> $cross
  1574. fi
  1575. if test "${QEMU_GA_DISTRO}" != ''; then
  1576. echo "qemu_ga_distro = $(meson_quote "${QEMU_GA_DISTRO}")" >> $cross
  1577. fi
  1578. if test "${QEMU_GA_VERSION}" != ''; then
  1579. echo "qemu_ga_version = $(meson_quote "${QEMU_GA_VERSION}")" >> $cross
  1580. fi
  1581. echo >> $cross
  1582. echo "[binaries]" >> $cross
  1583. echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
  1584. test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
  1585. test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
  1586. echo "ar = [$(meson_quote $ar)]" >> $cross
  1587. echo "dlltool = [$(meson_quote $dlltool)]" >> $cross
  1588. echo "nm = [$(meson_quote $nm)]" >> $cross
  1589. echo "pkgconfig = [$(meson_quote $pkg_config)]" >> $cross
  1590. echo "pkg-config = [$(meson_quote $pkg_config)]" >> $cross
  1591. echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
  1592. if has $sdl2_config; then
  1593. echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
  1594. fi
  1595. echo "strip = [$(meson_quote $strip)]" >> $cross
  1596. echo "widl = [$(meson_quote $widl)]" >> $cross
  1597. echo "windres = [$(meson_quote $windres)]" >> $cross
  1598. echo "windmc = [$(meson_quote $windmc)]" >> $cross
  1599. if test "$cross_compile" = "yes"; then
  1600. echo "[host_machine]" >> $cross
  1601. echo "system = '$host_os'" >> $cross
  1602. case "$cpu" in
  1603. i386)
  1604. echo "cpu_family = 'x86'" >> $cross
  1605. ;;
  1606. *)
  1607. echo "cpu_family = '$cpu'" >> $cross
  1608. ;;
  1609. esac
  1610. echo "cpu = '$cpu'" >> $cross
  1611. if test "$bigendian" = "yes" ; then
  1612. echo "endian = 'big'" >> $cross
  1613. else
  1614. echo "endian = 'little'" >> $cross
  1615. fi
  1616. native="config-meson.native.new"
  1617. echo "# Automatically generated by configure - do not modify" > $native
  1618. echo "[binaries]" >> $native
  1619. echo "c = [$(meson_quote $host_cc)]" >> $native
  1620. mv $native config-meson.native
  1621. meson_option_add --native-file
  1622. meson_option_add config-meson.native
  1623. fi
  1624. mv $cross config-meson.cross
  1625. meson_add_machine_file config-meson.cross
  1626. if test -f "$source_path/configs/meson/$host_os.txt"; then
  1627. meson_add_machine_file $source_path/configs/meson/$host_os.txt
  1628. fi
  1629. rm -rf meson-private meson-info meson-logs
  1630. test "$download" = "disabled" && meson_option_add "--wrap-mode=nodownload"
  1631. test "$default_feature" = no && meson_option_add -Dauto_features=disabled
  1632. test "$static" = yes && meson_option_add -Dprefer_static=true
  1633. test "$pie" = no && meson_option_add -Db_pie=false
  1634. # QEMU options
  1635. test "$cfi" != false && meson_option_add "-Dcfi=$cfi" "-Db_lto=$cfi"
  1636. test "$docs" != auto && meson_option_add "-Ddocs=$docs"
  1637. test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
  1638. test "$plugins" = yes && meson_option_add "-Dplugins=true"
  1639. test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg"
  1640. run_meson() {
  1641. NINJA=$ninja $meson setup "$@" "$PWD" "$source_path"
  1642. }
  1643. eval run_meson $meson_options
  1644. if test "$?" -ne 0 ; then
  1645. error_exit "meson setup failed"
  1646. fi
  1647. echo "$meson" > build.ninja.stamp
  1648. else
  1649. if test -f meson-private/cmd_line.txt; then
  1650. # Adjust old command line options that were removed
  1651. # sed -i is not portable
  1652. perl -i -ne '
  1653. /^sphinx_build/ && next;
  1654. print;' meson-private/cmd_line.txt
  1655. fi
  1656. fi
  1657. # Save the configure command line for later reuse.
  1658. cat <<EOD >config.status
  1659. #!/bin/sh
  1660. # Generated by configure.
  1661. # Run this file to recreate the current configuration.
  1662. # Compiler output produced by configure, useful for debugging
  1663. # configure, is in config.log if it exists.
  1664. EOD
  1665. preserve_env() {
  1666. envname=$1
  1667. eval envval=\$$envname
  1668. if test -n "$envval"
  1669. then
  1670. echo "$envname='$envval'" >> config.status
  1671. echo "export $envname" >> config.status
  1672. else
  1673. echo "unset $envname" >> config.status
  1674. fi
  1675. }
  1676. # Preserve various env variables that influence what
  1677. # features/build target configure will detect
  1678. preserve_env AR
  1679. preserve_env AS
  1680. preserve_env CC
  1681. preserve_env CFLAGS
  1682. preserve_env CXX
  1683. preserve_env CXXFLAGS
  1684. preserve_env DLLTOOL
  1685. preserve_env LD
  1686. preserve_env LDFLAGS
  1687. preserve_env LD_LIBRARY_PATH
  1688. preserve_env NM
  1689. preserve_env OBJCFLAGS
  1690. preserve_env OBJCOPY
  1691. preserve_env PATH
  1692. preserve_env PKG_CONFIG
  1693. preserve_env PKG_CONFIG_LIBDIR
  1694. preserve_env PKG_CONFIG_PATH
  1695. preserve_env PYTHON
  1696. preserve_env QEMU_GA_MANUFACTURER
  1697. preserve_env QEMU_GA_DISTRO
  1698. preserve_env QEMU_GA_VERSION
  1699. preserve_env SDL2_CONFIG
  1700. preserve_env SMBD
  1701. preserve_env STRIP
  1702. preserve_env WIDL
  1703. preserve_env WINDRES
  1704. preserve_env WINDMC
  1705. printf "exec" >>config.status
  1706. for i in "$0" "$@"; do
  1707. test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
  1708. done
  1709. echo ' "$@"' >>config.status
  1710. chmod +x config.status
  1711. rm -r "$TMPDIR1"