diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Documentation/kbuild/kbuild.txt | 14 | ||||
| -rw-r--r-- | Documentation/kbuild/kconfig.txt | 5 | ||||
| -rw-r--r-- | Makefile | 14 | ||||
| -rw-r--r-- | scripts/Kbuild.include | 6 | ||||
| -rw-r--r-- | scripts/Makefile.modbuiltin | 55 | ||||
| -rw-r--r-- | scripts/kconfig/confdata.c | 22 |
7 files changed, 112 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore index 002d5304968b..fb2190c61af0 100644 --- a/.gitignore +++ b/.gitignore | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | *.lst | 22 | *.lst |
| 23 | *.symtypes | 23 | *.symtypes |
| 24 | *.order | 24 | *.order |
| 25 | modules.builtin | ||
| 25 | *.elf | 26 | *.elf |
| 26 | *.bin | 27 | *.bin |
| 27 | *.gz | 28 | *.gz |
diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt index bb3bf38f03da..6f8c1cabbc5d 100644 --- a/Documentation/kbuild/kbuild.txt +++ b/Documentation/kbuild/kbuild.txt | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | Output files | ||
| 2 | |||
| 3 | modules.order | ||
| 4 | -------------------------------------------------- | ||
| 5 | This file records the order in which modules appear in Makefiles. This | ||
| 6 | is used by modprobe to deterministically resolve aliases that match | ||
| 7 | multiple modules. | ||
| 8 | |||
| 9 | modules.builtin | ||
| 10 | -------------------------------------------------- | ||
| 11 | This file lists all modules that are built into the kernel. This is used | ||
| 12 | by modprobe to not fail when trying to load something builtin. | ||
| 13 | |||
| 14 | |||
| 1 | Environment variables | 15 | Environment variables |
| 2 | 16 | ||
| 3 | KCPPFLAGS | 17 | KCPPFLAGS |
diff --git a/Documentation/kbuild/kconfig.txt b/Documentation/kbuild/kconfig.txt index ab8dc3538988..49efae703979 100644 --- a/Documentation/kbuild/kconfig.txt +++ b/Documentation/kbuild/kconfig.txt | |||
| @@ -103,6 +103,11 @@ KCONFIG_AUTOCONFIG | |||
| 103 | This environment variable can be set to specify the path & name of the | 103 | This environment variable can be set to specify the path & name of the |
| 104 | "auto.conf" file. Its default value is "include/config/auto.conf". | 104 | "auto.conf" file. Its default value is "include/config/auto.conf". |
| 105 | 105 | ||
| 106 | KCONFIG_TRISTATE | ||
| 107 | -------------------------------------------------- | ||
| 108 | This environment variable can be set to specify the path & name of the | ||
| 109 | "tristate.conf" file. Its default value is "include/config/tristate.conf". | ||
| 110 | |||
| 106 | KCONFIG_AUTOHEADER | 111 | KCONFIG_AUTOHEADER |
| 107 | -------------------------------------------------- | 112 | -------------------------------------------------- |
| 108 | This environment variable can be set to specify the path & name of the | 113 | This environment variable can be set to specify the path & name of the |
| @@ -464,7 +464,7 @@ ifeq ($(KBUILD_EXTMOD),) | |||
| 464 | # Carefully list dependencies so we do not try to build scripts twice | 464 | # Carefully list dependencies so we do not try to build scripts twice |
| 465 | # in parallel | 465 | # in parallel |
| 466 | PHONY += scripts | 466 | PHONY += scripts |
| 467 | scripts: scripts_basic include/config/auto.conf | 467 | scripts: scripts_basic include/config/auto.conf include/config/tristate.conf |
| 468 | $(Q)$(MAKE) $(build)=$(@) | 468 | $(Q)$(MAKE) $(build)=$(@) |
| 469 | 469 | ||
| 470 | # Objects we will link into vmlinux / subdirs we need to visit | 470 | # Objects we will link into vmlinux / subdirs we need to visit |
| @@ -491,7 +491,7 @@ $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; | |||
| 491 | # with it and forgot to run make oldconfig. | 491 | # with it and forgot to run make oldconfig. |
| 492 | # if auto.conf.cmd is missing then we are probably in a cleaned tree so | 492 | # if auto.conf.cmd is missing then we are probably in a cleaned tree so |
| 493 | # we execute the config step to be sure to catch updated Kconfig files | 493 | # we execute the config step to be sure to catch updated Kconfig files |
| 494 | include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd | 494 | include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd |
| 495 | $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig | 495 | $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig |
| 496 | else | 496 | else |
| 497 | # external modules needs include/generated/autoconf.h and include/config/auto.conf | 497 | # external modules needs include/generated/autoconf.h and include/config/auto.conf |
| @@ -876,6 +876,9 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ; | |||
| 876 | PHONY += $(vmlinux-dirs) | 876 | PHONY += $(vmlinux-dirs) |
| 877 | $(vmlinux-dirs): prepare scripts | 877 | $(vmlinux-dirs): prepare scripts |
| 878 | $(Q)$(MAKE) $(build)=$@ | 878 | $(Q)$(MAKE) $(build)=$@ |
| 879 | ifdef CONFIG_MODULES | ||
| 880 | $(Q)$(MAKE) $(modbuiltin)=$@ | ||
| 881 | endif | ||
| 879 | 882 | ||
| 880 | # Build the kernel release string | 883 | # Build the kernel release string |
| 881 | # | 884 | # |
| @@ -1080,6 +1083,7 @@ all: modules | |||
| 1080 | PHONY += modules | 1083 | PHONY += modules |
| 1081 | modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) | 1084 | modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) |
| 1082 | $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order | 1085 | $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order |
| 1086 | $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.builtin) > $(objtree)/modules.builtin | ||
| 1083 | @$(kecho) ' Building modules, stage 2.'; | 1087 | @$(kecho) ' Building modules, stage 2.'; |
| 1084 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost | 1088 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost |
| 1085 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild | 1089 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild |
| @@ -1109,6 +1113,7 @@ _modinst_: | |||
| 1109 | ln -s $(objtree) $(MODLIB)/build ; \ | 1113 | ln -s $(objtree) $(MODLIB)/build ; \ |
| 1110 | fi | 1114 | fi |
| 1111 | @cp -f $(objtree)/modules.order $(MODLIB)/ | 1115 | @cp -f $(objtree)/modules.order $(MODLIB)/ |
| 1116 | @cp -f $(objtree)/modules.builtin $(MODLIB)/ | ||
| 1112 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst | 1117 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst |
| 1113 | 1118 | ||
| 1114 | # This depmod is only for convenience to give the initial | 1119 | # This depmod is only for convenience to give the initial |
| @@ -1169,7 +1174,7 @@ clean: archclean $(clean-dirs) | |||
| 1169 | \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ | 1174 | \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ |
| 1170 | -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ | 1175 | -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ |
| 1171 | -o -name '*.symtypes' -o -name 'modules.order' \ | 1176 | -o -name '*.symtypes' -o -name 'modules.order' \ |
| 1172 | -o -name '.tmp_*.o.*' \ | 1177 | -o modules.order -o -name '.tmp_*.o.*' \ |
| 1173 | -o -name '*.gcno' \) -type f -print | xargs rm -f | 1178 | -o -name '*.gcno' \) -type f -print | xargs rm -f |
| 1174 | 1179 | ||
| 1175 | # mrproper - Delete all generated files, including .config | 1180 | # mrproper - Delete all generated files, including .config |
| @@ -1367,7 +1372,8 @@ $(clean-dirs): | |||
| 1367 | 1372 | ||
| 1368 | clean: rm-dirs := $(MODVERDIR) | 1373 | clean: rm-dirs := $(MODVERDIR) |
| 1369 | clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers \ | 1374 | clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers \ |
| 1370 | $(KBUILD_EXTMOD)/modules.order | 1375 | $(KBUILD_EXTMOD)/modules.order \ |
| 1376 | $(KBUILD_EXTMOD)/modules.builtin | ||
| 1371 | clean: $(clean-dirs) | 1377 | clean: $(clean-dirs) |
| 1372 | $(call cmd,rmdirs) | 1378 | $(call cmd,rmdirs) |
| 1373 | $(call cmd,rmfiles) | 1379 | $(call cmd,rmfiles) |
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index c67e73ecd5be..ed2773edfe71 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
| @@ -149,6 +149,12 @@ ld-option = $(call try-run,\ | |||
| 149 | # $(Q)$(MAKE) $(build)=dir | 149 | # $(Q)$(MAKE) $(build)=dir |
| 150 | build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj | 150 | build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj |
| 151 | 151 | ||
| 152 | ### | ||
| 153 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj= | ||
| 154 | # Usage: | ||
| 155 | # $(Q)$(MAKE) $(modbuiltin)=dir | ||
| 156 | modbuiltin := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.modbuiltin obj | ||
| 157 | |||
| 152 | # Prefix -I with $(srctree) if it is not an absolute path. | 158 | # Prefix -I with $(srctree) if it is not an absolute path. |
| 153 | # skip if -I has no parameter | 159 | # skip if -I has no parameter |
| 154 | addtree = $(if $(patsubst -I%,%,$(1)), \ | 160 | addtree = $(if $(patsubst -I%,%,$(1)), \ |
diff --git a/scripts/Makefile.modbuiltin b/scripts/Makefile.modbuiltin new file mode 100644 index 000000000000..102a276f6eea --- /dev/null +++ b/scripts/Makefile.modbuiltin | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | # ========================================================================== | ||
| 2 | # Generating modules.builtin | ||
| 3 | # ========================================================================== | ||
| 4 | |||
| 5 | src := $(obj) | ||
| 6 | |||
| 7 | PHONY := __modbuiltin | ||
| 8 | __modbuiltin: | ||
| 9 | |||
| 10 | -include include/config/auto.conf | ||
| 11 | # tristate.conf sets tristate variables to uppercase 'Y' or 'M' | ||
| 12 | # That way, we get the list of built-in modules in obj-Y | ||
| 13 | -include include/config/tristate.conf | ||
| 14 | |||
| 15 | include scripts/Kbuild.include | ||
| 16 | |||
| 17 | # The filename Kbuild has precedence over Makefile | ||
| 18 | kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) | ||
| 19 | kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) | ||
| 20 | include $(kbuild-file) | ||
| 21 | |||
| 22 | include scripts/Makefile.lib | ||
| 23 | __subdir-Y := $(patsubst %/,%,$(filter %/, $(obj-Y))) | ||
| 24 | subdir-Y += $(__subdir-Y) | ||
| 25 | subdir-ym := $(sort $(subdir-y) $(subdir-Y) $(subdir-m)) | ||
| 26 | subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) | ||
| 27 | obj-Y := $(addprefix $(obj)/,$(obj-Y)) | ||
| 28 | |||
| 29 | modbuiltin-subdirs := $(patsubst %,%/modules.builtin, $(subdir-ym)) | ||
| 30 | modbuiltin-mods := $(filter %.ko, $(obj-Y:.o=.ko)) | ||
| 31 | modbuiltin-target := $(obj)/modules.builtin | ||
| 32 | |||
| 33 | __modbuiltin: $(modbuiltin-target) $(subdir-ym) | ||
| 34 | @: | ||
| 35 | |||
| 36 | $(modbuiltin-target): $(subdir-ym) FORCE | ||
| 37 | $(Q)(for m in $(modbuiltin-mods); do echo kernel/$$m; done; \ | ||
| 38 | cat /dev/null $(modbuiltin-subdirs)) > $@ | ||
| 39 | |||
| 40 | PHONY += FORCE | ||
| 41 | |||
| 42 | FORCE: | ||
| 43 | |||
| 44 | # Descending | ||
| 45 | # --------------------------------------------------------------------------- | ||
| 46 | |||
| 47 | PHONY += $(subdir-ym) | ||
| 48 | $(subdir-ym): | ||
| 49 | $(Q)$(MAKE) $(modbuiltin)=$@ | ||
| 50 | |||
| 51 | |||
| 52 | # Declare the contents of the .PHONY variable as phony. We keep that | ||
| 53 | # information in a variable se we can use it in if_changed and friends. | ||
| 54 | |||
| 55 | .PHONY: $(PHONY) | ||
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 797a7410f690..c4dec80cfd8e 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
| @@ -677,7 +677,7 @@ int conf_write_autoconf(void) | |||
| 677 | struct symbol *sym; | 677 | struct symbol *sym; |
| 678 | const char *str; | 678 | const char *str; |
| 679 | const char *name; | 679 | const char *name; |
| 680 | FILE *out, *out_h; | 680 | FILE *out, *tristate, *out_h; |
| 681 | time_t now; | 681 | time_t now; |
| 682 | int i, l; | 682 | int i, l; |
| 683 | 683 | ||
| @@ -692,9 +692,16 @@ int conf_write_autoconf(void) | |||
| 692 | if (!out) | 692 | if (!out) |
| 693 | return 1; | 693 | return 1; |
| 694 | 694 | ||
| 695 | tristate = fopen(".tmpconfig_tristate", "w"); | ||
| 696 | if (!tristate) { | ||
| 697 | fclose(out); | ||
| 698 | return 1; | ||
| 699 | } | ||
| 700 | |||
| 695 | out_h = fopen(".tmpconfig.h", "w"); | 701 | out_h = fopen(".tmpconfig.h", "w"); |
| 696 | if (!out_h) { | 702 | if (!out_h) { |
| 697 | fclose(out); | 703 | fclose(out); |
| 704 | fclose(tristate); | ||
| 698 | return 1; | 705 | return 1; |
| 699 | } | 706 | } |
| 700 | 707 | ||
| @@ -707,6 +714,9 @@ int conf_write_autoconf(void) | |||
| 707 | "# %s" | 714 | "# %s" |
| 708 | "#\n", | 715 | "#\n", |
| 709 | sym_get_string_value(sym), ctime(&now)); | 716 | sym_get_string_value(sym), ctime(&now)); |
| 717 | fprintf(tristate, "#\n" | ||
| 718 | "# Automatically generated - do not edit\n" | ||
| 719 | "\n"); | ||
| 710 | fprintf(out_h, "/*\n" | 720 | fprintf(out_h, "/*\n" |
| 711 | " * Automatically generated C config: don't edit\n" | 721 | " * Automatically generated C config: don't edit\n" |
| 712 | " * Linux kernel version: %s\n" | 722 | " * Linux kernel version: %s\n" |
| @@ -727,10 +737,14 @@ int conf_write_autoconf(void) | |||
| 727 | break; | 737 | break; |
| 728 | case mod: | 738 | case mod: |
| 729 | fprintf(out, "CONFIG_%s=m\n", sym->name); | 739 | fprintf(out, "CONFIG_%s=m\n", sym->name); |
| 740 | fprintf(tristate, "CONFIG_%s=M\n", sym->name); | ||
| 730 | fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); | 741 | fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); |
| 731 | break; | 742 | break; |
| 732 | case yes: | 743 | case yes: |
| 733 | fprintf(out, "CONFIG_%s=y\n", sym->name); | 744 | fprintf(out, "CONFIG_%s=y\n", sym->name); |
| 745 | if (sym->type == S_TRISTATE) | ||
| 746 | fprintf(tristate, "CONFIG_%s=Y\n", | ||
| 747 | sym->name); | ||
| 734 | fprintf(out_h, "#define CONFIG_%s 1\n", sym->name); | 748 | fprintf(out_h, "#define CONFIG_%s 1\n", sym->name); |
| 735 | break; | 749 | break; |
| 736 | } | 750 | } |
| @@ -772,6 +786,7 @@ int conf_write_autoconf(void) | |||
| 772 | } | 786 | } |
| 773 | } | 787 | } |
| 774 | fclose(out); | 788 | fclose(out); |
| 789 | fclose(tristate); | ||
| 775 | fclose(out_h); | 790 | fclose(out_h); |
| 776 | 791 | ||
| 777 | name = getenv("KCONFIG_AUTOHEADER"); | 792 | name = getenv("KCONFIG_AUTOHEADER"); |
| @@ -779,6 +794,11 @@ int conf_write_autoconf(void) | |||
| 779 | name = "include/generated/autoconf.h"; | 794 | name = "include/generated/autoconf.h"; |
| 780 | if (rename(".tmpconfig.h", name)) | 795 | if (rename(".tmpconfig.h", name)) |
| 781 | return 1; | 796 | return 1; |
| 797 | name = getenv("KCONFIG_TRISTATE"); | ||
| 798 | if (!name) | ||
| 799 | name = "include/config/tristate.conf"; | ||
| 800 | if (rename(".tmpconfig_tristate", name)) | ||
| 801 | return 1; | ||
| 782 | name = conf_get_autoconfig_name(); | 802 | name = conf_get_autoconfig_name(); |
| 783 | /* | 803 | /* |
| 784 | * This must be the last step, kbuild has a dependency on auto.conf | 804 | * This must be the last step, kbuild has a dependency on auto.conf |
