summaryrefslogtreecommitdiff
path: root/scripts/Makefile.modinst
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Makefile.modinst')
-rw-r--r--scripts/Makefile.modinst56
1 files changed, 53 insertions, 3 deletions
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 6e1fe0e5bcbd..6dcc5b132fb1 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -2,11 +2,47 @@
# Installing modules
# ==========================================================================
-quiet_cmd_modules_install = INSTALL $(obj-m)
-cmd_modules_install = mkdir -p $(MODLIB)/kernel/$(obj); \
- cp $(obj-m) $(MODLIB)/kernel/$(obj)
+src := $(obj)
+
+no-rules.make := 1
.PHONY: modules_install
+modules_install:
+
+include .config
+
+#$(warning $(CONFIG_X86))
+
+include $(obj)/Makefile
+
+# Figure out what we need to build from the various variables
+# ==========================================================================
+
+# When an object is listed to be built compiled-in and modular,
+# only build the compiled-in version
+
+obj-m := $(filter-out $(obj-y),$(obj-m))
+
+__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
+subdir-y += $(__subdir-y)
+__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
+subdir-m += $(__subdir-m)
+obj-m := $(filter-out %/, $(obj-m))
+
+# Subdirectories we need to descend into
+
+subdir-ym := $(sort $(subdir-y) $(subdir-m))
+
+# Add subdir path
+
+obj-m := $(addprefix $(obj)/,$(obj-m))
+subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
+
+# ==========================================================================
+
+quiet_cmd_modules_install = INSTALL $(obj-m)
+ cmd_modules_install = mkdir -p $(MODLIB)/kernel/$(obj); \
+ cp $(obj-m) $(MODLIB)/kernel/$(obj)
modules_install: $(subdir-ym)
ifneq ($(obj-m),)
@@ -15,3 +51,17 @@ else
@:
endif
+# ===========================================================================
+# Generic stuff
+# ===========================================================================
+
+# Descending
+# ---------------------------------------------------------------------------
+
+.PHONY: $(subdir-ym)
+$(subdir-ym):
+ $(Q)$(MAKE) -rR -f scripts/Makefile.modinst obj=$@
+
+# If quiet is set, only print short version of command
+
+cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))