Skip to content

Commit c36dd41

Browse files
committed
configure: move target-specific defaults to an external machine file
Enable Windows-specific defaults with a machine file, so that related options can be automatically parsed and included in the help message. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 050b439 commit c36dd41

File tree

4 files changed

+34
-23
lines changed

4 files changed

+34
-23
lines changed

configs/meson/windows.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# target-specific defaults, can still be overridden on
2+
# the command line
3+
4+
[built-in options]
5+
bindir = ''
6+
prefix = '/qemu'
7+
8+
[project options]
9+
qemu_suffix = ''

configure

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,6 @@ default_cflags='-O2 -g'
246246
git_submodules_action="update"
247247
docs="auto"
248248
EXESUF=""
249-
prefix="/usr/local"
250-
qemu_suffix="qemu"
251249
system="yes"
252250
linux_user=""
253251
bsd_user=""
@@ -256,7 +254,6 @@ subdirs=""
256254
ninja=""
257255
python=
258256
download="enabled"
259-
bindir="bin"
260257
skip_meson=no
261258
use_containers="yes"
262259
gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
@@ -583,9 +580,6 @@ done
583580

584581
if test "$targetos" = "windows" ; then
585582
EXESUF=".exe"
586-
prefix="/qemu"
587-
bindir=""
588-
qemu_suffix=""
589583
fi
590584

591585
meson_option_build_array() {
@@ -622,15 +616,21 @@ meson_option_parse() {
622616
fi
623617
}
624618

619+
meson_add_machine_file() {
620+
if test "$cross_compile" = "yes"; then
621+
meson_option_add --cross-file "$1"
622+
else
623+
meson_option_add --native-file "$1"
624+
fi
625+
}
626+
625627
for opt do
626628
optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
627629
case "$opt" in
628630
--help|-h) show_help=yes
629631
;;
630632
--version|-V) exec cat "$source_path/VERSION"
631633
;;
632-
--prefix=*) prefix="$optarg"
633-
;;
634634
--cross-prefix=*)
635635
;;
636636
--cc=*)
@@ -701,10 +701,6 @@ for opt do
701701
;;
702702
--static) static="yes"
703703
;;
704-
--bindir=*) bindir="$optarg"
705-
;;
706-
--with-suffix=*) qemu_suffix="$optarg"
707-
;;
708704
--host=*|--build=*|\
709705
--disable-dependency-tracking|\
710706
--sbindir=*|--sharedstatedir=*|\
@@ -861,7 +857,6 @@ Options: [defaults in brackets after descriptions]
861857
862858
Standard options:
863859
--help print this message
864-
--prefix=PREFIX install in PREFIX [$prefix]
865860
--target-list=LIST set target list (default: build all)
866861
$(echo Available targets: $default_target_list | \
867862
fold -s -w 53 | sed -e 's/^/ /')
@@ -886,8 +881,6 @@ Advanced options (experts only):
886881
--ninja=NINJA use specified ninja [$ninja]
887882
--smbd=SMBD use specified smbd [$smbd]
888883
--static enable static build [$static]
889-
--bindir=PATH install binaries in PATH
890-
--with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
891884
--without-default-features default all --enable-* options to "disabled"
892885
--without-default-devices do not include any device that is not needed to
893886
start the emulator (only use if you are including
@@ -1803,24 +1796,25 @@ if test "$skip_meson" = no; then
18031796
else
18041797
echo "endian = 'little'" >> $cross
18051798
fi
1806-
cross_arg="--cross-file config-meson.cross"
18071799

18081800
native="config-meson.native.new"
18091801
echo "# Automatically generated by configure - do not modify" > $native
18101802
echo "[binaries]" >> $native
18111803
echo "c = [$(meson_quote $host_cc)]" >> $native
18121804
mv $native config-meson.native
1813-
cross_arg="$cross_arg --native-file config-meson.native"
1814-
else
1815-
cross_arg="--native-file config-meson.cross"
1805+
meson_option_add --native-file
1806+
meson_option_add config-meson.native
18161807
fi
18171808
mv $cross config-meson.cross
1809+
meson_add_machine_file config-meson.cross
1810+
if test -f "$source_path/configs/meson/$targetos.txt"; then
1811+
meson_add_machine_file $source_path/configs/meson/$targetos.txt
1812+
fi
18181813

18191814
rm -rf meson-private meson-info meson-logs
18201815

18211816
# Built-in options
18221817
test "$download" = "disabled" && meson_option_add "--wrap-mode=nodownload"
1823-
test "$bindir" != "bin" && meson_option_add "-Dbindir=$bindir"
18241818
test "$default_feature" = no && meson_option_add -Dauto_features=disabled
18251819
test "$static" = yes && meson_option_add -Dprefer_static=true
18261820
test "$pie" = no && meson_option_add -Db_pie=false
@@ -1831,11 +1825,10 @@ if test "$skip_meson" = no; then
18311825
test "$docs" != auto && meson_option_add "-Ddocs=$docs"
18321826
test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
18331827
test "$plugins" = yes && meson_option_add "-Dplugins=true"
1834-
test "$qemu_suffix" != qemu && meson_option_add "-Dqemu_suffix=$qemu_suffix"
18351828
test "$smbd" != '' && meson_option_add "-Dsmbd=$smbd"
18361829
test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg"
18371830
run_meson() {
1838-
NINJA=$ninja $meson setup --prefix "$prefix" "$@" $cross_arg "$PWD" "$source_path"
1831+
NINJA=$ninja $meson setup "$@" "$PWD" "$source_path"
18391832
}
18401833
eval run_meson $meson_options
18411834
if test "$?" -ne 0 ; then

scripts/meson-buildoptions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
SKIP_OPTIONS = {
2929
"default_devices",
3030
"fuzzing_engine",
31-
"qemu_suffix",
3231
"smbd",
3332
}
3433

@@ -40,6 +39,7 @@
4039
"malloc": "enable-malloc",
4140
"pkgversion": "with-pkgversion",
4241
"qemu_firmwarepath": "firmwarepath",
42+
"qemu_suffix": "with-suffix",
4343
"trace_backends": "enable-trace-backends",
4444
"trace_file": "with-trace-file",
4545
}
@@ -52,6 +52,7 @@
5252
BUILTIN_OPTIONS = {
5353
"b_coverage",
5454
"b_lto",
55+
"bindir",
5556
"datadir",
5657
"debug",
5758
"includedir",
@@ -60,6 +61,7 @@
6061
"localedir",
6162
"localstatedir",
6263
"mandir",
64+
"prefix",
6365
"strip",
6466
"sysconfdir",
6567
}

