1 ksplice-makefile := $(word $(words $(MAKEFILE_LIST)), $(MAKEFILE_LIST))
2 ksplice-script = $(dir $(ksplice-makefile))ksplice.pl
5 $(if $(filter_out snap diff,$(KSPLICE_MODE)), \
6 $(error Invalid KSPLICE_MODE $(KSPLICE_MODE).))
7 ksplice-mode-$(KSPLICE_MODE) = y
12 quiet_cmd_ksplice-combine = COMBINE $(@:.KSPLICE=)
13 cmd_ksplice-combine = $(ksplice-script) combine $@ $(filter $(ksplice-link-deps),$^)
14 quiet_cmd_ksplice-snap = SNAP $(@:.KSPLICE=)
15 cmd_ksplice-snap = $(ksplice-script) snap $@
16 quiet_cmd_ksplice-diff = DIFF $(@:.KSPLICE=)
17 cmd_ksplice-diff = $(ksplice-script) diff $@
18 quiet_cmd_ksplice-cow = COW $@
19 cmd_ksplice-cow = cp -a $@ $@.KSPLICE_pre
21 ifeq ($(KERNELRELEASE),)
23 # Makefile.lib must be included before Makefile because they contain
24 # different filechk definitions in 2.6.12.
25 include scripts/Makefile.lib
27 CFLAGS_KERNEL += -ffunction-sections -fdata-sections
28 CFLAGS_MODULE += -ffunction-sections -fdata-sections
29 ksplice-deps += vmlinux.o.KSPLICE
30 ksplice-dirs += $(addprefix _ksplice_,$(vmlinux-dirs))
31 ksplice-before += prepare0 prepare scripts
33 ksplice-vmlinux-objs = $(filter-out $(head-y),$(if $(vmlinux-all),$(vmlinux-all),$(vmlinux-objs)))
34 vmlinux.o.KSPLICE: ksplice-link-deps = $(ksplice-vmlinux-objs:=.KSPLICE)
35 vmlinux.o.KSPLICE: $(ksplice-vmlinux-objs:=.KSPLICE) FORCE
36 $(call if_changed,ksplice-combine)
37 ksplice-targets += vmlinux.o.KSPLICE
38 $(ksplice-vmlinux-objs:=.KSPLICE): $(ksplice-dirs) ;
42 include $(srctree)/scripts/Makefile.build
43 ksplice-deps += $(builtin-target:=.KSPLICE) $(lib-target:=.KSPLICE) $(obj-m:=.KSPLICE)
44 ksplice-dirs += $(addprefix _ksplice_,$(subdir-ym))
47 $(builtin-target:=.KSPLICE): ksplice-link-deps = $(obj-y:=.KSPLICE)
48 $(builtin-target:=.KSPLICE): $(obj-y:=.KSPLICE) FORCE
49 $(call if_changed,ksplice-combine)
50 ksplice-targets += $(builtin-target:=.KSPLICE)
54 $(lib-target:=.KSPLICE): ksplice-link-deps = $(lib-y:=.KSPLICE)
55 $(lib-target:=.KSPLICE): $(lib-y:=.KSPLICE) FORCE
56 $(call if_changed,ksplice-combine)
57 ksplice-targets += $(lib-target:=.KSPLICE)
60 $(sort $(multi-used-y:=.KSPLICE) $(multi-used-m:=.KSPLICE)): ksplice-link-deps = $(addsuffix .KSPLICE,$(addprefix $(obj)/,$($(patsubst $(obj)/%,%,$(@:.o.KSPLICE=-objs))) $($(patsubst $(obj)/%,%,$(@:.o.KSPLICE=-y)))))
61 $(sort $(multi-used-y:=.KSPLICE)): $(obj)/%.o.KSPLICE: $(multi-objs-y:=.KSPLICE) FORCE
62 $(call if_changed,ksplice-combine)
63 $(sort $(multi-used-m:=.KSPLICE)): $(obj)/%.o.KSPLICE: $(multi-objs-m:=.KSPLICE) FORCE
64 $(call if_changed,ksplice-combine)
65 ksplice-targets += $(sort $(multi-used-y:=.KSPLICE) $(multi-used-m:=.KSPLICE))
67 ifdef ksplice-mode-snap
68 $(obj)/%.o.KSPLICE: $(obj)/%.o FORCE
69 $(if $(strip $(wildcard $<.KSPLICE_pre) $(filter $<,$?)), \
70 $(call cmd,ksplice-snap))
72 $(obj)/%.o.KSPLICE: $(obj)/%.o
73 $(call cmd,ksplice-diff)
76 $(sort $(subdir-obj-y:=.KSPLICE)): $(ksplice-dirs) ;
80 define ksplice-cow-check
81 $(if $(filter-out %.KSPLICE,$@), \
82 $(if $(ksplice-mode-diff), \
83 $(if $(strip $(filter-out $(PHONY),$?) $(filter-out $(cmd_$(1)),$(cmd_$@)) $(filter-out $(cmd_$@),$(cmd_$(1)))), \
84 $(if $(wildcard $@), \
85 $(if $(wildcard $@.KSPLICE_pre),, \
86 $(call cmd,ksplice-cow))))))
90 $(foreach v,if_changed if_changed_dep if_changed_rule, \
91 $(eval $(v)=$$(ksplice-cow-check)$(value $(v))))
93 __ksplice: $(ksplice-deps) $(ksplice-dirs)
96 ksplice-cmd-files := $(wildcard $(foreach f,$(sort $(ksplice-targets)),$(dir $(f)).$(notdir $(f)).cmd))
97 ifneq ($(ksplice-cmd-files),)
98 include $(ksplice-cmd-files)
101 ksplice := -f $(ksplice-makefile) obj
103 PHONY += $(ksplice-dirs)
104 $(ksplice-dirs): $(ksplice-before)
105 $(Q)$(MAKE) $(ksplice)=$(patsubst _ksplice_%,%,$@)