Skip to contentSkip to conversation

qemu timestamp and related makefile cleanups

PATCH In review Michael S. Tsirkin 2 participants 12 messages Jan 15, 2013 – Jan 18, 2013

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 6d82c0d..d11a5b4 100644
@@ -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
#8 lore raw

PATCH 4/4 Makefile: fix make clean on libcacard

In reply to 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.

---
 libcacard/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libcacard/Makefile +1 -1
index 47827a0..a3518c1 100644
@@ -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
#4 lore raw

PATCH 3/4 rules/mak: make clean should blow away timestamp files

In reply to Michael S. Tsirkin

Using a global pattern makes it easier to clean out old generated files.

---
 rules.mak | 5 +++++
 1 file changed, 5 insertions(+)
rules.mak +5 -0
index d11a5b4..edc2552 100644
@@ -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
#2 lore raw

PATCH 2/4 Makefile: clean timestamp generation rule

In reply to Michael S. Tsirkin

create timestamp by rule without sideeffects.

---
 trace/Makefile.objs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
trace/Makefile.objs +2 -2
index 27fe26b..dde9d57 100644
@@ -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
#9 lore raw

Re: [Qemu-devel] [PATCH 4/4] Makefile: fix make clean on libcacard

In reply to Michael S. Tsirkin
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.

---
 libcacard/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libcacard/Makefile +0 -0
index 47827a0..a3518c1 100644

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

#10 lore raw

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.

---
 libcacard/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libcacard/Makefile +0 -0
index 47827a0..a3518c1 100644

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").

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
#5 lore raw

Re: [Qemu-devel] [PATCH 3/4] rules/mak: make clean should blow away timestamp files

In reply to Michael S. Tsirkin
Quoted 13 lines · Michael S. Tsirkin

Using a global pattern makes it easier to clean out old generated files.

---
 rules.mak | 5 +++++
 1 file changed, 5 insertions(+)
rules.mak +0 -0
index d11a5b4..edc2552 100644

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

#6 lore raw

Re: [Qemu-devel] [PATCH 3/4] rules/mak: make clean should blow away timestamp files

In reply to Stefan Hajnoczi
Quoted 25 lines · Stefan Hajnoczi
Quoted 13 lines · Michael S. Tsirkin

Using a global pattern makes it easier to clean out old generated files.

---
 rules.mak | 5 +++++
 1 file changed, 5 insertions(+)
rules.mak +0 -0
index d11a5b4..edc2552 100644

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.

Quoted 1 line

Stefan

Yes but it helps whenever we include rules.mak which is in most places.

Signature · 1 line
MST
#7 lore raw

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.

---
 rules.mak | 5 +++++
 1 file changed, 5 insertions(+)
rules.mak +0 -0
index d11a5b4..edc2552 100644

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.

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

#11 lore raw

Re: [Qemu-devel] [PATCH 4/4] Makefile: fix make clean on libcacard

In reply to Michael S. Tsirkin
Quoted 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.

---
 libcacard/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libcacard/Makefile +0 -0
index 47827a0..a3518c1 100644

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").

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.

<[email protected]>

Stefan