scripts/meson-buildoptions.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ meson_options_help() {
33
printf "%s\n" ' --audio-drv-list=CHOICES Set audio driver list [default] (choices: alsa/co'
44
printf "%s\n" ' reaudio/default/dsound/jack/oss/pa/pipewire/sdl/s'
55
printf "%s\n" ' ndio)'
6+
printf "%s\n" ' --bindir=VALUE Executable directory [bin]'
67
printf "%s\n" ' --block-drv-ro-whitelist=VALUE'
78
printf "%s\n" ' set block driver read-only whitelist (by default'
89
printf "%s\n" ' affects only QEMU, not tools like qemu-img)'
@@ -62,13 +63,16 @@ meson_options_help() {
6263
printf "%s\n" ' --localedir=VALUE Locale data directory [share/locale]'
6364
printf "%s\n" ' --localstatedir=VALUE Localstate data directory [/var/local]'
6465
printf "%s\n" ' --mandir=VALUE Manual page directory [share/man]'
66+
printf "%s\n" ' --prefix=VALUE Installation prefix [/usr/local]'
6567
printf "%s\n" ' --sysconfdir=VALUE Sysconf data directory [etc]'
6668
printf "%s\n" ' --tls-priority=VALUE Default TLS protocol/cipher priority string'
6769
printf "%s\n" ' [NORMAL]'
6870
printf "%s\n" ' --with-coroutine=CHOICE coroutine backend to use (choices:'
6971
printf "%s\n" ' auto/sigaltstack/ucontext/windows)'
7072
printf "%s\n" ' --with-pkgversion=VALUE use specified string as sub-version of the'
7173
printf "%s\n" ' package'
74+
printf "%s\n" ' --with-suffix=VALUE Suffix for QEMU data/modules/config directories'
75+
printf "%s\n" ' (can be empty) [qemu]'
7276
printf "%s\n" ' --with-trace-file=VALUE Trace file prefix for simple backend [trace]'
7377
printf "%s\n" ''
7478
printf "%s\n" 'Optional features, enabled with --enable-FEATURE and'
@@ -229,6 +233,7 @@ _meson_option_parse() {
229233
--disable-gcov) printf "%s" -Db_coverage=false ;;
230234
--enable-lto) printf "%s" -Db_lto=true ;;
231235
--disable-lto) printf "%s" -Db_lto=false ;;
236+
--bindir=*) quote_sh "-Dbindir=$2" ;;
232237
--enable-blkio) printf "%s" -Dblkio=enabled ;;
233238
--disable-blkio) printf "%s" -Dblkio=disabled ;;
234239
--block-drv-ro-whitelist=*) quote_sh "-Dblock_drv_ro_whitelist=$2" ;;
@@ -407,13 +412,15 @@ _meson_option_parse() {
407412
--disable-plugins) printf "%s" -Dplugins=false ;;
408413
--enable-png) printf "%s" -Dpng=enabled ;;
409414
--disable-png) printf "%s" -Dpng=disabled ;;
415+
--prefix=*) quote_sh "-Dprefix=$2" ;;
410416
--enable-pvrdma) printf "%s" -Dpvrdma=enabled ;;
411417
--disable-pvrdma) printf "%s" -Dpvrdma=disabled ;;
412418
--enable-qcow1) printf "%s" -Dqcow1=enabled ;;
413419
--disable-qcow1) printf "%s" -Dqcow1=disabled ;;
414420
--enable-qed) printf "%s" -Dqed=enabled ;;
415421
--disable-qed) printf "%s" -Dqed=disabled ;;
416422
--firmwarepath=*) quote_sh "-Dqemu_firmwarepath=$(meson_option_build_array $2)" ;;
423+
--with-suffix=*) quote_sh "-Dqemu_suffix=$2" ;;
417424
--enable-qga-vss) printf "%s" -Dqga_vss=enabled ;;
418425
--disable-qga-vss) printf "%s" -Dqga_vss=disabled ;;
419426
--enable-qom-cast-debug) printf "%s" -Dqom_cast_debug=true ;;

0 commit comments

Comments
 (0)