Skip to contentSkip to conversation

Makefile: Do not generate files if "configure" has not been run yet

PATCH Superseded Thomas Huth 2 participants 3 messages Jun 7, 2017 – Jun 8, 2017 Kbuild

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: Do not generate files if "configure" has not been run yet

When doing a "make -j10" in the vanilla QEMU source tree (without running "configure first), the Makefile currently generates two files already, qemu-version.h and qemu-options.def. This should not happen, so let's make these targets depend on config-host.mak. Also the python files can not be executed without $(PYTHON), so these scripts should depend on config-host.mak, too.

---
 Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Makefile +4 -1
index c830d7a..6786dc2 100644
@@ -286,7 +286,7 @@ endif
 
 all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
 
-qemu-version.h: FORCE
+qemu-version.h: config-host.mak FORCE
 	$(call quiet-command, \
 		(cd $(SRC_PATH); \
 		printf '#define QEMU_PKGVERSION '; \
@@ -312,6 +312,7 @@ qemu-version.h: FORCE
 
 config-host.h: config-host.h-timestamp
 config-host.h-timestamp: config-host.mak
+qemu-options.def: config-host.mak
 qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
 
@@ -393,6 +394,8 @@ gen-out-type = $(subst .,-,$(suffix $@))
 
 qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
 
+$(qapi-py): config-host.mak
+
 qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
 $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 2 lines · Thomas Huth

When doing a "make -j10" in the vanilla QEMU source tree (without running "configure first), the Makefile currently generates two

s/"configure/"configure"/

Quoted 15 lines

files already, qemu-version.h and qemu-options.def. This should not happen, so let's make these targets depend on config-host.mak. Also the python files can not be executed without $(PYTHON), so these scripts should depend on config-host.mak, too.

---
 Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Makefile +0 -0
index c830d7a..6786dc2 100644

Makefile endif · line 289

Quoted 5 lines
Makefile +1 -1
@@ -286,7 +286,7 @@ endif
 
 all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
 
-qemu-version.h: FORCE
+qemu-version.h: config-host.mak FORCE

This one makes sense.

Makefile gen-out-type = $(subst .,-,$(suffix $@)) · line 397

Quoted 5 lines
Makefile +1 -0
@@ -393,6 +394,8 @@ gen-out-type = $(subst .,-,$(suffix $@))
 
 qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
 
+$(qapi-py): config-host.mak

But this one is weird. How can a pre-existing file have a dependency? Remember, $(qapi-py) is not the list of built files, but the list of files used to build other files. It seems like you either want config-host.mak includes in $(qapi-py), or...

Makefile gen-out-type = $(subst .,-,$(suffix $@)) · line 400

Quoted 3 lines
Makefile +1 -0
+
 qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
 $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)

...that THIS should be the rule that depends on config-host.mak in addition do depending on $(qapi-py).

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#2 lore raw
Quoted 40 lines · Eric Blake
Quoted 2 lines · Thomas Huth

When doing a "make -j10" in the vanilla QEMU source tree (without running "configure first), the Makefile currently generates two

s/"configure/"configure"/

Quoted 15 lines

files already, qemu-version.h and qemu-options.def. This should not happen, so let's make these targets depend on config-host.mak. Also the python files can not be executed without $(PYTHON), so these scripts should depend on config-host.mak, too.

---
 Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Makefile +0 -0
index c830d7a..6786dc2 100644

Makefile endif · line 289

Quoted 5 lines
Makefile +1 -1
@@ -286,7 +286,7 @@ endif
 
 all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
 
-qemu-version.h: FORCE
+qemu-version.h: config-host.mak FORCE

This one makes sense.

Makefile gen-out-type = $(subst .,-,$(suffix $@)) · line 397

Quoted 5 lines
Makefile +1 -0
@@ -393,6 +394,8 @@ gen-out-type = $(subst .,-,$(suffix $@))
 
 qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
 
+$(qapi-py): config-host.mak

But this one is weird. How can a pre-existing file have a dependency? Remember, $(qapi-py) is not the list of built files, but the list of files used to build other files. It seems like you either want config-host.mak includes in $(qapi-py), or...

Quoted 6 lines

Makefile gen-out-type = $(subst .,-,$(suffix $@)) · line 400

Quoted 3 lines
Makefile +1 -0
+
 qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
 $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)

...that THIS should be the rule that depends on config-host.mak in addition do depending on $(qapi-py).

Yes, it's all those targets that use $(PYTHON) which should depend on config-host.mak instead. But there are lots of them, and all of them depend on $(qapi-py) already, so it seemed simpler to make $(qapy-py) depend on config-host.mak instead of adding that dependency to all those targets ... but maybe that's too confusing in the long run, so I'll add it to those targets instead.

Thomas