Message ID | 1462713526-2582-1-git-send-email-richard.weiyang@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Sun, May 08, 2016 at 01:18:46PM +0000, Wei Yang wrote: > In x86 Makefile, each elf target has a rule for its dependent, which shares > the same pattern. We could let makefile to handle this job instead of > writing a specific rule for each elf target. By doing so, the makefile rule > looks clear and would be easy for adding new cases. > > This patch does several cleanup: > 1. add $(cstart.o) in *.elf dependent > 2. remove all those elf rules which share the same pattern > 3. remove the *.o dependent in the elf rule who has extra dependent > 4. move the vmx.elf rule to Makefile.x86_64 since this is not a common case > 5. remove elf rules in Makefile.i386 > 6. Add %.elf and %.o in .PRECIOUS to keep them after make > > Signed-off-by: Wei Yang <richard.weiyang@gmail.com> > > --- > v2: > add .PRECIOUS special target to keep those intermediate files > > --- > x86/Makefile.common | 72 ++++++----------------------------------------------- > x86/Makefile.i386 | 4 --- > x86/Makefile.x86_64 | 2 ++ > 3 files changed, 9 insertions(+), 69 deletions(-) Reviewed-by: Andrew Jones <drjones@redhat.com> > > diff --git a/x86/Makefile.common b/x86/Makefile.common > index 298e5f7..356d879 100644 > --- a/x86/Makefile.common > +++ b/x86/Makefile.common > @@ -25,8 +25,11 @@ KEEP_FRAME_POINTER := y > > libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name) > > +# We want to keep intermediate file: %.elf and %.o > +.PRECIOUS: %.elf %.o > + > FLATLIBS = lib/libcflat.a $(libgcc) > -%.elf: %.o $(FLATLIBS) x86/flat.lds > +%.elf: %.o $(FLATLIBS) x86/flat.lds $(cstart.o) > $(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \ > $(filter %.o, $^) $(FLATLIBS) > > @@ -53,77 +56,16 @@ test_cases: $(tests-common) $(tests) > > $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86 > > -$(TEST_DIR)/access.elf: $(cstart.o) $(TEST_DIR)/access.o > - > -$(TEST_DIR)/hypercall.elf: $(cstart.o) $(TEST_DIR)/hypercall.o > - > -$(TEST_DIR)/sieve.elf: $(cstart.o) $(TEST_DIR)/sieve.o > - > -$(TEST_DIR)/vmexit.elf: $(cstart.o) $(TEST_DIR)/vmexit.o > - > -$(TEST_DIR)/smptest.elf: $(cstart.o) $(TEST_DIR)/smptest.o > - > -$(TEST_DIR)/emulator.elf: $(cstart.o) $(TEST_DIR)/emulator.o > - > -$(TEST_DIR)/port80.elf: $(cstart.o) $(TEST_DIR)/port80.o > - > -$(TEST_DIR)/tsc.elf: $(cstart.o) $(TEST_DIR)/tsc.o > - > -$(TEST_DIR)/tsc_adjust.elf: $(cstart.o) $(TEST_DIR)/tsc_adjust.o > - > -$(TEST_DIR)/apic.elf: $(cstart.o) $(TEST_DIR)/apic.o > - > -$(TEST_DIR)/ioapic.elf: $(cstart.o) $(TEST_DIR)/ioapic.o > - > -$(TEST_DIR)/tscdeadline_latency.elf: $(cstart.o) $(TEST_DIR)/tscdeadline_latency.o > - > -$(TEST_DIR)/init.elf: $(cstart.o) $(TEST_DIR)/init.o > - > $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o > $(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^ > > $(TEST_DIR)/realmode.o: bits = 32 > > -$(TEST_DIR)/msr.elf: $(cstart.o) $(TEST_DIR)/msr.o > - > -$(TEST_DIR)/idt_test.elf: $(cstart.o) $(TEST_DIR)/idt_test.o > - > -$(TEST_DIR)/xsave.elf: $(cstart.o) $(TEST_DIR)/xsave.o > - > -$(TEST_DIR)/rmap_chain.elf: $(cstart.o) $(TEST_DIR)/rmap_chain.o > - > -$(TEST_DIR)/svm.elf: $(cstart.o) $(TEST_DIR)/svm.o > - > -$(TEST_DIR)/kvmclock_test.elf: $(cstart.o) $(TEST_DIR)/kvmclock.o \ > - $(TEST_DIR)/kvmclock_test.o > - > -$(TEST_DIR)/eventinj.elf: $(cstart.o) $(TEST_DIR)/eventinj.o > - > -$(TEST_DIR)/s3.elf: $(cstart.o) $(TEST_DIR)/s3.o > - > -$(TEST_DIR)/pmu.elf: $(cstart.o) $(TEST_DIR)/pmu.o > - > -$(TEST_DIR)/asyncpf.elf: $(cstart.o) $(TEST_DIR)/asyncpf.o > - > -$(TEST_DIR)/pcid.elf: $(cstart.o) $(TEST_DIR)/pcid.o > - > -$(TEST_DIR)/smap.elf: $(cstart.o) $(TEST_DIR)/smap.o > - > -$(TEST_DIR)/pku.elf: $(cstart.o) $(TEST_DIR)/pku.o > - > -$(TEST_DIR)/vmx.elf: $(cstart.o) $(TEST_DIR)/vmx.o $(TEST_DIR)/vmx_tests.o > - > -$(TEST_DIR)/debug.elf: $(cstart.o) $(TEST_DIR)/debug.o > - > -$(TEST_DIR)/memory.elf: $(cstart.o) $(TEST_DIR)/memory.o > - > -$(TEST_DIR)/hyperv_synic.elf: $(cstart.o) $(TEST_DIR)/hyperv.o \ > - $(TEST_DIR)/hyperv_synic.o > +$(TEST_DIR)/kvmclock_test.elf: $(TEST_DIR)/kvmclock.o > > -$(TEST_DIR)/hyperv_stimer.elf: $(cstart.o) $(TEST_DIR)/hyperv.o \ > - $(TEST_DIR)/hyperv_stimer.o > +$(TEST_DIR)/hyperv_synic.elf: $(TEST_DIR)/hyperv.o > > -$(TEST_DIR)/setjmp.elf: $(cstart.o) $(TEST_DIR)/setjmp.o > +$(TEST_DIR)/hyperv_stimer.elf: $(TEST_DIR)/hyperv.o > > arch_clean: > $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \ > diff --git a/x86/Makefile.i386 b/x86/Makefile.i386 > index 8a4c45c..c4176c4 100644 > --- a/x86/Makefile.i386 > +++ b/x86/Makefile.i386 > @@ -9,7 +9,3 @@ tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat \ > $(TEST_DIR)/cmpxchg8b.flat > > include $(TEST_DIR)/Makefile.common > - > -$(TEST_DIR)/cmpxchg8b.elf: $(cstart.o) $(TEST_DIR)/cmpxchg8b.o > -$(TEST_DIR)/taskswitch.elf: $(cstart.o) $(TEST_DIR)/taskswitch.o > -$(TEST_DIR)/taskswitch2.elf: $(cstart.o) $(TEST_DIR)/taskswitch2.o > diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64 > index 6b7ccfb..e166911 100644 > --- a/x86/Makefile.x86_64 > +++ b/x86/Makefile.x86_64 > @@ -16,3 +16,5 @@ tests += $(TEST_DIR)/vmx.flat > tests += $(TEST_DIR)/tscdeadline_latency.flat > > include $(TEST_DIR)/Makefile.common > + > +$(TEST_DIR)/vmx.elf: $(TEST_DIR)/vmx_tests.o > -- > 2.5.0 > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08/05/2016 15:18, Wei Yang wrote: > In x86 Makefile, each elf target has a rule for its dependent, which shares > the same pattern. We could let makefile to handle this job instead of > writing a specific rule for each elf target. By doing so, the makefile rule > looks clear and would be easy for adding new cases. > > This patch does several cleanup: > 1. add $(cstart.o) in *.elf dependent > 2. remove all those elf rules which share the same pattern > 3. remove the *.o dependent in the elf rule who has extra dependent > 4. move the vmx.elf rule to Makefile.x86_64 since this is not a common case > 5. remove elf rules in Makefile.i386 > 6. Add %.elf and %.o in .PRECIOUS to keep them after make > > Signed-off-by: Wei Yang <richard.weiyang@gmail.com> > > --- > v2: > add .PRECIOUS special target to keep those intermediate files I think keeping the .o is useless, as it will be recreated each time (the source changes). If .elf need to be kept, they should be in the targets, something like: -- a/x86/Makefile.x86_64 +++ b/x86/Makefile.x86_64 @@ -6,14 +6,19 @@ CFLAGS += -mno-red-zone cflatobjs += lib/x86/setjmp64.o tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \ + $(TEST_DIR)/access.elf $(TEST_DIR)/apic.elf \ $(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat \ + $(TEST_DIR)/emulator.elf $(TEST_DIR)/idt_test.elf \ ... We don't need some magic here. Laurent > --- > x86/Makefile.common | 72 ++++++----------------------------------------------- > x86/Makefile.i386 | 4 --- > x86/Makefile.x86_64 | 2 ++ > 3 files changed, 9 insertions(+), 69 deletions(-) > > diff --git a/x86/Makefile.common b/x86/Makefile.common > index 298e5f7..356d879 100644 > --- a/x86/Makefile.common > +++ b/x86/Makefile.common > @@ -25,8 +25,11 @@ KEEP_FRAME_POINTER := y > > libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name) > > +# We want to keep intermediate file: %.elf and %.o > +.PRECIOUS: %.elf %.o > + > FLATLIBS = lib/libcflat.a $(libgcc) > -%.elf: %.o $(FLATLIBS) x86/flat.lds > +%.elf: %.o $(FLATLIBS) x86/flat.lds $(cstart.o) > $(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \ > $(filter %.o, $^) $(FLATLIBS) > > @@ -53,77 +56,16 @@ test_cases: $(tests-common) $(tests) > > $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86 > > -$(TEST_DIR)/access.elf: $(cstart.o) $(TEST_DIR)/access.o > - > -$(TEST_DIR)/hypercall.elf: $(cstart.o) $(TEST_DIR)/hypercall.o > - > -$(TEST_DIR)/sieve.elf: $(cstart.o) $(TEST_DIR)/sieve.o > - > -$(TEST_DIR)/vmexit.elf: $(cstart.o) $(TEST_DIR)/vmexit.o > - > -$(TEST_DIR)/smptest.elf: $(cstart.o) $(TEST_DIR)/smptest.o > - > -$(TEST_DIR)/emulator.elf: $(cstart.o) $(TEST_DIR)/emulator.o > - > -$(TEST_DIR)/port80.elf: $(cstart.o) $(TEST_DIR)/port80.o > - > -$(TEST_DIR)/tsc.elf: $(cstart.o) $(TEST_DIR)/tsc.o > - > -$(TEST_DIR)/tsc_adjust.elf: $(cstart.o) $(TEST_DIR)/tsc_adjust.o > - > -$(TEST_DIR)/apic.elf: $(cstart.o) $(TEST_DIR)/apic.o > - > -$(TEST_DIR)/ioapic.elf: $(cstart.o) $(TEST_DIR)/ioapic.o > - > -$(TEST_DIR)/tscdeadline_latency.elf: $(cstart.o) $(TEST_DIR)/tscdeadline_latency.o > - > -$(TEST_DIR)/init.elf: $(cstart.o) $(TEST_DIR)/init.o > - > $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o > $(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^ > > $(TEST_DIR)/realmode.o: bits = 32 > > -$(TEST_DIR)/msr.elf: $(cstart.o) $(TEST_DIR)/msr.o > - > -$(TEST_DIR)/idt_test.elf: $(cstart.o) $(TEST_DIR)/idt_test.o > - > -$(TEST_DIR)/xsave.elf: $(cstart.o) $(TEST_DIR)/xsave.o > - > -$(TEST_DIR)/rmap_chain.elf: $(cstart.o) $(TEST_DIR)/rmap_chain.o > - > -$(TEST_DIR)/svm.elf: $(cstart.o) $(TEST_DIR)/svm.o > - > -$(TEST_DIR)/kvmclock_test.elf: $(cstart.o) $(TEST_DIR)/kvmclock.o \ > - $(TEST_DIR)/kvmclock_test.o > - > -$(TEST_DIR)/eventinj.elf: $(cstart.o) $(TEST_DIR)/eventinj.o > - > -$(TEST_DIR)/s3.elf: $(cstart.o) $(TEST_DIR)/s3.o > - > -$(TEST_DIR)/pmu.elf: $(cstart.o) $(TEST_DIR)/pmu.o > - > -$(TEST_DIR)/asyncpf.elf: $(cstart.o) $(TEST_DIR)/asyncpf.o > - > -$(TEST_DIR)/pcid.elf: $(cstart.o) $(TEST_DIR)/pcid.o > - > -$(TEST_DIR)/smap.elf: $(cstart.o) $(TEST_DIR)/smap.o > - > -$(TEST_DIR)/pku.elf: $(cstart.o) $(TEST_DIR)/pku.o > - > -$(TEST_DIR)/vmx.elf: $(cstart.o) $(TEST_DIR)/vmx.o $(TEST_DIR)/vmx_tests.o > - > -$(TEST_DIR)/debug.elf: $(cstart.o) $(TEST_DIR)/debug.o > - > -$(TEST_DIR)/memory.elf: $(cstart.o) $(TEST_DIR)/memory.o > - > -$(TEST_DIR)/hyperv_synic.elf: $(cstart.o) $(TEST_DIR)/hyperv.o \ > - $(TEST_DIR)/hyperv_synic.o > +$(TEST_DIR)/kvmclock_test.elf: $(TEST_DIR)/kvmclock.o > > -$(TEST_DIR)/hyperv_stimer.elf: $(cstart.o) $(TEST_DIR)/hyperv.o \ > - $(TEST_DIR)/hyperv_stimer.o > +$(TEST_DIR)/hyperv_synic.elf: $(TEST_DIR)/hyperv.o > > -$(TEST_DIR)/setjmp.elf: $(cstart.o) $(TEST_DIR)/setjmp.o > +$(TEST_DIR)/hyperv_stimer.elf: $(TEST_DIR)/hyperv.o > > arch_clean: > $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \ > diff --git a/x86/Makefile.i386 b/x86/Makefile.i386 > index 8a4c45c..c4176c4 100644 > --- a/x86/Makefile.i386 > +++ b/x86/Makefile.i386 > @@ -9,7 +9,3 @@ tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat \ > $(TEST_DIR)/cmpxchg8b.flat > > include $(TEST_DIR)/Makefile.common > - > -$(TEST_DIR)/cmpxchg8b.elf: $(cstart.o) $(TEST_DIR)/cmpxchg8b.o > -$(TEST_DIR)/taskswitch.elf: $(cstart.o) $(TEST_DIR)/taskswitch.o > -$(TEST_DIR)/taskswitch2.elf: $(cstart.o) $(TEST_DIR)/taskswitch2.o > diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64 > index 6b7ccfb..e166911 100644 > --- a/x86/Makefile.x86_64 > +++ b/x86/Makefile.x86_64 > @@ -16,3 +16,5 @@ tests += $(TEST_DIR)/vmx.flat > tests += $(TEST_DIR)/tscdeadline_latency.flat > > include $(TEST_DIR)/Makefile.common > + > +$(TEST_DIR)/vmx.elf: $(TEST_DIR)/vmx_tests.o > -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, May 10, 2016 at 10:09:49AM +0200, Laurent Vivier wrote: > > > On 08/05/2016 15:18, Wei Yang wrote: > > In x86 Makefile, each elf target has a rule for its dependent, which shares > > the same pattern. We could let makefile to handle this job instead of > > writing a specific rule for each elf target. By doing so, the makefile rule > > looks clear and would be easy for adding new cases. > > > > This patch does several cleanup: > > 1. add $(cstart.o) in *.elf dependent > > 2. remove all those elf rules which share the same pattern > > 3. remove the *.o dependent in the elf rule who has extra dependent > > 4. move the vmx.elf rule to Makefile.x86_64 since this is not a common case > > 5. remove elf rules in Makefile.i386 > > 6. Add %.elf and %.o in .PRECIOUS to keep them after make > > > > Signed-off-by: Wei Yang <richard.weiyang@gmail.com> > > > > --- > > v2: > > add .PRECIOUS special target to keep those intermediate files > > I think keeping the .o is useless, as it will be recreated each time > (the source changes). The .o's may be useful for disassembly. > > If .elf need to be kept, they should be in the targets, something like: The elfs are definitely useful for disassembly. > > -- a/x86/Makefile.x86_64 > +++ b/x86/Makefile.x86_64 > @@ -6,14 +6,19 @@ CFLAGS += -mno-red-zone > cflatobjs += lib/x86/setjmp64.o > > tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \ > + $(TEST_DIR)/access.elf $(TEST_DIR)/apic.elf \ > $(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat \ > + $(TEST_DIR)/emulator.elf $(TEST_DIR)/idt_test.elf \ > ... This is ugly. > > We don't need some magic here. Why choose ugliness over a special make target? > > Laurent > > --- > > x86/Makefile.common | 72 ++++++----------------------------------------------- > > x86/Makefile.i386 | 4 --- > > x86/Makefile.x86_64 | 2 ++ > > 3 files changed, 9 insertions(+), 69 deletions(-) > > > > diff --git a/x86/Makefile.common b/x86/Makefile.common > > index 298e5f7..356d879 100644 > > --- a/x86/Makefile.common > > +++ b/x86/Makefile.common > > @@ -25,8 +25,11 @@ KEEP_FRAME_POINTER := y > > > > libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name) > > > > +# We want to keep intermediate file: %.elf and %.o > > +.PRECIOUS: %.elf %.o > > + > > FLATLIBS = lib/libcflat.a $(libgcc) > > -%.elf: %.o $(FLATLIBS) x86/flat.lds > > +%.elf: %.o $(FLATLIBS) x86/flat.lds $(cstart.o) > > $(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \ > > $(filter %.o, $^) $(FLATLIBS) > > > > @@ -53,77 +56,16 @@ test_cases: $(tests-common) $(tests) > > > > $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86 > > > > -$(TEST_DIR)/access.elf: $(cstart.o) $(TEST_DIR)/access.o > > - > > -$(TEST_DIR)/hypercall.elf: $(cstart.o) $(TEST_DIR)/hypercall.o > > - > > -$(TEST_DIR)/sieve.elf: $(cstart.o) $(TEST_DIR)/sieve.o > > - > > -$(TEST_DIR)/vmexit.elf: $(cstart.o) $(TEST_DIR)/vmexit.o > > - > > -$(TEST_DIR)/smptest.elf: $(cstart.o) $(TEST_DIR)/smptest.o > > - > > -$(TEST_DIR)/emulator.elf: $(cstart.o) $(TEST_DIR)/emulator.o > > - > > -$(TEST_DIR)/port80.elf: $(cstart.o) $(TEST_DIR)/port80.o > > - > > -$(TEST_DIR)/tsc.elf: $(cstart.o) $(TEST_DIR)/tsc.o > > - > > -$(TEST_DIR)/tsc_adjust.elf: $(cstart.o) $(TEST_DIR)/tsc_adjust.o > > - > > -$(TEST_DIR)/apic.elf: $(cstart.o) $(TEST_DIR)/apic.o > > - > > -$(TEST_DIR)/ioapic.elf: $(cstart.o) $(TEST_DIR)/ioapic.o > > - > > -$(TEST_DIR)/tscdeadline_latency.elf: $(cstart.o) $(TEST_DIR)/tscdeadline_latency.o > > - > > -$(TEST_DIR)/init.elf: $(cstart.o) $(TEST_DIR)/init.o > > - > > $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o > > $(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^ > > > > $(TEST_DIR)/realmode.o: bits = 32 > > > > -$(TEST_DIR)/msr.elf: $(cstart.o) $(TEST_DIR)/msr.o > > - > > -$(TEST_DIR)/idt_test.elf: $(cstart.o) $(TEST_DIR)/idt_test.o > > - > > -$(TEST_DIR)/xsave.elf: $(cstart.o) $(TEST_DIR)/xsave.o > > - > > -$(TEST_DIR)/rmap_chain.elf: $(cstart.o) $(TEST_DIR)/rmap_chain.o > > - > > -$(TEST_DIR)/svm.elf: $(cstart.o) $(TEST_DIR)/svm.o > > - > > -$(TEST_DIR)/kvmclock_test.elf: $(cstart.o) $(TEST_DIR)/kvmclock.o \ > > - $(TEST_DIR)/kvmclock_test.o > > - > > -$(TEST_DIR)/eventinj.elf: $(cstart.o) $(TEST_DIR)/eventinj.o > > - > > -$(TEST_DIR)/s3.elf: $(cstart.o) $(TEST_DIR)/s3.o > > - > > -$(TEST_DIR)/pmu.elf: $(cstart.o) $(TEST_DIR)/pmu.o > > - > > -$(TEST_DIR)/asyncpf.elf: $(cstart.o) $(TEST_DIR)/asyncpf.o > > - > > -$(TEST_DIR)/pcid.elf: $(cstart.o) $(TEST_DIR)/pcid.o > > - > > -$(TEST_DIR)/smap.elf: $(cstart.o) $(TEST_DIR)/smap.o > > - > > -$(TEST_DIR)/pku.elf: $(cstart.o) $(TEST_DIR)/pku.o > > - > > -$(TEST_DIR)/vmx.elf: $(cstart.o) $(TEST_DIR)/vmx.o $(TEST_DIR)/vmx_tests.o > > - > > -$(TEST_DIR)/debug.elf: $(cstart.o) $(TEST_DIR)/debug.o > > - > > -$(TEST_DIR)/memory.elf: $(cstart.o) $(TEST_DIR)/memory.o > > - > > -$(TEST_DIR)/hyperv_synic.elf: $(cstart.o) $(TEST_DIR)/hyperv.o \ > > - $(TEST_DIR)/hyperv_synic.o > > +$(TEST_DIR)/kvmclock_test.elf: $(TEST_DIR)/kvmclock.o > > > > -$(TEST_DIR)/hyperv_stimer.elf: $(cstart.o) $(TEST_DIR)/hyperv.o \ > > - $(TEST_DIR)/hyperv_stimer.o > > +$(TEST_DIR)/hyperv_synic.elf: $(TEST_DIR)/hyperv.o > > > > -$(TEST_DIR)/setjmp.elf: $(cstart.o) $(TEST_DIR)/setjmp.o > > +$(TEST_DIR)/hyperv_stimer.elf: $(TEST_DIR)/hyperv.o > > > > arch_clean: > > $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \ > > diff --git a/x86/Makefile.i386 b/x86/Makefile.i386 > > index 8a4c45c..c4176c4 100644 > > --- a/x86/Makefile.i386 > > +++ b/x86/Makefile.i386 > > @@ -9,7 +9,3 @@ tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat \ > > $(TEST_DIR)/cmpxchg8b.flat > > > > include $(TEST_DIR)/Makefile.common > > - > > -$(TEST_DIR)/cmpxchg8b.elf: $(cstart.o) $(TEST_DIR)/cmpxchg8b.o > > -$(TEST_DIR)/taskswitch.elf: $(cstart.o) $(TEST_DIR)/taskswitch.o > > -$(TEST_DIR)/taskswitch2.elf: $(cstart.o) $(TEST_DIR)/taskswitch2.o > > diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64 > > index 6b7ccfb..e166911 100644 > > --- a/x86/Makefile.x86_64 > > +++ b/x86/Makefile.x86_64 > > @@ -16,3 +16,5 @@ tests += $(TEST_DIR)/vmx.flat > > tests += $(TEST_DIR)/tscdeadline_latency.flat > > > > include $(TEST_DIR)/Makefile.common > > + > > +$(TEST_DIR)/vmx.elf: $(TEST_DIR)/vmx_tests.o > > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 10/05/2016 11:16, Andrew Jones wrote: > On Tue, May 10, 2016 at 10:09:49AM +0200, Laurent Vivier wrote: >> >> >> On 08/05/2016 15:18, Wei Yang wrote: >>> In x86 Makefile, each elf target has a rule for its dependent, which shares >>> the same pattern. We could let makefile to handle this job instead of >>> writing a specific rule for each elf target. By doing so, the makefile rule >>> looks clear and would be easy for adding new cases. >>> >>> This patch does several cleanup: >>> 1. add $(cstart.o) in *.elf dependent >>> 2. remove all those elf rules which share the same pattern >>> 3. remove the *.o dependent in the elf rule who has extra dependent >>> 4. move the vmx.elf rule to Makefile.x86_64 since this is not a common case >>> 5. remove elf rules in Makefile.i386 >>> 6. Add %.elf and %.o in .PRECIOUS to keep them after make >>> >>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com> >>> >>> --- >>> v2: >>> add .PRECIOUS special target to keep those intermediate files >> >> I think keeping the .o is useless, as it will be recreated each time >> (the source changes). > > The .o's may be useful for disassembly. You can generate them on demand, for instance: make x86/vmexit.o >> >> If .elf need to be kept, they should be in the targets, something like: > > The elfs are definitely useful for disassembly. > >> >> -- a/x86/Makefile.x86_64 >> +++ b/x86/Makefile.x86_64 >> @@ -6,14 +6,19 @@ CFLAGS += -mno-red-zone >> cflatobjs += lib/x86/setjmp64.o >> >> tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \ >> + $(TEST_DIR)/access.elf $(TEST_DIR)/apic.elf \ >> $(TEST_DIR)/emulator.flat $(TEST_DIR)/idt_test.flat \ >> + $(TEST_DIR)/emulator.elf $(TEST_DIR)/idt_test.elf \ >> ... > > This is ugly. > >> >> We don't need some magic here. > > Why choose ugliness over a special make target? What is ugly or beautiful is a question of point of view :) I like to rely on explicit rules rather than on an obscure GNU make property. But it is just my opinion, so let's go with ".PRECIOUS" Laurent -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08/05/2016 15:18, Wei Yang wrote: > In x86 Makefile, each elf target has a rule for its dependent, which shares > the same pattern. We could let makefile to handle this job instead of > writing a specific rule for each elf target. By doing so, the makefile rule > looks clear and would be easy for adding new cases. > > This patch does several cleanup: > 1. add $(cstart.o) in *.elf dependent > 2. remove all those elf rules which share the same pattern > 3. remove the *.o dependent in the elf rule who has extra dependent > 4. move the vmx.elf rule to Makefile.x86_64 since this is not a common case > 5. remove elf rules in Makefile.i386 > 6. Add %.elf and %.o in .PRECIOUS to keep them after make > > Signed-off-by: Wei Yang <richard.weiyang@gmail.com> > > --- > v2: > add .PRECIOUS special target to keep those intermediate files Does -.PRECIOUS: %.elf %.o +.SECONDARY: work for you? That is, .SECONDARY without any prefixes? We might even put it in the toplevel makefile. Still, the patch looks good, I've queued it. Paolo > --- > x86/Makefile.common | 72 ++++++----------------------------------------------- > x86/Makefile.i386 | 4 --- > x86/Makefile.x86_64 | 2 ++ > 3 files changed, 9 insertions(+), 69 deletions(-) > > diff --git a/x86/Makefile.common b/x86/Makefile.common > index 298e5f7..356d879 100644 > --- a/x86/Makefile.common > +++ b/x86/Makefile.common > @@ -25,8 +25,11 @@ KEEP_FRAME_POINTER := y > > libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name) > > +# We want to keep intermediate file: %.elf and %.o > +.PRECIOUS: %.elf %.o > + > FLATLIBS = lib/libcflat.a $(libgcc) > -%.elf: %.o $(FLATLIBS) x86/flat.lds > +%.elf: %.o $(FLATLIBS) x86/flat.lds $(cstart.o) > $(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \ > $(filter %.o, $^) $(FLATLIBS) > > @@ -53,77 +56,16 @@ test_cases: $(tests-common) $(tests) > > $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86 > > -$(TEST_DIR)/access.elf: $(cstart.o) $(TEST_DIR)/access.o > - > -$(TEST_DIR)/hypercall.elf: $(cstart.o) $(TEST_DIR)/hypercall.o > - > -$(TEST_DIR)/sieve.elf: $(cstart.o) $(TEST_DIR)/sieve.o > - > -$(TEST_DIR)/vmexit.elf: $(cstart.o) $(TEST_DIR)/vmexit.o > - > -$(TEST_DIR)/smptest.elf: $(cstart.o) $(TEST_DIR)/smptest.o > - > -$(TEST_DIR)/emulator.elf: $(cstart.o) $(TEST_DIR)/emulator.o > - > -$(TEST_DIR)/port80.elf: $(cstart.o) $(TEST_DIR)/port80.o > - > -$(TEST_DIR)/tsc.elf: $(cstart.o) $(TEST_DIR)/tsc.o > - > -$(TEST_DIR)/tsc_adjust.elf: $(cstart.o) $(TEST_DIR)/tsc_adjust.o > - > -$(TEST_DIR)/apic.elf: $(cstart.o) $(TEST_DIR)/apic.o > - > -$(TEST_DIR)/ioapic.elf: $(cstart.o) $(TEST_DIR)/ioapic.o > - > -$(TEST_DIR)/tscdeadline_latency.elf: $(cstart.o) $(TEST_DIR)/tscdeadline_latency.o > - > -$(TEST_DIR)/init.elf: $(cstart.o) $(TEST_DIR)/init.o > - > $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o > $(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^ > > $(TEST_DIR)/realmode.o: bits = 32 > > -$(TEST_DIR)/msr.elf: $(cstart.o) $(TEST_DIR)/msr.o > - > -$(TEST_DIR)/idt_test.elf: $(cstart.o) $(TEST_DIR)/idt_test.o > - > -$(TEST_DIR)/xsave.elf: $(cstart.o) $(TEST_DIR)/xsave.o > - > -$(TEST_DIR)/rmap_chain.elf: $(cstart.o) $(TEST_DIR)/rmap_chain.o > - > -$(TEST_DIR)/svm.elf: $(cstart.o) $(TEST_DIR)/svm.o > - > -$(TEST_DIR)/kvmclock_test.elf: $(cstart.o) $(TEST_DIR)/kvmclock.o \ > - $(TEST_DIR)/kvmclock_test.o > - > -$(TEST_DIR)/eventinj.elf: $(cstart.o) $(TEST_DIR)/eventinj.o > - > -$(TEST_DIR)/s3.elf: $(cstart.o) $(TEST_DIR)/s3.o > - > -$(TEST_DIR)/pmu.elf: $(cstart.o) $(TEST_DIR)/pmu.o > - > -$(TEST_DIR)/asyncpf.elf: $(cstart.o) $(TEST_DIR)/asyncpf.o > - > -$(TEST_DIR)/pcid.elf: $(cstart.o) $(TEST_DIR)/pcid.o > - > -$(TEST_DIR)/smap.elf: $(cstart.o) $(TEST_DIR)/smap.o > - > -$(TEST_DIR)/pku.elf: $(cstart.o) $(TEST_DIR)/pku.o > - > -$(TEST_DIR)/vmx.elf: $(cstart.o) $(TEST_DIR)/vmx.o $(TEST_DIR)/vmx_tests.o > - > -$(TEST_DIR)/debug.elf: $(cstart.o) $(TEST_DIR)/debug.o > - > -$(TEST_DIR)/memory.elf: $(cstart.o) $(TEST_DIR)/memory.o > - > -$(TEST_DIR)/hyperv_synic.elf: $(cstart.o) $(TEST_DIR)/hyperv.o \ > - $(TEST_DIR)/hyperv_synic.o > +$(TEST_DIR)/kvmclock_test.elf: $(TEST_DIR)/kvmclock.o > > -$(TEST_DIR)/hyperv_stimer.elf: $(cstart.o) $(TEST_DIR)/hyperv.o \ > - $(TEST_DIR)/hyperv_stimer.o > +$(TEST_DIR)/hyperv_synic.elf: $(TEST_DIR)/hyperv.o > > -$(TEST_DIR)/setjmp.elf: $(cstart.o) $(TEST_DIR)/setjmp.o > +$(TEST_DIR)/hyperv_stimer.elf: $(TEST_DIR)/hyperv.o > > arch_clean: > $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \ > diff --git a/x86/Makefile.i386 b/x86/Makefile.i386 > index 8a4c45c..c4176c4 100644 > --- a/x86/Makefile.i386 > +++ b/x86/Makefile.i386 > @@ -9,7 +9,3 @@ tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat \ > $(TEST_DIR)/cmpxchg8b.flat > > include $(TEST_DIR)/Makefile.common > - > -$(TEST_DIR)/cmpxchg8b.elf: $(cstart.o) $(TEST_DIR)/cmpxchg8b.o > -$(TEST_DIR)/taskswitch.elf: $(cstart.o) $(TEST_DIR)/taskswitch.o > -$(TEST_DIR)/taskswitch2.elf: $(cstart.o) $(TEST_DIR)/taskswitch2.o > diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64 > index 6b7ccfb..e166911 100644 > --- a/x86/Makefile.x86_64 > +++ b/x86/Makefile.x86_64 > @@ -16,3 +16,5 @@ tests += $(TEST_DIR)/vmx.flat > tests += $(TEST_DIR)/tscdeadline_latency.flat > > include $(TEST_DIR)/Makefile.common > + > +$(TEST_DIR)/vmx.elf: $(TEST_DIR)/vmx_tests.o > -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, May 10, 2016 at 02:28:48PM +0200, Paolo Bonzini wrote: > > >On 08/05/2016 15:18, Wei Yang wrote: >> In x86 Makefile, each elf target has a rule for its dependent, which shares >> the same pattern. We could let makefile to handle this job instead of >> writing a specific rule for each elf target. By doing so, the makefile rule >> looks clear and would be easy for adding new cases. >> >> This patch does several cleanup: >> 1. add $(cstart.o) in *.elf dependent >> 2. remove all those elf rules which share the same pattern >> 3. remove the *.o dependent in the elf rule who has extra dependent >> 4. move the vmx.elf rule to Makefile.x86_64 since this is not a common case >> 5. remove elf rules in Makefile.i386 >> 6. Add %.elf and %.o in .PRECIOUS to keep them after make >> >> Signed-off-by: Wei Yang <richard.weiyang@gmail.com> >> >> --- >> v2: >> add .PRECIOUS special target to keep those intermediate files > >Does > >-.PRECIOUS: %.elf %.o >+.SECONDARY: > >work for you? That is, .SECONDARY without any prefixes? We might even >put it in the toplevel makefile. No, I have tried this. The behavior is a little strange. After you make the project and then remove x86/cstart64.o then run "make" again. The expected behavior should be re-generate x86/cstart64.o and all *elf and so on. But the behavior on my machine is x86/cstart64.o will not be generated and other target miss dependent. Not sure why. > >Still, the patch looks good, I've queued it. > Thanks >Paolo > >> --- >> x86/Makefile.common | 72 ++++++----------------------------------------------- >> x86/Makefile.i386 | 4 --- >> x86/Makefile.x86_64 | 2 ++ >> 3 files changed, 9 insertions(+), 69 deletions(-) >> >> diff --git a/x86/Makefile.common b/x86/Makefile.common >> index 298e5f7..356d879 100644 >> --- a/x86/Makefile.common >> +++ b/x86/Makefile.common >> @@ -25,8 +25,11 @@ KEEP_FRAME_POINTER := y >> >> libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name) >> >> +# We want to keep intermediate file: %.elf and %.o >> +.PRECIOUS: %.elf %.o >> + >> FLATLIBS = lib/libcflat.a $(libgcc) >> -%.elf: %.o $(FLATLIBS) x86/flat.lds >> +%.elf: %.o $(FLATLIBS) x86/flat.lds $(cstart.o) >> $(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \ >> $(filter %.o, $^) $(FLATLIBS) >> >> @@ -53,77 +56,16 @@ test_cases: $(tests-common) $(tests) >> >> $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86 >> >> -$(TEST_DIR)/access.elf: $(cstart.o) $(TEST_DIR)/access.o >> - >> -$(TEST_DIR)/hypercall.elf: $(cstart.o) $(TEST_DIR)/hypercall.o >> - >> -$(TEST_DIR)/sieve.elf: $(cstart.o) $(TEST_DIR)/sieve.o >> - >> -$(TEST_DIR)/vmexit.elf: $(cstart.o) $(TEST_DIR)/vmexit.o >> - >> -$(TEST_DIR)/smptest.elf: $(cstart.o) $(TEST_DIR)/smptest.o >> - >> -$(TEST_DIR)/emulator.elf: $(cstart.o) $(TEST_DIR)/emulator.o >> - >> -$(TEST_DIR)/port80.elf: $(cstart.o) $(TEST_DIR)/port80.o >> - >> -$(TEST_DIR)/tsc.elf: $(cstart.o) $(TEST_DIR)/tsc.o >> - >> -$(TEST_DIR)/tsc_adjust.elf: $(cstart.o) $(TEST_DIR)/tsc_adjust.o >> - >> -$(TEST_DIR)/apic.elf: $(cstart.o) $(TEST_DIR)/apic.o >> - >> -$(TEST_DIR)/ioapic.elf: $(cstart.o) $(TEST_DIR)/ioapic.o >> - >> -$(TEST_DIR)/tscdeadline_latency.elf: $(cstart.o) $(TEST_DIR)/tscdeadline_latency.o >> - >> -$(TEST_DIR)/init.elf: $(cstart.o) $(TEST_DIR)/init.o >> - >> $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o >> $(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^ >> >> $(TEST_DIR)/realmode.o: bits = 32 >> >> -$(TEST_DIR)/msr.elf: $(cstart.o) $(TEST_DIR)/msr.o >> - >> -$(TEST_DIR)/idt_test.elf: $(cstart.o) $(TEST_DIR)/idt_test.o >> - >> -$(TEST_DIR)/xsave.elf: $(cstart.o) $(TEST_DIR)/xsave.o >> - >> -$(TEST_DIR)/rmap_chain.elf: $(cstart.o) $(TEST_DIR)/rmap_chain.o >> - >> -$(TEST_DIR)/svm.elf: $(cstart.o) $(TEST_DIR)/svm.o >> - >> -$(TEST_DIR)/kvmclock_test.elf: $(cstart.o) $(TEST_DIR)/kvmclock.o \ >> - $(TEST_DIR)/kvmclock_test.o >> - >> -$(TEST_DIR)/eventinj.elf: $(cstart.o) $(TEST_DIR)/eventinj.o >> - >> -$(TEST_DIR)/s3.elf: $(cstart.o) $(TEST_DIR)/s3.o >> - >> -$(TEST_DIR)/pmu.elf: $(cstart.o) $(TEST_DIR)/pmu.o >> - >> -$(TEST_DIR)/asyncpf.elf: $(cstart.o) $(TEST_DIR)/asyncpf.o >> - >> -$(TEST_DIR)/pcid.elf: $(cstart.o) $(TEST_DIR)/pcid.o >> - >> -$(TEST_DIR)/smap.elf: $(cstart.o) $(TEST_DIR)/smap.o >> - >> -$(TEST_DIR)/pku.elf: $(cstart.o) $(TEST_DIR)/pku.o >> - >> -$(TEST_DIR)/vmx.elf: $(cstart.o) $(TEST_DIR)/vmx.o $(TEST_DIR)/vmx_tests.o >> - >> -$(TEST_DIR)/debug.elf: $(cstart.o) $(TEST_DIR)/debug.o >> - >> -$(TEST_DIR)/memory.elf: $(cstart.o) $(TEST_DIR)/memory.o >> - >> -$(TEST_DIR)/hyperv_synic.elf: $(cstart.o) $(TEST_DIR)/hyperv.o \ >> - $(TEST_DIR)/hyperv_synic.o >> +$(TEST_DIR)/kvmclock_test.elf: $(TEST_DIR)/kvmclock.o >> >> -$(TEST_DIR)/hyperv_stimer.elf: $(cstart.o) $(TEST_DIR)/hyperv.o \ >> - $(TEST_DIR)/hyperv_stimer.o >> +$(TEST_DIR)/hyperv_synic.elf: $(TEST_DIR)/hyperv.o >> >> -$(TEST_DIR)/setjmp.elf: $(cstart.o) $(TEST_DIR)/setjmp.o >> +$(TEST_DIR)/hyperv_stimer.elf: $(TEST_DIR)/hyperv.o >> >> arch_clean: >> $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \ >> diff --git a/x86/Makefile.i386 b/x86/Makefile.i386 >> index 8a4c45c..c4176c4 100644 >> --- a/x86/Makefile.i386 >> +++ b/x86/Makefile.i386 >> @@ -9,7 +9,3 @@ tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat \ >> $(TEST_DIR)/cmpxchg8b.flat >> >> include $(TEST_DIR)/Makefile.common >> - >> -$(TEST_DIR)/cmpxchg8b.elf: $(cstart.o) $(TEST_DIR)/cmpxchg8b.o >> -$(TEST_DIR)/taskswitch.elf: $(cstart.o) $(TEST_DIR)/taskswitch.o >> -$(TEST_DIR)/taskswitch2.elf: $(cstart.o) $(TEST_DIR)/taskswitch2.o >> diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64 >> index 6b7ccfb..e166911 100644 >> --- a/x86/Makefile.x86_64 >> +++ b/x86/Makefile.x86_64 >> @@ -16,3 +16,5 @@ tests += $(TEST_DIR)/vmx.flat >> tests += $(TEST_DIR)/tscdeadline_latency.flat >> >> include $(TEST_DIR)/Makefile.common >> + >> +$(TEST_DIR)/vmx.elf: $(TEST_DIR)/vmx_tests.o >>
diff --git a/x86/Makefile.common b/x86/Makefile.common index 298e5f7..356d879 100644 --- a/x86/Makefile.common +++ b/x86/Makefile.common @@ -25,8 +25,11 @@ KEEP_FRAME_POINTER := y libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name) +# We want to keep intermediate file: %.elf and %.o +.PRECIOUS: %.elf %.o + FLATLIBS = lib/libcflat.a $(libgcc) -%.elf: %.o $(FLATLIBS) x86/flat.lds +%.elf: %.o $(FLATLIBS) x86/flat.lds $(cstart.o) $(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \ $(filter %.o, $^) $(FLATLIBS) @@ -53,77 +56,16 @@ test_cases: $(tests-common) $(tests) $(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86 -$(TEST_DIR)/access.elf: $(cstart.o) $(TEST_DIR)/access.o - -$(TEST_DIR)/hypercall.elf: $(cstart.o) $(TEST_DIR)/hypercall.o - -$(TEST_DIR)/sieve.elf: $(cstart.o) $(TEST_DIR)/sieve.o - -$(TEST_DIR)/vmexit.elf: $(cstart.o) $(TEST_DIR)/vmexit.o - -$(TEST_DIR)/smptest.elf: $(cstart.o) $(TEST_DIR)/smptest.o - -$(TEST_DIR)/emulator.elf: $(cstart.o) $(TEST_DIR)/emulator.o - -$(TEST_DIR)/port80.elf: $(cstart.o) $(TEST_DIR)/port80.o - -$(TEST_DIR)/tsc.elf: $(cstart.o) $(TEST_DIR)/tsc.o - -$(TEST_DIR)/tsc_adjust.elf: $(cstart.o) $(TEST_DIR)/tsc_adjust.o - -$(TEST_DIR)/apic.elf: $(cstart.o) $(TEST_DIR)/apic.o - -$(TEST_DIR)/ioapic.elf: $(cstart.o) $(TEST_DIR)/ioapic.o - -$(TEST_DIR)/tscdeadline_latency.elf: $(cstart.o) $(TEST_DIR)/tscdeadline_latency.o - -$(TEST_DIR)/init.elf: $(cstart.o) $(TEST_DIR)/init.o - $(TEST_DIR)/realmode.elf: $(TEST_DIR)/realmode.o $(CC) -m32 -nostdlib -o $@ -Wl,-T,$(TEST_DIR)/realmode.lds $^ $(TEST_DIR)/realmode.o: bits = 32 -$(TEST_DIR)/msr.elf: $(cstart.o) $(TEST_DIR)/msr.o - -$(TEST_DIR)/idt_test.elf: $(cstart.o) $(TEST_DIR)/idt_test.o - -$(TEST_DIR)/xsave.elf: $(cstart.o) $(TEST_DIR)/xsave.o - -$(TEST_DIR)/rmap_chain.elf: $(cstart.o) $(TEST_DIR)/rmap_chain.o - -$(TEST_DIR)/svm.elf: $(cstart.o) $(TEST_DIR)/svm.o - -$(TEST_DIR)/kvmclock_test.elf: $(cstart.o) $(TEST_DIR)/kvmclock.o \ - $(TEST_DIR)/kvmclock_test.o - -$(TEST_DIR)/eventinj.elf: $(cstart.o) $(TEST_DIR)/eventinj.o - -$(TEST_DIR)/s3.elf: $(cstart.o) $(TEST_DIR)/s3.o - -$(TEST_DIR)/pmu.elf: $(cstart.o) $(TEST_DIR)/pmu.o - -$(TEST_DIR)/asyncpf.elf: $(cstart.o) $(TEST_DIR)/asyncpf.o - -$(TEST_DIR)/pcid.elf: $(cstart.o) $(TEST_DIR)/pcid.o - -$(TEST_DIR)/smap.elf: $(cstart.o) $(TEST_DIR)/smap.o - -$(TEST_DIR)/pku.elf: $(cstart.o) $(TEST_DIR)/pku.o - -$(TEST_DIR)/vmx.elf: $(cstart.o) $(TEST_DIR)/vmx.o $(TEST_DIR)/vmx_tests.o - -$(TEST_DIR)/debug.elf: $(cstart.o) $(TEST_DIR)/debug.o - -$(TEST_DIR)/memory.elf: $(cstart.o) $(TEST_DIR)/memory.o - -$(TEST_DIR)/hyperv_synic.elf: $(cstart.o) $(TEST_DIR)/hyperv.o \ - $(TEST_DIR)/hyperv_synic.o +$(TEST_DIR)/kvmclock_test.elf: $(TEST_DIR)/kvmclock.o -$(TEST_DIR)/hyperv_stimer.elf: $(cstart.o) $(TEST_DIR)/hyperv.o \ - $(TEST_DIR)/hyperv_stimer.o +$(TEST_DIR)/hyperv_synic.elf: $(TEST_DIR)/hyperv.o -$(TEST_DIR)/setjmp.elf: $(cstart.o) $(TEST_DIR)/setjmp.o +$(TEST_DIR)/hyperv_stimer.elf: $(TEST_DIR)/hyperv.o arch_clean: $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \ diff --git a/x86/Makefile.i386 b/x86/Makefile.i386 index 8a4c45c..c4176c4 100644 --- a/x86/Makefile.i386 +++ b/x86/Makefile.i386 @@ -9,7 +9,3 @@ tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat \ $(TEST_DIR)/cmpxchg8b.flat include $(TEST_DIR)/Makefile.common - -$(TEST_DIR)/cmpxchg8b.elf: $(cstart.o) $(TEST_DIR)/cmpxchg8b.o -$(TEST_DIR)/taskswitch.elf: $(cstart.o) $(TEST_DIR)/taskswitch.o -$(TEST_DIR)/taskswitch2.elf: $(cstart.o) $(TEST_DIR)/taskswitch2.o diff --git a/x86/Makefile.x86_64 b/x86/Makefile.x86_64 index 6b7ccfb..e166911 100644 --- a/x86/Makefile.x86_64 +++ b/x86/Makefile.x86_64 @@ -16,3 +16,5 @@ tests += $(TEST_DIR)/vmx.flat tests += $(TEST_DIR)/tscdeadline_latency.flat include $(TEST_DIR)/Makefile.common + +$(TEST_DIR)/vmx.elf: $(TEST_DIR)/vmx_tests.o
In x86 Makefile, each elf target has a rule for its dependent, which shares the same pattern. We could let makefile to handle this job instead of writing a specific rule for each elf target. By doing so, the makefile rule looks clear and would be easy for adding new cases. This patch does several cleanup: 1. add $(cstart.o) in *.elf dependent 2. remove all those elf rules which share the same pattern 3. remove the *.o dependent in the elf rule who has extra dependent 4. move the vmx.elf rule to Makefile.x86_64 since this is not a common case 5. remove elf rules in Makefile.i386 6. Add %.elf and %.o in .PRECIOUS to keep them after make Signed-off-by: Wei Yang <richard.weiyang@gmail.com> --- v2: add .PRECIOUS special target to keep those intermediate files --- x86/Makefile.common | 72 ++++++----------------------------------------------- x86/Makefile.i386 | 4 --- x86/Makefile.x86_64 | 2 ++ 3 files changed, 9 insertions(+), 69 deletions(-)