diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 141 |
1 files changed, 92 insertions, 49 deletions
@@ -41,9 +41,15 @@ ifndef KBUILD_VERBOSE | |||
41 | KBUILD_VERBOSE = 0 | 41 | KBUILD_VERBOSE = 0 |
42 | endif | 42 | endif |
43 | 43 | ||
44 | # Call checker as part of compilation of C files | 44 | # Call a source code checker (by default, "sparse") as part of the |
45 | # Use 'make C=1' to enable checking (sparse, by default) | 45 | # C compilation. |
46 | # Override with 'make C=1 CHECK=checker_executable CHECKFLAGS=....' | 46 | # |
47 | # Use 'make C=1' to enable checking of only re-compiled files. | ||
48 | # Use 'make C=2' to enable checking of *all* source files, regardless | ||
49 | # of whether they are re-compiled or not. | ||
50 | # | ||
51 | # See the file "Documentation/sparse.txt" for more details, including | ||
52 | # where to get the "sparse" utility. | ||
47 | 53 | ||
48 | ifdef C | 54 | ifdef C |
49 | ifeq ("$(origin C)", "command line") | 55 | ifeq ("$(origin C)", "command line") |
@@ -639,12 +645,12 @@ define rule_vmlinux__ | |||
639 | $(call cmd,vmlinux__) | 645 | $(call cmd,vmlinux__) |
640 | $(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd | 646 | $(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd |
641 | 647 | ||
642 | $(Q)$(if $($(quiet)cmd_sysmap), \ | 648 | $(Q)$(if $($(quiet)cmd_sysmap), \ |
643 | echo ' $($(quiet)cmd_sysmap) System.map' &&) \ | 649 | echo ' $($(quiet)cmd_sysmap) System.map' &&) \ |
644 | $(cmd_sysmap) $@ System.map; \ | 650 | $(cmd_sysmap) $@ System.map; \ |
645 | if [ $$? -ne 0 ]; then \ | 651 | if [ $$? -ne 0 ]; then \ |
646 | rm -f $@; \ | 652 | rm -f $@; \ |
647 | /bin/false; \ | 653 | /bin/false; \ |
648 | fi; | 654 | fi; |
649 | $(verify_kallsyms) | 655 | $(verify_kallsyms) |
650 | endef | 656 | endef |
@@ -677,12 +683,12 @@ endif | |||
677 | kallsyms.o := .tmp_kallsyms$(last_kallsyms).o | 683 | kallsyms.o := .tmp_kallsyms$(last_kallsyms).o |
678 | 684 | ||
679 | define verify_kallsyms | 685 | define verify_kallsyms |
680 | $(Q)$(if $($(quiet)cmd_sysmap), \ | 686 | $(Q)$(if $($(quiet)cmd_sysmap), \ |
681 | echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \ | 687 | echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \ |
682 | $(cmd_sysmap) .tmp_vmlinux$(last_kallsyms) .tmp_System.map | 688 | $(cmd_sysmap) .tmp_vmlinux$(last_kallsyms) .tmp_System.map |
683 | $(Q)cmp -s System.map .tmp_System.map || \ | 689 | $(Q)cmp -s System.map .tmp_System.map || \ |
684 | (echo Inconsistent kallsyms data; \ | 690 | (echo Inconsistent kallsyms data; \ |
685 | echo Try setting CONFIG_KALLSYMS_EXTRA_PASS; \ | 691 | echo Try setting CONFIG_KALLSYMS_EXTRA_PASS; \ |
686 | rm .tmp_kallsyms* ; /bin/false ) | 692 | rm .tmp_kallsyms* ; /bin/false ) |
687 | endef | 693 | endef |
688 | 694 | ||
@@ -736,6 +742,7 @@ endif # ifdef CONFIG_KALLSYMS | |||
736 | # vmlinux image - including updated kernel symbols | 742 | # vmlinux image - including updated kernel symbols |
737 | vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) FORCE | 743 | vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) FORCE |
738 | $(call if_changed_rule,vmlinux__) | 744 | $(call if_changed_rule,vmlinux__) |
745 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@ | ||
739 | $(Q)rm -f .old_version | 746 | $(Q)rm -f .old_version |
740 | 747 | ||
741 | # The actual objects are generated when descending, | 748 | # The actual objects are generated when descending, |
@@ -753,12 +760,34 @@ $(vmlinux-dirs): prepare scripts | |||
753 | $(Q)$(MAKE) $(build)=$@ | 760 | $(Q)$(MAKE) $(build)=$@ |
754 | 761 | ||
755 | # Build the kernel release string | 762 | # Build the kernel release string |
756 | # The KERNELRELEASE is stored in a file named include/config/kernel.release | ||
757 | # to be used when executing for example make install or make modules_install | ||
758 | # | 763 | # |
759 | # Take the contents of any files called localversion* and the config | 764 | # The KERNELRELEASE value built here is stored in the file |
760 | # variable CONFIG_LOCALVERSION and append them to KERNELRELEASE. | 765 | # include/config/kernel.release, and is used when executing several |
761 | # LOCALVERSION from the command line override all of this | 766 | # make targets, such as "make install" or "make modules_install." |
767 | # | ||
768 | # The eventual kernel release string consists of the following fields, | ||
769 | # shown in a hierarchical format to show how smaller parts are concatenated | ||
770 | # to form the larger and final value, with values coming from places like | ||
771 | # the Makefile, kernel config options, make command line options and/or | ||
772 | # SCM tag information. | ||
773 | # | ||
774 | # $(KERNELVERSION) | ||
775 | # $(VERSION) eg, 2 | ||
776 | # $(PATCHLEVEL) eg, 6 | ||
777 | # $(SUBLEVEL) eg, 18 | ||
778 | # $(EXTRAVERSION) eg, -rc6 | ||
779 | # $(localver-full) | ||
780 | # $(localver) | ||
781 | # localversion* (all localversion* files) | ||
782 | # $(CONFIG_LOCALVERSION) (from kernel config setting) | ||
783 | # $(localver-auto) (only if CONFIG_LOCALVERSION_AUTO is set) | ||
784 | # ./scripts/setlocalversion (SCM tag, if one exists) | ||
785 | # $(LOCALVERSION) (from make command line if provided) | ||
786 | # | ||
787 | # Note how the final $(localver-auto) string is included *only* if the | ||
788 | # kernel config option CONFIG_LOCALVERSION_AUTO is selected. Also, at the | ||
789 | # moment, only git is supported but other SCMs can edit the script | ||
790 | # scripts/setlocalversion and add the appropriate checks as needed. | ||
762 | 791 | ||
763 | nullstring := | 792 | nullstring := |
764 | space := $(nullstring) # end of line | 793 | space := $(nullstring) # end of line |
@@ -895,23 +924,24 @@ export INSTALL_HDR_PATH | |||
895 | HDRARCHES=$(filter-out generic,$(patsubst $(srctree)/include/asm-%/Kbuild,%,$(wildcard $(srctree)/include/asm-*/Kbuild))) | 924 | HDRARCHES=$(filter-out generic,$(patsubst $(srctree)/include/asm-%/Kbuild,%,$(wildcard $(srctree)/include/asm-*/Kbuild))) |
896 | 925 | ||
897 | PHONY += headers_install_all | 926 | PHONY += headers_install_all |
898 | headers_install_all: include/linux/version.h | 927 | headers_install_all: include/linux/version.h scripts_basic FORCE |
899 | $(Q)unifdef -Ux /dev/null | 928 | $(Q)$(MAKE) $(build)=scripts scripts/unifdef |
900 | $(Q)for arch in $(HDRARCHES); do \ | 929 | $(Q)for arch in $(HDRARCHES); do \ |
901 | $(MAKE) ARCH=$$arch -rR -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch ;\ | 930 | $(MAKE) ARCH=$$arch -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch ;\ |
902 | done | 931 | done |
903 | 932 | ||
904 | PHONY += headers_install | 933 | PHONY += headers_install |
905 | headers_install: include/linux/version.h | 934 | headers_install: include/linux/version.h scripts_basic FORCE |
906 | @if [ ! -r include/asm-$(ARCH)/Kbuild ]; then \ | 935 | @if [ ! -r include/asm-$(ARCH)/Kbuild ]; then \ |
907 | echo '*** Error: Headers not exportable for this architecture ($(ARCH))'; \ | 936 | echo '*** Error: Headers not exportable for this architecture ($(ARCH))'; \ |
908 | exit 1 ; fi | 937 | exit 1 ; fi |
909 | $(Q)unifdef -Ux /dev/null | 938 | $(Q)$(MAKE) $(build)=scripts scripts/unifdef |
910 | $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.headersinst obj=include | 939 | $(Q)rm -rf $(INSTALL_HDR_PATH)/include |
940 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst obj=include | ||
911 | 941 | ||
912 | PHONY += headers_check | 942 | PHONY += headers_check |
913 | headers_check: headers_install | 943 | headers_check: headers_install |
914 | $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.headersinst obj=include HDRCHECK=1 | 944 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.headersinst obj=include HDRCHECK=1 |
915 | 945 | ||
916 | # --------------------------------------------------------------------------- | 946 | # --------------------------------------------------------------------------- |
917 | # Modules | 947 | # Modules |
@@ -927,7 +957,7 @@ all: modules | |||
927 | PHONY += modules | 957 | PHONY += modules |
928 | modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) | 958 | modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) |
929 | @echo ' Building modules, stage 2.'; | 959 | @echo ' Building modules, stage 2.'; |
930 | $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost | 960 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost |
931 | 961 | ||
932 | 962 | ||
933 | # Target to prepare building external modules | 963 | # Target to prepare building external modules |
@@ -953,7 +983,7 @@ _modinst_: | |||
953 | rm -f $(MODLIB)/build ; \ | 983 | rm -f $(MODLIB)/build ; \ |
954 | ln -s $(objtree) $(MODLIB)/build ; \ | 984 | ln -s $(objtree) $(MODLIB)/build ; \ |
955 | fi | 985 | fi |
956 | $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst | 986 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst |
957 | 987 | ||
958 | # If System.map exists, run depmod. This deliberately does not have a | 988 | # If System.map exists, run depmod. This deliberately does not have a |
959 | # dependency on System.map since that would run the dependency tree on | 989 | # dependency on System.map since that would run the dependency tree on |
@@ -1068,8 +1098,10 @@ boards := $(notdir $(boards)) | |||
1068 | 1098 | ||
1069 | help: | 1099 | help: |
1070 | @echo 'Cleaning targets:' | 1100 | @echo 'Cleaning targets:' |
1071 | @echo ' clean - remove most generated files but keep the config' | 1101 | @echo ' clean - remove most generated files but keep the config and' |
1102 | @echo ' enough build support to build external modules' | ||
1072 | @echo ' mrproper - remove all generated files + config + various backup files' | 1103 | @echo ' mrproper - remove all generated files + config + various backup files' |
1104 | @echo ' distclean - mrproper + remove editor backup and patch files' | ||
1073 | @echo '' | 1105 | @echo '' |
1074 | @echo 'Configuration targets:' | 1106 | @echo 'Configuration targets:' |
1075 | @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help | 1107 | @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help |
@@ -1115,6 +1147,7 @@ help: | |||
1115 | echo '') | 1147 | echo '') |
1116 | 1148 | ||
1117 | @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' | 1149 | @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' |
1150 | @echo ' make V=2 [targets] 2 => give reason for rebuild of target' | ||
1118 | @echo ' make O=dir [targets] Locate all output files in "dir", including .config' | 1151 | @echo ' make O=dir [targets] Locate all output files in "dir", including .config' |
1119 | @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)' | 1152 | @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)' |
1120 | @echo ' make C=2 [targets] Force check of all c source with $$CHECK' | 1153 | @echo ' make C=2 [targets] Force check of all c source with $$CHECK' |
@@ -1169,7 +1202,7 @@ $(module-dirs): crmodverdir $(objtree)/Module.symvers | |||
1169 | 1202 | ||
1170 | modules: $(module-dirs) | 1203 | modules: $(module-dirs) |
1171 | @echo ' Building modules, stage 2.'; | 1204 | @echo ' Building modules, stage 2.'; |
1172 | $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost | 1205 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost |
1173 | 1206 | ||
1174 | PHONY += modules_install | 1207 | PHONY += modules_install |
1175 | modules_install: _emodinst_ _emodinst_post | 1208 | modules_install: _emodinst_ _emodinst_post |
@@ -1178,7 +1211,7 @@ install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) | |||
1178 | PHONY += _emodinst_ | 1211 | PHONY += _emodinst_ |
1179 | _emodinst_: | 1212 | _emodinst_: |
1180 | $(Q)mkdir -p $(MODLIB)/$(install-dir) | 1213 | $(Q)mkdir -p $(MODLIB)/$(install-dir) |
1181 | $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst | 1214 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst |
1182 | 1215 | ||
1183 | # Run depmod only is we have System.map and depmod is executable | 1216 | # Run depmod only is we have System.map and depmod is executable |
1184 | quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) | 1217 | quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) |
@@ -1279,6 +1312,31 @@ define all-defconfigs | |||
1279 | $(call find-sources,'defconfig') | 1312 | $(call find-sources,'defconfig') |
1280 | endef | 1313 | endef |
1281 | 1314 | ||
1315 | define xtags | ||
1316 | if $1 --version 2>&1 | grep -iq exuberant; then \ | ||
1317 | $(all-sources) | xargs $1 -a \ | ||
1318 | -I __initdata,__exitdata,__acquires,__releases \ | ||
1319 | -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ | ||
1320 | --extra=+f --c-kinds=+px; \ | ||
1321 | $(all-kconfigs) | xargs $1 -a \ | ||
1322 | --langdef=kconfig \ | ||
1323 | --language-force=kconfig \ | ||
1324 | --regex-kconfig='/^[[:blank:]]*config[[:blank:]]+([[:alnum:]_]+)/\1/'; \ | ||
1325 | $(all-defconfigs) | xargs $1 -a \ | ||
1326 | --langdef=dotconfig \ | ||
1327 | --language-force=dotconfig \ | ||
1328 | --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'; \ | ||
1329 | elif $1 --version 2>&1 | grep -iq emacs; then \ | ||
1330 | $(all-sources) | xargs $1 -a; \ | ||
1331 | $(all-kconfigs) | xargs $1 -a \ | ||
1332 | --regex='/^[ \t]*config[ \t]+\([a-zA-Z0-9_]+\)/\1/'; \ | ||
1333 | $(all-defconfigs) | xargs $1 -a \ | ||
1334 | --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'; \ | ||
1335 | else \ | ||
1336 | $(all-sources) | xargs $1 -a; \ | ||
1337 | fi | ||
1338 | endef | ||
1339 | |||
1282 | quiet_cmd_cscope-file = FILELST cscope.files | 1340 | quiet_cmd_cscope-file = FILELST cscope.files |
1283 | cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files | 1341 | cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files |
1284 | 1342 | ||
@@ -1292,31 +1350,16 @@ cscope: FORCE | |||
1292 | quiet_cmd_TAGS = MAKE $@ | 1350 | quiet_cmd_TAGS = MAKE $@ |
1293 | define cmd_TAGS | 1351 | define cmd_TAGS |
1294 | rm -f $@; \ | 1352 | rm -f $@; \ |
1295 | ETAGSF=`etags --version | grep -i exuberant >/dev/null && \ | 1353 | $(call xtags,etags) |
1296 | echo "-I __initdata,__exitdata,__acquires,__releases \ | ||
1297 | -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ | ||
1298 | --extra=+f --c-kinds=+px"`; \ | ||
1299 | $(all-sources) | xargs etags $$ETAGSF -a; \ | ||
1300 | if test "x$$ETAGSF" = x; then \ | ||
1301 | $(all-kconfigs) | xargs etags -a \ | ||
1302 | --regex='/^config[ \t]+\([a-zA-Z0-9_]+\)/\1/'; \ | ||
1303 | $(all-defconfigs) | xargs etags -a \ | ||
1304 | --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'; \ | ||
1305 | fi | ||
1306 | endef | 1354 | endef |
1307 | 1355 | ||
1308 | TAGS: FORCE | 1356 | TAGS: FORCE |
1309 | $(call cmd,TAGS) | 1357 | $(call cmd,TAGS) |
1310 | 1358 | ||
1311 | |||
1312 | quiet_cmd_tags = MAKE $@ | 1359 | quiet_cmd_tags = MAKE $@ |
1313 | define cmd_tags | 1360 | define cmd_tags |
1314 | rm -f $@; \ | 1361 | rm -f $@; \ |
1315 | CTAGSF=`ctags --version | grep -i exuberant >/dev/null && \ | 1362 | $(call xtags,ctags) |
1316 | echo "-I __initdata,__exitdata,__acquires,__releases \ | ||
1317 | -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ | ||
1318 | --extra=+f --c-kinds=+px"`; \ | ||
1319 | $(all-sources) | xargs ctags $$CTAGSF -a | ||
1320 | endef | 1363 | endef |
1321 | 1364 | ||
1322 | tags: FORCE | 1365 | tags: FORCE |
@@ -1394,7 +1437,7 @@ endif | |||
1394 | %.ko: prepare scripts FORCE | 1437 | %.ko: prepare scripts FORCE |
1395 | $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ | 1438 | $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ |
1396 | $(build)=$(build-dir) $(@:.ko=.o) | 1439 | $(build)=$(build-dir) $(@:.ko=.o) |
1397 | $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost | 1440 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost |
1398 | 1441 | ||
1399 | # FIXME Should go into a make.lib or something | 1442 | # FIXME Should go into a make.lib or something |
1400 | # =========================================================================== | 1443 | # =========================================================================== |