qemu timestamp and related makefile cleanups
cover qemu timestamp and related makefile cleanups
I recently had some build failures because of a stable timestamp file. The following patchset addresses some of the issue I found when going over the makefiles.
Michael S. Tsirkin (4):
rules.mak: cleanup config generation rules
Makefile: clean timestamp generation rule rules/mak: make clean should blow away timestamp files
Makefile: fix make clean on libcacard
libcacard/Makefile | 2 +- rules.mak | 14 +++++++++----- trace/Makefile.objs | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-)
Signature · 1 line
MST
PATCH 1/4 rules.mak: cleanup config generation rules
This addresses two issues with config generation
1. rule generating timestamp has side effect. Thus cleanup on error does not work.
2. rule for handling timestamp is too generic. It can create any missing .h file.
As a result when .h file is removed, build might try to create it using this rule which results in build errors.
--- rules.mak | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
rules.mak +4 -5
@@ -82,12 +82,11 @@ TRACETOOL=$(PYTHON) $(SRC_PATH)/scripts/tracetool.py # Generate timestamp files for .h include files -%.h: %.h-timestamp - @test -f $@ || cp $< $@ +config-%.h: config-%.h-timestamp + @cmp $< $@ >/dev/null 2>&1 || cp $< $@ -%.h-timestamp: %.mak - $(call quiet-command, sh $(SRC_PATH)/scripts/create_config < $< > $@, " GEN $(TARGET_DIR)$*.h") - @cmp $@ $*.h >/dev/null 2>&1 || cp $@ $*.h +config-%.h-timestamp: config-%.mak + $(call quiet-command, sh $(SRC_PATH)/scripts/create_config < $< > $@, " GEN $(TARGET_DIR)config-$*.h") # will delete the target of a rule if commands exit with a nonzero exit status .DELETE_ON_ERROR:
Signature · 1 line
MST
PATCH 4/4 Makefile: fix make clean on libcacard
In reply to Michael S. Tsirkinlibcacard lacks a clean target. Need to fix it,
meanwhile mark this target phony so it does not
stop parallel make clean.
--- libcacard/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libcacard/Makefile +1 -1
@@ -35,7 +35,7 @@ libcacard.pc: $(SRC_PATH)/libcacard/libcacard.pc.in -e 's|@PREFIX@|$(prefix)|' $< > libcacard.pc,\ " GEN $@") -.PHONY: install-libcacard +.PHONY: install-libcacard clean install: install-libcacard install-libcacard: libcacard.pc libcacard.la
Signature · 1 line
MST
PATCH 3/4 rules/mak: make clean should blow away timestamp files
In reply to Michael S. TsirkinUsing a global pattern makes it easier to clean out old generated files.
--- rules.mak | 5 +++++ 1 file changed, 5 insertions(+)
rules.mak +5 -0
@@ -88,6 +88,11 @@ config-%.h: config-%.h-timestamp config-%.h-timestamp: config-%.mak $(call quiet-command, sh $(SRC_PATH)/scripts/create_config < $< > $@, " GEN $(TARGET_DIR)config-$*.h") +.PHONY: clean-timestamp +clean-timestamp: + rm -f *.timestamp +clean: clean-timestamp + # will delete the target of a rule if commands exit with a nonzero exit status .DELETE_ON_ERROR:
Signature · 1 line
MST
PATCH 2/4 Makefile: clean timestamp generation rule
In reply to Michael S. Tsirkincreate timestamp by rule without sideeffects.
--- trace/Makefile.objs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
trace/Makefile.objs +2 -2
@@ -4,24 +4,24 @@ # Auto-generated header for tracing routines $(obj)/generated-tracers.h: $(obj)/generated-tracers.h-timestamp + @cmp -s $< $@ || cp $< $@ $(obj)/generated-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(call quiet-command,$(TRACETOOL) \ --format=h \ --backend=$(TRACE_BACKEND) \ < $< > $@," GEN $(patsubst %-timestamp,%,$@)") - @cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst %-timestamp,%,$@) ###################################################################### # Auto-generated tracing routines (non-DTrace) ifneq ($(TRACE_BACKEND),dtrace) $(obj)/generated-tracers.c: $(obj)/generated-tracers.c-timestamp + @cmp -s $< $@ || cp $< $@ $(obj)/generated-tracers.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(call quiet-command,$(TRACETOOL) \ --format=c \ --backend=$(TRACE_BACKEND) \ < $< > $@," GEN $(patsubst %-timestamp,%,$@)") - @cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst %-timestamp,%,$@) $(obj)/generated-tracers.o: $(obj)/generated-tracers.c $(obj)/generated-tracers.h endif
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH 4/4] Makefile: fix make clean on libcacard
In reply to Michael S. TsirkinQuoted 14 lines · Michael S. Tsirkin
libcacard lacks a clean target. Need to fix it,
meanwhile mark this target phony so it does not
stop parallel make clean.Signed-off-by Michael S. Tsirkin <[email protected]>--- libcacard/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libcacard/Makefile +0
-0
libcacard/Makefile libcacard.pc: $(SRC_PATH)/libcacard/libcacard.pc.in · line 38
Quoted 5 lines
libcacard/Makefile +1
-1@@ -35,7 +35,7 @@ libcacard.pc: $(SRC_PATH)/libcacard/libcacard.pc.in -e 's|@PREFIX@|$(prefix)|' $< > libcacard.pc,\ " GEN $@") -.PHONY: install-libcacard +.PHONY: install-libcacard clean
libcacard/Makefile is not supposed to have a clean target since 992aeb8eb53e5846a957cf333f2e1ec8cb6e0c04 ("libcacard: rewrite Makefile in non-recursive style").
I have a patch on qemu-devel to remove libcacard from the make clean loop since its objects are already handled by the global clean now that the file is sourced rather than invoked recursively.
Stefan
Re: [Qemu-devel] [PATCH 4/4] Makefile: fix make clean on libcacard
Quoted 25 lines · Stefan Hajnoczi
Quoted 14 lines · Michael S. Tsirkin
libcacard lacks a clean target. Need to fix it,
meanwhile mark this target phony so it does not
stop parallel make clean.Signed-off-by Michael S. Tsirkin <[email protected]>--- libcacard/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libcacard/Makefile +0
-0libcacard/Makefile libcacard.pc: $(SRC_PATH)/libcacard/libcacard.pc.in · line 38
Quoted 5 lines
libcacard/Makefile +1
-1@@ -35,7 +35,7 @@ libcacard.pc: $(SRC_PATH)/libcacard/libcacard.pc.in -e 's|@PREFIX@|$(prefix)|' $< > libcacard.pc,\ " GEN $@") -.PHONY: install-libcacard +.PHONY: install-libcacard cleanlibcacard/Makefile is not supposed to have a clean target since
992aeb8eb53e5846a957cf333f2e1ec8cb6e0c04("libcacard: rewriteMakefilein non-recursive style").
Quoted 5 lines
I have a patch on qemu-devel to remove libcacard from the make clean loop since its objects are already handled by the global clean now that the file is sourced rather than invoked recursively.
Stefan
That will help too. Can you give me the msg id? Maybe I'll just put it on my tree.
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH 3/4] rules/mak: make clean should blow away timestamp files
In reply to Michael S. TsirkinQuoted 13 lines · Michael S. Tsirkin
Using a global pattern makes it easier to clean out old generated files.
Signed-off-by Michael S. Tsirkin <[email protected]>--- rules.mak | 5 +++++ 1 file changed, 5 insertions(+)rules.mak +0
-0
rules.mak config-%.h: config-%.h-timestamp · line 93
Quoted 6 lines
rules.mak +3
-0@@ -88,6 +88,11 @@ config-%.h: config-%.h-timestamp config-%.h-timestamp: config-%.mak $(call quiet-command, sh $(SRC_PATH)/scripts/create_config < $< > $@, " GEN $(TARGET_DIR)config-$*.h") +.PHONY: clean-timestamp +clean-timestamp: + rm -f *.timestamp
Timestamp files also live in subdirectories and I think we're slowly moving away from recursive make, so this may not clean all timestamp files.
Stefan
Re: [Qemu-devel] [PATCH 2/4] Makefile: clean timestamp generation rule
In reply to Michael S. TsirkinQuoted 6 lines · Michael S. Tsirkin
create timestamp by rule without sideeffects.
Signed-off-by Michael S. Tsirkin <[email protected]>--- trace/Makefile.objs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Re: [Qemu-devel] [PATCH 3/4] rules/mak: make clean should blow away timestamp files
In reply to Stefan HajnocziQuoted 25 lines · Stefan Hajnoczi
Quoted 13 lines · Michael S. Tsirkin
Using a global pattern makes it easier to clean out old generated files.
Signed-off-by Michael S. Tsirkin <[email protected]>--- rules.mak | 5 +++++ 1 file changed, 5 insertions(+)rules.mak +0
-0rules.mak config-%.h: config-%.h-timestamp · line 93
Quoted 6 lines
rules.mak +3
-0@@ -88,6 +88,11 @@ config-%.h: config-%.h-timestamp config-%.h-timestamp: config-%.mak $(call quiet-command, sh $(SRC_PATH)/scripts/create_config < $< > $@, " GEN $(TARGET_DIR)config-$*.h") +.PHONY: clean-timestamp +clean-timestamp: + rm -f *.timestampTimestamp files also live in subdirectories and I think we're slowly moving away from recursive make, so this may not clean all timestamp files.
Quoted 1 line
Stefan
Yes but it helps whenever we include rules.mak which is in most places.
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH 3/4] rules/mak: make clean should blow away timestamp files
Quoted 26 lines · Michael S. Tsirkin
Quoted 25 lines · Stefan Hajnoczi
Quoted 13 lines · Michael S. Tsirkin
Using a global pattern makes it easier to clean out old generated files.
Signed-off-by Michael S. Tsirkin <[email protected]>--- rules.mak | 5 +++++ 1 file changed, 5 insertions(+)rules.mak +0
-0rules.mak config-%.h: config-%.h-timestamp · line 93
Quoted 6 lines
rules.mak +3
-0@@ -88,6 +88,11 @@ config-%.h: config-%.h-timestamp config-%.h-timestamp: config-%.mak $(call quiet-command, sh $(SRC_PATH)/scripts/create_config < $< > $@, " GEN $(TARGET_DIR)config-$*.h") +.PHONY: clean-timestamp +clean-timestamp: + rm -f *.timestampTimestamp files also live in subdirectories and I think we're slowly moving away from recursive make, so this may not clean all timestamp files.
Quoted 3 lines
Quoted 1 line
Stefan
Yes but it helps whenever we include rules.mak which is in most places.
Okay, something to keep an eye on when Makefiles are converted to non-recursive.
Stefan
Re: [Qemu-devel] [PATCH 4/4] Makefile: fix make clean on libcacard
In reply to Michael S. TsirkinQuoted 26 lines · Michael S. Tsirkin
Quoted 25 lines · Stefan Hajnoczi
Quoted 14 lines · Michael S. Tsirkin
libcacard lacks a clean target. Need to fix it,
meanwhile mark this target phony so it does not
stop parallel make clean.Signed-off-by Michael S. Tsirkin <[email protected]>--- libcacard/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libcacard/Makefile +0
-0libcacard/Makefile libcacard.pc: $(SRC_PATH)/libcacard/libcacard.pc.in · line 38
Quoted 5 lines
libcacard/Makefile +1
-1@@ -35,7 +35,7 @@ libcacard.pc: $(SRC_PATH)/libcacard/libcacard.pc.in -e 's|@PREFIX@|$(prefix)|' $< > libcacard.pc,\ " GEN $@") -.PHONY: install-libcacard +.PHONY: install-libcacard cleanlibcacard/Makefile is not supposed to have a clean target since
992aeb8eb53e5846a957cf333f2e1ec8cb6e0c04("libcacard: rewriteMakefilein non-recursive style").
Quoted 8 lines
Quoted 5 lines
I have a patch on qemu-devel to remove libcacard from the make clean loop since its objects are already handled by the global clean now that the file is sourced rather than invoked recursively.
Stefan
That will help too. Can you give me the msg id? Maybe I'll just put it on my tree.
Stefan