aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile207
1 files changed, 66 insertions, 141 deletions
diff --git a/Makefile b/Makefile
index 71e98e9e6acd..09ff7d81809a 100644
--- a/Makefile
+++ b/Makefile
@@ -336,7 +336,7 @@ LINUXINCLUDE := -Iinclude \
336 -I$(srctree)/arch/$(hdr-arch)/include \ 336 -I$(srctree)/arch/$(hdr-arch)/include \
337 -include include/linux/autoconf.h 337 -include include/linux/autoconf.h
338 338
339KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) 339KBUILD_CPPFLAGS := -D__KERNEL__
340 340
341KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 341KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
342 -fno-strict-aliasing -fno-common \ 342 -fno-strict-aliasing -fno-common \
@@ -439,7 +439,11 @@ ifeq ($(config-targets),1)
439include $(srctree)/arch/$(SRCARCH)/Makefile 439include $(srctree)/arch/$(SRCARCH)/Makefile
440export KBUILD_DEFCONFIG KBUILD_KCONFIG 440export KBUILD_DEFCONFIG KBUILD_KCONFIG
441 441
442config %config: scripts_basic outputmakefile FORCE 442config: scripts_basic outputmakefile FORCE
443 $(Q)mkdir -p include/linux include/config
444 $(Q)$(MAKE) $(build)=scripts/kconfig $@
445
446%config: scripts_basic outputmakefile FORCE
443 $(Q)mkdir -p include/linux include/config 447 $(Q)mkdir -p include/linux include/config
444 $(Q)$(MAKE) $(build)=scripts/kconfig $@ 448 $(Q)$(MAKE) $(build)=scripts/kconfig $@
445 449
@@ -600,20 +604,25 @@ export INSTALL_PATH ?= /boot
600MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) 604MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
601export MODLIB 605export MODLIB
602 606
603# 607strip-symbols := $(srctree)/scripts/strip-symbols \
604# INSTALL_MOD_STRIP, if defined, will cause modules to be 608 $(wildcard $(srctree)/arch/$(ARCH)/scripts/strip-symbols)
605# stripped after they are installed. If INSTALL_MOD_STRIP is '1', then
606# the default option --strip-debug will be used. Otherwise,
607# INSTALL_MOD_STRIP will used as the options to the strip command.
608 609
610#
611# INSTALL_MOD_STRIP, if defined, will cause modules to be stripped while
612# they get installed. If INSTALL_MOD_STRIP is '1', then the default
613# options (see below) will be used. Otherwise, INSTALL_MOD_STRIP will
614# be used as the option(s) to the objcopy command.
609ifdef INSTALL_MOD_STRIP 615ifdef INSTALL_MOD_STRIP
610ifeq ($(INSTALL_MOD_STRIP),1) 616ifeq ($(INSTALL_MOD_STRIP),1)
611mod_strip_cmd = $(STRIP) --strip-debug 617mod_strip_cmd = $(OBJCOPY) --strip-debug
618ifeq ($(CONFIG_KALLSYMS_ALL),$(CONFIG_KALLSYMS_STRIP_GENERATED))
619mod_strip_cmd += --wildcard $(addprefix --strip-symbols ,$(strip-symbols))
620endif
612else 621else
613mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP) 622mod_strip_cmd = $(OBJCOPY) $(INSTALL_MOD_STRIP)
614endif # INSTALL_MOD_STRIP=1 623endif # INSTALL_MOD_STRIP=1
615else 624else
616mod_strip_cmd = true 625mod_strip_cmd = false
617endif # INSTALL_MOD_STRIP 626endif # INSTALL_MOD_STRIP
618export mod_strip_cmd 627export mod_strip_cmd
619 628
@@ -743,6 +752,7 @@ last_kallsyms := 2
743endif 752endif
744 753
745kallsyms.o := .tmp_kallsyms$(last_kallsyms).o 754kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
755kallsyms.h := $(wildcard include/config/kallsyms/*.h) $(wildcard include/config/kallsyms/*/*.h)
746 756
747define verify_kallsyms 757define verify_kallsyms
748 $(Q)$(if $($(quiet)cmd_sysmap), \ 758 $(Q)$(if $($(quiet)cmd_sysmap), \
@@ -767,24 +777,41 @@ endef
767 777
768# Generate .S file with all kernel symbols 778# Generate .S file with all kernel symbols
769quiet_cmd_kallsyms = KSYM $@ 779quiet_cmd_kallsyms = KSYM $@
770 cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) \ 780 cmd_kallsyms = { test $* -eq 0 || $(NM) -n $<; } \
771 $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) > $@ 781 | $(KALLSYMS) $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) >$@
772 782
773.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE 783quiet_cmd_kstrip = STRIP $@
784 cmd_kstrip = $(OBJCOPY) --wildcard $(addprefix --strip$(if $(CONFIG_RELOCATABLE),-unneeded)-symbols ,$(filter %/scripts/strip-symbols,$^)) $< $@
785
786$(foreach n,0 1 2 3,.tmp_kallsyms$(n).o): KBUILD_AFLAGS += -Wa,--strip-local-absolute
787$(foreach n,0 1 2 3,.tmp_kallsyms$(n).o): %.o: %.S scripts FORCE
774 $(call if_changed_dep,as_o_S) 788 $(call if_changed_dep,as_o_S)
775 789
776.tmp_kallsyms%.S: .tmp_vmlinux% $(KALLSYMS) 790ifeq ($(CONFIG_KALLSYMS_STRIP_GENERATED),y)
791strip-ext := .stripped
792endif
793
794.tmp_kallsyms%.S: .tmp_vmlinux%$(strip-ext) $(KALLSYMS) $(kallsyms.h)
777 $(call cmd,kallsyms) 795 $(call cmd,kallsyms)
778 796
797# make -jN seems to have problems with intermediate files, see bug #3330.
798.SECONDARY: $(foreach n,1 2 3,.tmp_vmlinux$(n).stripped)
799.tmp_vmlinux%.stripped: .tmp_vmlinux% $(strip-symbols) $(kallsyms.h)
800 $(call cmd,kstrip)
801
802ifneq ($(CONFIG_DEBUG_INFO),y)
803.tmp_vmlinux%: LDFLAGS_vmlinux += -S
804endif
779# .tmp_vmlinux1 must be complete except kallsyms, so update vmlinux version 805# .tmp_vmlinux1 must be complete except kallsyms, so update vmlinux version
780.tmp_vmlinux1: $(vmlinux-lds) $(vmlinux-all) FORCE 806.tmp_vmlinux%: $(vmlinux-lds) $(vmlinux-all) FORCE
781 $(call if_changed_rule,ksym_ld) 807 $(if $(filter 1,$*),$(call if_changed_rule,ksym_ld),$(call if_changed,vmlinux__))
782 808
783.tmp_vmlinux2: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms1.o FORCE 809.tmp_vmlinux0$(strip-ext):
784 $(call if_changed,vmlinux__) 810 $(Q)echo "placeholder" >$@
785 811
786.tmp_vmlinux3: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms2.o FORCE 812.tmp_vmlinux1: .tmp_kallsyms0.o
787 $(call if_changed,vmlinux__) 813.tmp_vmlinux2: .tmp_kallsyms1.o
814.tmp_vmlinux3: .tmp_kallsyms2.o
788 815
789# Needs to visit scripts/ before $(KALLSYMS) can be used. 816# Needs to visit scripts/ before $(KALLSYMS) can be used.
790$(KALLSYMS): scripts ; 817$(KALLSYMS): scripts ;
@@ -926,7 +953,7 @@ PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
926# 2) Create the include2 directory, used for the second asm symlink 953# 2) Create the include2 directory, used for the second asm symlink
927prepare3: include/config/kernel.release 954prepare3: include/config/kernel.release
928ifneq ($(KBUILD_SRC),) 955ifneq ($(KBUILD_SRC),)
929 @echo ' Using $(srctree) as source for kernel' 956 @$(kecho) ' Using $(srctree) as source for kernel'
930 $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \ 957 $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
931 echo " $(srctree) is not clean, please run 'make mrproper'";\ 958 echo " $(srctree) is not clean, please run 'make mrproper'";\
932 echo " in the '$(srctree)' directory.";\ 959 echo " in the '$(srctree)' directory.";\
@@ -983,7 +1010,7 @@ endef
983# directory for generated filesas used by some architectures. 1010# directory for generated filesas used by some architectures.
984define create-symlink 1011define create-symlink
985 if [ ! -L include/asm ]; then \ 1012 if [ ! -L include/asm ]; then \
986 echo ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \ 1013 $(kecho) ' SYMLINK $@ -> include/asm-$(SRCARCH)'; \
987 if [ ! -d include/asm-$(SRCARCH) ]; then \ 1014 if [ ! -d include/asm-$(SRCARCH) ]; then \
988 mkdir -p include/asm-$(SRCARCH); \ 1015 mkdir -p include/asm-$(SRCARCH); \
989 fi; \ 1016 fi; \
@@ -1022,6 +1049,10 @@ include/linux/version.h: $(srctree)/Makefile FORCE
1022include/linux/utsrelease.h: include/config/kernel.release FORCE 1049include/linux/utsrelease.h: include/config/kernel.release FORCE
1023 $(call filechk,utsrelease.h) 1050 $(call filechk,utsrelease.h)
1024 1051
1052PHONY += headerdep
1053headerdep:
1054 $(Q)find include/ -name '*.h' | xargs --max-args 1 scripts/headerdep.pl
1055
1025# --------------------------------------------------------------------------- 1056# ---------------------------------------------------------------------------
1026 1057
1027PHONY += depend dep 1058PHONY += depend dep
@@ -1096,7 +1127,7 @@ all: modules
1096PHONY += modules 1127PHONY += modules
1097modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) 1128modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
1098 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order 1129 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
1099 @echo ' Building modules, stage 2.'; 1130 @$(kecho) ' Building modules, stage 2.';
1100 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1131 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1101 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild 1132 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild
1102 1133
@@ -1270,7 +1301,8 @@ help:
1270 @echo ' versioncheck - Sanity check on version.h usage' 1301 @echo ' versioncheck - Sanity check on version.h usage'
1271 @echo ' includecheck - Check for duplicate included header files' 1302 @echo ' includecheck - Check for duplicate included header files'
1272 @echo ' export_report - List the usages of all exported symbols' 1303 @echo ' export_report - List the usages of all exported symbols'
1273 @echo ' headers_check - Sanity check on exported headers'; \ 1304 @echo ' headers_check - Sanity check on exported headers'
1305 @echo ' headerdep - Detect inclusion cycles in headers'; \
1274 echo '' 1306 echo ''
1275 @echo 'Kernel packaging:' 1307 @echo 'Kernel packaging:'
1276 @$(MAKE) $(build)=$(package-dir) help 1308 @$(MAKE) $(build)=$(package-dir) help
@@ -1360,7 +1392,7 @@ $(module-dirs): crmodverdir $(objtree)/Module.symvers
1360 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) 1392 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
1361 1393
1362modules: $(module-dirs) 1394modules: $(module-dirs)
1363 @echo ' Building modules, stage 2.'; 1395 @$(kecho) ' Building modules, stage 2.';
1364 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1396 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1365 1397
1366PHONY += modules_install 1398PHONY += modules_install
@@ -1409,123 +1441,12 @@ endif # KBUILD_EXTMOD
1409 1441
1410# Generate tags for editors 1442# Generate tags for editors
1411# --------------------------------------------------------------------------- 1443# ---------------------------------------------------------------------------
1444quiet_cmd_tags = GEN $@
1445 cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@
1412 1446
1413#We want __srctree to totally vanish out when KBUILD_OUTPUT is not set 1447tags TAGS cscope: FORCE
1414#(which is the most common case IMHO) to avoid unneeded clutter in the big tags file.
1415#Adding $(srctree) adds about 20M on i386 to the size of the output file!
1416
1417ifeq ($(src),$(obj))
1418__srctree =
1419else
1420__srctree = $(srctree)/
1421endif
1422
1423ifeq ($(ALLSOURCE_ARCHS),)
1424ifeq ($(ARCH),um)
1425ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH)
1426else
1427ALLINCLUDE_ARCHS := $(SRCARCH)
1428endif
1429else
1430#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour.
1431ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS)
1432endif
1433
1434ALLSOURCE_ARCHS := $(SRCARCH)
1435
1436define find-sources
1437 ( for arch in $(ALLSOURCE_ARCHS) ; do \
1438 find $(__srctree)arch/$${arch} $(RCS_FIND_IGNORE) \
1439 -wholename $(__srctree)arch/$${arch}/include/asm -type d -prune \
1440 -o -name $1 -print; \
1441 done ; \
1442 find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \
1443 -name $1 -print; \
1444 find $(__srctree)include $(RCS_FIND_IGNORE) \
1445 \( -name config -o -name 'asm-*' \) -prune \
1446 -o -name $1 -print; \
1447 for arch in $(ALLINCLUDE_ARCHS) ; do \
1448 test -e $(__srctree)include/asm-$${arch} && \
1449 find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \
1450 -name $1 -print; \
1451 test -e $(__srctree)arch/$${arch}/include/asm && \
1452 find $(__srctree)arch/$${arch}/include/asm $(RCS_FIND_IGNORE) \
1453 -name $1 -print; \
1454 done ; \
1455 find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \
1456 -name $1 -print; \
1457 find $(__srctree) $(RCS_FIND_IGNORE) \
1458 \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \
1459 -name $1 -print; \
1460 )
1461endef
1462
1463define all-sources
1464 $(call find-sources,'*.[chS]')
1465endef
1466define all-kconfigs
1467 $(call find-sources,'Kconfig*')
1468endef
1469define all-defconfigs
1470 $(call find-sources,'defconfig')
1471endef
1472
1473define xtags
1474 if $1 --version 2>&1 | grep -iq exuberant; then \
1475 $(all-sources) | xargs $1 -a \
1476 -I __initdata,__exitdata,__acquires,__releases \
1477 -I __read_mostly,____cacheline_aligned,____cacheline_aligned_in_smp,____cacheline_internodealigned_in_smp \
1478 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
1479 --extra=+f --c-kinds=+px \
1480 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/'; \
1481 $(all-kconfigs) | xargs $1 -a \
1482 --langdef=kconfig \
1483 --language-force=kconfig \
1484 --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/'; \
1485 $(all-defconfigs) | xargs -r $1 -a \
1486 --langdef=dotconfig \
1487 --language-force=dotconfig \
1488 --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'; \
1489 elif $1 --version 2>&1 | grep -iq emacs; then \
1490 $(all-sources) | xargs $1 -a; \
1491 $(all-kconfigs) | xargs $1 -a \
1492 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'; \
1493 $(all-defconfigs) | xargs -r $1 -a \
1494 --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'; \
1495 else \
1496 $(all-sources) | xargs $1 -a; \
1497 fi
1498endef
1499
1500quiet_cmd_cscope-file = FILELST cscope.files
1501 cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files
1502
1503quiet_cmd_cscope = MAKE cscope.out
1504 cmd_cscope = cscope -b -f cscope.out
1505
1506cscope: FORCE
1507 $(call cmd,cscope-file)
1508 $(call cmd,cscope)
1509
1510quiet_cmd_TAGS = MAKE $@
1511define cmd_TAGS
1512 rm -f $@; \
1513 $(call xtags,etags)
1514endef
1515
1516TAGS: FORCE
1517 $(call cmd,TAGS)
1518
1519quiet_cmd_tags = MAKE $@
1520define cmd_tags
1521 rm -f $@; \
1522 $(call xtags,ctags)
1523endef
1524
1525tags: FORCE
1526 $(call cmd,tags) 1448 $(call cmd,tags)
1527 1449
1528
1529# Scripts to check various things for consistency 1450# Scripts to check various things for consistency
1530# --------------------------------------------------------------------------- 1451# ---------------------------------------------------------------------------
1531 1452
@@ -1604,7 +1525,11 @@ endif
1604 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1525 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1605 1526
1606# Modules 1527# Modules
1607/ %/: prepare scripts FORCE 1528/: prepare scripts FORCE
1529 $(cmd_crmodverdir)
1530 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1531 $(build)=$(build-dir)
1532%/: prepare scripts FORCE
1608 $(cmd_crmodverdir) 1533 $(cmd_crmodverdir)
1609 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1534 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1610 $(build)=$(build-dir) 1535 $(build)=$(build-dir)
@@ -1638,7 +1563,7 @@ cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \
1638 $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) 1563 $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*)
1639 1564
1640a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \ 1565a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \
1641 $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ 1566 $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CPPFLAGS) \
1642 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o) 1567 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
1643 1568
1644quiet_cmd_as_o_S = AS $@ 1569quiet_cmd_as_o_S = AS $@