linux: adjust make logic
PATCH 1/1 linux: adjust make logic
The changed logic allows having *-xen.[cS] files anywhere in the tree, without a need to modify the corresponding Makefiles. The patch also cleans up Makefiles modified for Xen as far as possible.
As before, the patch works on 2.6.22 and was just made apply to the aged Xen repository.
Signed-off-by Jan Beulich <[email protected]>
arch/i386/Makefile +0 -1
@@ -129,7 +129,6 @@ PHONY += zImage bzImage compressed zlilo ifdef CONFIG_XEN CPPFLAGS := -Iinclude$(if $(KBUILD_SRC),2)/asm/mach-xen $(CPPFLAGS) -head-y := arch/i386/kernel/head-xen.o arch/i386/kernel/init_task-xen.o boot := arch/i386/boot-xen .PHONY: vmlinuz all: vmlinuz
arch/i386/kernel/Makefile +6 -20
@@ -43,13 +43,8 @@ obj-$(CONFIG_K8_NB) += k8.o EXTRA_AFLAGS := -traditional obj-$(CONFIG_SCx200) += scx200.o +obj-$(CONFIG_XEN) += fixup.o -ifdef CONFIG_XEN -vsyscall_note := vsyscall-note-xen.o -else -vsyscall_note := vsyscall-note.o -endif - # vsyscall.o contains the vsyscall DSO images as __initdata. # We must build both images before we can assemble it. # Note: kbuild does not track this dependency due to usage of .incbin
@@ -74,7 +69,7 @@ SYSCFLAGS_vsyscall-int80.so = $(vsyscall $(obj)/vsyscall-int80.so $(obj)/vsyscall-sysenter.so: \ $(obj)/vsyscall-%.so: $(src)/vsyscall.lds \ - $(obj)/vsyscall-%.o $(obj)/$(vsyscall_note) FORCE + $(obj)/vsyscall-%.o $(obj)/vsyscall-note.o FORCE $(call if_changed,syscall) # We also create a special relocatable object that should mirror the symbol
@@ -86,20 +81,11 @@ $(obj)/built-in.o: ld_flags += -R $(obj) SYSCFLAGS_vsyscall-syms.o = -r $(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \ - $(obj)/vsyscall-sysenter.o $(obj)/$(vsyscall_note) FORCE + $(obj)/vsyscall-sysenter.o $(obj)/vsyscall-note.o FORCE $(call if_changed,syscall) +early_printk-y += ../../x86_64/kernel/early_printk.o k8-y += ../../x86_64/kernel/k8.o -ifdef CONFIG_XEN -include $(srctree)/scripts/Makefile.xen - -obj-y += fixup.o -microcode-$(subst m,y,$(CONFIG_MICROCODE)) := microcode-xen.o -n-obj-xen := i8259.o timers/ reboot.o smpboot.o trampoline.o - -obj-y := $(call filterxen, $(obj-y), $(n-obj-xen)) -obj-y := $(call cherrypickxen, $(obj-y)) -extra-y := $(call cherrypickxen, $(extra-y)) -%/head-xen.o %/head-xen.s: EXTRA_AFLAGS := -endif +disabled-obj-$(CONFIG_XEN) := i8259.o reboot.o smpboot.o trampoline.o +%/head.o %/head.s: $(if $(CONFIG_XEN),EXTRA_AFLAGS,dummy) :=
arch/i386/kernel/acpi/Makefile +0 -4
@@ -8,7 +8,3 @@ ifneq ($(CONFIG_ACPI_PROCESSOR),) obj-y += cstate.o processor.o endif -ifdef CONFIG_XEN -include $(srctree)/scripts/Makefile.xen -obj-y := $(call cherrypickxen, $(obj-y), $(src)) -endif
arch/i386/kernel/cpu/Makefile +0 -4
@@ -20,7 +20,3 @@ obj-$(CONFIG_CPU_FREQ) += cpufreq/ obj-$(CONFIG_MTRR) += mtrr/ obj-$(CONFIG_CPU_FREQ) += cpufreq/ -ifdef CONFIG_XEN -include $(srctree)/scripts/Makefile.xen -obj-y := $(call cherrypickxen, $(obj-y), $(src)) -endif
arch/i386/kernel/cpu/mtrr/Makefile +1 -7
@@ -1,10 +1,4 @@ obj-y += cyrix.o obj-y += centaur.o -ifdef CONFIG_XEN -include $(srctree)/scripts/Makefile.xen -n-obj-xen := generic.o state.o amd.o cyrix.o centaur.o - -obj-y := $(call filterxen, $(obj-y), $(n-obj-xen)) -obj-y := $(call cherrypickxen, $(obj-y)) -endif +obj-$(CONFIG_XEN) := main.o if.o
arch/i386/kernel/early_printk-xen.c deleted +0 -2
@@ -1,2 +0,0 @@ - -#include "../../x86_64/kernel/early_printk-xen.c"
arch/i386/mm/Makefile +1 -8
@@ -8,11 +8,4 @@ obj-$(CONFIG_NUMA) += discontig.o obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o obj-$(CONFIG_HIGHMEM) += highmem.o obj-$(CONFIG_BOOT_IOREMAP) += boot_ioremap.o - -ifdef CONFIG_XEN -include $(srctree)/scripts/Makefile.xen - -obj-y += hypervisor.o - -obj-y := $(call cherrypickxen, $(obj-y)) -endif +obj-$(CONFIG_XEN) += hypervisor.o
arch/i386/pci/Makefile +0 -5
@@ -16,8 +16,3 @@ pci-$(CONFIG_X86_VISWS) := visws.o fixu pci-$(CONFIG_X86_NUMAQ) := numa.o irq.o obj-y += $(pci-y) common.o - -ifdef CONFIG_XEN -include $(srctree)/scripts/Makefile.xen -obj-y := $(call cherrypickxen, $(obj-y)) -endif
arch/x86_64/Makefile +0 -1
@@ -94,7 +94,6 @@ PHONY += bzImage bzlilo install archmrpr ifdef CONFIG_XEN CPPFLAGS := -Iinclude$(if $(KBUILD_SRC),2)/asm/mach-xen $(CPPFLAGS) -head-y := arch/x86_64/kernel/head-xen.o arch/x86_64/kernel/head64-xen.o arch/x86_64/kernel/init_task.o LDFLAGS_vmlinux := -e startup_64 boot := arch/i386/boot-xen .PHONY: vmlinuz
arch/x86_64/ia32/Makefile +3 -10
@@ -37,15 +37,8 @@ $(obj)/vsyscall-%.so: $(src)/vsyscall.ld ifdef CONFIG_XEN AFLAGS_vsyscall-int80.o = -m32 -Wa,-32 -Iarch/i386/kernel -CFLAGS_syscall32-xen.o += -DUSE_INT80 -AFLAGS_syscall32_syscall-xen.o += -DUSE_INT80 +CFLAGS_syscall32.o += -DUSE_INT80 +AFLAGS_syscall32_syscall.o += -DUSE_INT80 -$(obj)/syscall32_syscall-xen.o: \ - $(foreach F,int80 sysenter syscall,$(obj)/vsyscall-$F.so) - -targets := $(foreach F,int80 sysenter syscall,vsyscall-$F.o vsyscall-$F.so) - -include $(srctree)/scripts/Makefile.xen - -obj-y := $(call cherrypickxen, $(obj-y)) +$(obj)/syscall32_syscall.o: $(obj)/vsyscall-int80.so endif
arch/x86_64/kernel/Makefile +4 -14
@@ -64,18 +64,8 @@ alternative-y += ../../i386/kernel/alt msr-$(subst m,y,$(CONFIG_X86_MSR)) += ../../i386/kernel/msr.o alternative-y += ../../i386/kernel/alternative.o -ifdef CONFIG_XEN -time-y += ../../i386/kernel/time-xen.o -pci-dma-y += ../../i386/kernel/pci-dma-xen.o -microcode-$(subst m,y,$(CONFIG_MICROCODE)) := ../../i386/kernel/microcode-xen.o -quirks-y := ../../i386/kernel/quirks-xen.o +time-$(CONFIG_XEN) += ../../i386/kernel/time.o +pci-dma-$(CONFIG_XEN) += ../../i386/kernel/pci-dma.o -n-obj-xen := i8259.o reboot.o i8237.o smpboot.o trampoline.o - -include $(srctree)/scripts/Makefile.xen - -obj-y := $(call filterxen, $(obj-y), $(n-obj-xen)) -obj-y := $(call cherrypickxen, $(obj-y)) -extra-y := $(call cherrypickxen, $(extra-y)) -%/head-xen.o %/head-xen.s: EXTRA_AFLAGS := -endif +disabled-obj-$(CONFIG_XEN) := i8259.o reboot.o smpboot.o trampoline.o +%/head.o %/head.s: $(if $(CONFIG_XEN),EXTRA_AFLAGS,dummy) :=
arch/x86_64/mm/Makefile +3 -10
@@ -7,15 +7,8 @@ obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpag obj-$(CONFIG_NUMA) += numa.o obj-$(CONFIG_K8_NUMA) += k8topology.o obj-$(CONFIG_ACPI_NUMA) += srat.o +obj-$(CONFIG_XEN) += hypervisor.o hugetlbpage-y = ../../i386/mm/hugetlbpage.o - -ifdef CONFIG_XEN -include $(srctree)/scripts/Makefile.xen - -ioremap-y += ../../i386/mm/ioremap-xen.o -hypervisor-y += ../../i386/mm/hypervisor.o -obj-y += hypervisor.o - -obj-y := $(call cherrypickxen, $(obj-y)) -endif +ioremap-$(CONFIG_XEN) := ../../i386/mm/ioremap.o +hypervisor-y := ../../i386/mm/hypervisor.o
arch/x86_64/pci/Makefile +0 -7
@@ -30,10 +30,3 @@ i386-y += ../../i386/pci/i386.o fixup-y += ../../i386/pci/fixup.o i386-y += ../../i386/pci/i386.o init-y += ../../i386/pci/init.o - -ifdef CONFIG_XEN -irq-y := ../../i386/pci/irq-xen.o -include $(srctree)/scripts/Makefile.xen - -obj-y := $(call cherrypickxen, $(obj-y)) -endif
scripts/Makefile.build +12 -0
@@ -68,6 +68,18 @@ ifndef obj $(warning kbuild: Makefile.build is included improperly) endif +ifeq ($(CONFIG_XEN),y) +$(objtree)/scripts/Makefile.xen: $(srctree)/scripts/Makefile.xen.awk $(srctree)/scripts/Makefile.build + @echo ' Updating $@' + @$(AWK) -f $< $(filter-out $<,$^) >$@ + +xen-src-single-used-m := $(patsubst $(srctree)/%,%,$(wildcard $(addprefix $(srctree)/,$(single-used-m:.o=-xen.c)))) +xen-single-used-m := $(xen-src-single-used-m:-xen.c=.o) +single-used-m := $(filter-out $(xen-single-used-m),$(single-used-m)) + +-include $(objtree)/scripts/Makefile.xen +endif + # =========================================================================== ifneq ($(strip $(lib-y) $(lib-m) $(lib-n) $(lib-)),)
scripts/Makefile.lib +6 -0
@@ -13,6 +13,12 @@ obj-m := $(filter-out $(obj-y),$(obj-m)) lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) +# Remove objects forcibly disabled + +obj-y := $(filter-out $(disabled-obj-y),$(obj-y)) +obj-m := $(filter-out $(disabled-obj-y),$(obj-m)) +lib-y := $(filter-out $(disabled-obj-y),$(lib-y)) + # Handle objects in subdirs # ---------------------------------------------------------------------------
scripts/Makefile.xen deleted +0 -14
@@ -1,14 +0,0 @@ - -# cherrypickxen($1 = allobj) -cherrypickxen = $(foreach var, $(1), \ - $(shell o=$(var); \ - c=$${o%.o}-xen.c; \ - s=$${o%.o}-xen.S; \ - oxen=$${o%.o}-xen.o; \ - [ -f $(srctree)/$(src)/$${c} ] || \ - [ -f $(srctree)/$(src)/$${s} ] \ - && echo $$oxen \ - || echo $(var) ) \ - ) -# filterxen($1 = allobj, $2 = noobjs) -filterxen = $(filter-out $(2), $(1))
scripts/Makefile.xen.awk new file +34 -0
@@ -0,0 +1,34 @@ +BEGIN { + is_rule = 0 +} + +/^[[:space:]]*#/ { + next +} + +/^[[:space:]]*$/ { + if (is_rule) + print("") + is_rule = 0 + next +} + +/:[[:space:]]*%\.[cS][[:space:]]/ { + line = gensub(/%.([cS])/, "%-xen.\\1", "g", $0) + line = gensub(/(single-used-m)/, "xen-\\1", "g", line) + print line + is_rule = 1 + next +} + +/^[^\t]$/ { + if (is_rule) + print("") + is_rule = 0 + next +} + +is_rule { + print $0 + next +}