Seeking QEMU makefile advice
Hi Paolo,
I'm trying to resolve a FIXME in a patch I recently posted. Here's what I want to do:
QAPI_COMMON_MODULES = block-core block char common crypto introspect
QAPI_COMMON_MODULES += job migration misc net rdma rocker run-state
QAPI_COMMON_MODULES += sockets tpm trace transaction ui
QAPI_TARGET_MODULES = target
QAPI_MODULES = $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES)
util-obj-y += qapi/qapi-builtin-types.o
util-obj-y += $(QAPI_COMMON_MODULES:%=qapi/qapi-types-%.o)
util-obj-y += qapi/qapi-builtin-visit.o
util-obj-y += $(QAPI_COMMON_MODULES:%=qapi/qapi-visit-%.o)
util-obj-y += qapi/qapi-emit-events.o
util-obj-y += $(QAPI_COMMON_MODULES:%=qapi/qapi-events-%.o)
obj-y += $(QAPI_TARGET_MODULES:%=qapi/qapi-types-%.o)
obj-y += qapi/qapi-types.o
obj-y += $(QAPI_TARGET_MODULES:%=qapi/qapi-visit-%.o)
obj-y += qapi/qapi-visit.o
obj-y += $(QAPI_TARGET_MODULES:%=qapi/qapi-events-%.o)
obj-y += qapi/qapi-events.o
obj-y += $(QAPI_TARGET_MODULES:%=qapi/qapi-commands-%.o)
obj-y += qapi/qapi-commands.o
obj-y += qapi/qapi-introspect.oSimple enough, except which part goes where?
First attempt:
* Define QAPI_COMMON_MODULES, QAPI_TARGET_MODULES and QAPI_MODULES in Makefile.obj
* Add to util-obj-y in Makefile.obj
* Add to obj-y in Makefile.target
No go, because QAPI_TARGET_MODULES is blank there. To make progress, I duplicated its definition there, marked FIXME.
Message-Id: <[email protected]>
https://lists.nongnu.org/archive/html/qemu-devel/2019-02/msg01652.html
Diff appended for your convenience.
I've since realized QAPI_TARGET_MODULES is blank there because it only gets defined further down, via include $(SRC_PATH)/Makefile.objs.
This leads me to my problem:
* On the one hand, I want to add to obj-y after the include defines QAPI_TARGET_MODULES.
* On the other hand, I need to be done with adding to obj-y before the all-obj-y := $(obj-y) line.
Can't satisfy both. Any ideas on how to better distribute the work between the makefiles?
Makefile.objs +9 -11
@@ -1,20 +1,19 @@ -QAPI_MODULES = block-core block char common crypto introspect job migration -QAPI_MODULES += misc net rdma rocker run-state sockets tpm trace transaction -QAPI_MODULES += ui +QAPI_COMMON_MODULES = block-core block char common crypto introspect +QAPI_COMMON_MODULES += job migration misc net rdma rocker run-state +QAPI_COMMON_MODULES += sockets tpm trace transaction ui +QAPI_TARGET_MODULES = target +QAPI_MODULES = $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES) ####################################################################### # Common libraries for tools and emulators stub-obj-y = stubs/ crypto/ util-obj-y = util/ qobject/ qapi/ util-obj-y += qapi/qapi-builtin-types.o -util-obj-y += qapi/qapi-types.o -util-obj-y += $(QAPI_MODULES:%=qapi/qapi-types-%.o) +util-obj-y += $(QAPI_COMMON_MODULES:%=qapi/qapi-types-%.o) util-obj-y += qapi/qapi-builtin-visit.o -util-obj-y += qapi/qapi-visit.o -util-obj-y += $(QAPI_MODULES:%=qapi/qapi-visit-%.o) +util-obj-y += $(QAPI_COMMON_MODULES:%=qapi/qapi-visit-%.o) util-obj-y += qapi/qapi-emit-events.o -util-obj-y += qapi/qapi-events.o -util-obj-y += $(QAPI_MODULES:%=qapi/qapi-events-%.o) +util-obj-y += $(QAPI_COMMON_MODULES:%=qapi/qapi-events-%.o) chardev-obj-y = chardev/ slirp-obj-$(CONFIG_SLIRP) = slirp/
@@ -92,8 +91,7 @@ common-obj-$(CONFIG_FDT) += device_tree.o ###################################################################### # qapi -common-obj-y += qapi/qapi-commands.o -common-obj-y += $(QAPI_MODULES:%=qapi/qapi-commands-%.o) +common-obj-y += $(QAPI_COMMON_MODULES:%=qapi/qapi-commands-%.o) common-obj-y += qmp.o hmp.o endif
Makefile.target +10 -0
@@ -164,6 +164,16 @@ endif GENERATED_FILES += hmp-commands.h hmp-commands-info.h +# FIXME duplicates Makefile.obj's +QAPI_TARGET_MODULES = target +obj-y += $(QAPI_TARGET_MODULES:%=qapi/qapi-types-%.o) +obj-y += qapi/qapi-types.o +obj-y += $(QAPI_TARGET_MODULES:%=qapi/qapi-visit-%.o) +obj-y += qapi/qapi-visit.o +obj-y += $(QAPI_TARGET_MODULES:%=qapi/qapi-events-%.o) +obj-y += qapi/qapi-events.o +obj-y += $(QAPI_TARGET_MODULES:%=qapi/qapi-commands-%.o) +obj-y += qapi/qapi-commands.o obj-y += qapi/qapi-introspect.o endif # CONFIG_SOFTMMU
qapi/qapi-schema.json +1 -0
@@ -97,3 +97,4 @@ { 'include': 'trace.json' } { 'include': 'introspect.json' } { 'include': 'misc.json' } +{ 'include': 'target.json' }
qapi/target.json new file +13 -0
@@ -0,0 +1,13 @@ +# -*- Mode: Python -*- +# + +## +# = Target-specific commands & events +## + +## +# @TARGET-TEMPORARY-DUMMY: +# Will go away in the next commit. Needed in this one because empty +# modules don't generate anything, defeating this commit's purpose. +## +{ 'event': 'TARGET-TEMPORARY-DUMMY' }
Quoted 6 lines · Markus Armbruster
* Define
QAPI_COMMON_MODULES,QAPI_TARGET_MODULESandQAPI_MODULESin Makefile.obj* Add to util-obj-y in Makefile.obj
* Add to obj-y in Makefile.target
Why can't both be in Makefile.objs, or in qapi/Makefile.objs?
Paolo
Quoted 20 lines
No go, because
QAPI_TARGET_MODULESis blank there. To make progress, I duplicated its definition there, marked FIXME.Message-Id: <[email protected]>
https://lists.nongnu.org/archive/html/qemu-devel/2019-02/msg01652.html
Diff appended for your convenience.I've since realized
QAPI_TARGET_MODULESis blank there because it only gets defined further down, via include $(SRC_PATH)/Makefile.objs.This leads me to my problem:
* On the one hand, I want to add to obj-y after the include defines
QAPI_TARGET_MODULES.* On the other hand, I need to be done with adding to obj-y before the all-obj-y := $(obj-y) line.
Can't satisfy both. Any ideas on how to better distribute the work between the makefiles?
Quoted 9 lines · Paolo Bonzini
Quoted 6 lines · Markus Armbruster
* Define
QAPI_COMMON_MODULES,QAPI_TARGET_MODULESandQAPI_MODULESin Makefile.obj* Add to util-obj-y in Makefile.obj
* Add to obj-y in Makefile.target
Why can't both be in Makefile.objs, or in qapi/Makefile.objs?
When I try either place, I get
LINK x86_64-softmmu/qemu-system-x86_64
monitor.o: In function `qmp_query_qmp_schema':
/work/armbru/qemu/monitor.c:1136: undefined reference to `qmp_schema_qlit' [more errors...]
Compiling with V=1 confirms qapi-introspect.o isn't in $(all-obj-y).
I think this is the case because Makefile.target has
all-obj-y := $(obj-y)
before
include $(SRC_PATH)/Makefile.objs
If I move the former below the latter (without really understanding the consequences), I get
make[1]: *** No rule to make target '9pfs/', needed by 'qemu-system-x86_64'.
make[1]: *** No rule to make target 'acpi/', needed by 'qemu-system-x86_64'.
make[1]: *** No rule to make target 'adc/', needed by 'qemu-system-x86_64'.
[many, many more...]What now?
Quoted 12 lines · Markus Armbruster
Quoted 9 lines · Paolo Bonzini
Quoted 6 lines · Markus Armbruster
* Define
QAPI_COMMON_MODULES,QAPI_TARGET_MODULESandQAPI_MODULESin Makefile.obj* Add to util-obj-y in Makefile.obj
* Add to obj-y in Makefile.target
Why can't both be in Makefile.objs, or in qapi/Makefile.objs?
Quoted 8 lines
When I try either place, I get
LINK x86_64-softmmu/qemu-system-x86_64
monitor.o: In function `qmp_query_qmp_schema':
/work/armbru/qemu/monitor.c:1136: undefined reference to `qmp_schema_qlit' [more errors...]Compiling with V=1 confirms qapi-introspect.o isn't in $(all-obj-y).
Oh, ok. Then I suggest placing it in qapi/Makefile.objs, and you'll have to add "obj-y += qapi/" in Makefile.target (I'm not sure if it's under "ifdef CONFIG_SOFTMMU" or outside, but you'd know that).
Thanks,
Paolo
Quoted 18 lines
I think this is the case because Makefile.target has
all-obj-y := $(obj-y)before
include $(SRC_PATH)/Makefile.objsIf I move the former below the latter (without really understanding the consequences), I get
make[1]: *** No rule to make target '9pfs/', needed by 'qemu-system-x86_64'. make[1]: *** No rule to make target 'acpi/', needed by 'qemu-system-x86_64'. make[1]: *** No rule to make target 'adc/', needed by 'qemu-system-x86_64'. [many, many more...]What now?
Quoted 20 lines · Paolo Bonzini
Quoted 19 lines · Markus Armbruster
Quoted 9 lines · Paolo Bonzini
Quoted 6 lines · Markus Armbruster
* Define
QAPI_COMMON_MODULES,QAPI_TARGET_MODULESandQAPI_MODULESin Makefile.obj* Add to util-obj-y in Makefile.obj
* Add to obj-y in Makefile.target
Why can't both be in Makefile.objs, or in qapi/Makefile.objs?
When I try either place, I get
LINK x86_64-softmmu/qemu-system-x86_64
monitor.o: In function `qmp_query_qmp_schema':
/work/armbru/qemu/monitor.c:1136: undefined reference to `qmp_schema_qlit' [more errors...]
Quoted 5 lines
Quoted 1 line
Compiling with V=1 confirms qapi-introspect.o isn't in $(all-obj-y).
Oh, ok. Then I suggest placing it in qapi/Makefile.objs, and you'll have to add "obj-y += qapi/" in Makefile.target (I'm not sure if it's under "ifdef
CONFIG_SOFTMMU" or outside, but you'd know that).
I think I got that to work. Thanks for your help!