@@ -336,7 +336,7 @@ LINUXINCLUDE := -Iinclude \
336336 -I$(srctree ) /arch/$(hdr-arch ) /include \
337337 -include include/linux/autoconf.h
338338
339- KBUILD_CPPFLAGS := -D__KERNEL__ $( LINUXINCLUDE )
339+ KBUILD_CPPFLAGS := -D__KERNEL__
340340
341341KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
342342 -fno-strict-aliasing -fno-common \
@@ -439,7 +439,11 @@ ifeq ($(config-targets),1)
439439include $(srctree ) /arch/$(SRCARCH ) /Makefile
440440export KBUILD_DEFCONFIG KBUILD_KCONFIG
441441
442- config % config : scripts_basic outputmakefile FORCE
442+ config : 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
443447 $(Q ) mkdir -p include/linux include/config
444448 $(Q )$(MAKE ) $(build ) =scripts/kconfig $@
445449
@@ -600,20 +604,25 @@ export INSTALL_PATH ?= /boot
600604MODLIB = $(INSTALL_MOD_PATH ) /lib/modules/$(KERNELRELEASE )
601605export MODLIB
602606
603- #
604- # INSTALL_MOD_STRIP, if defined, will cause modules to be
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.
607+ strip-symbols := $(srctree ) /scripts/strip-symbols \
608+ $(wildcard $(srctree ) /arch/$(ARCH ) /scripts/strip-symbols)
608609
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.
609615ifdef INSTALL_MOD_STRIP
610616ifeq ($(INSTALL_MOD_STRIP ) ,1)
611- mod_strip_cmd = $(STRIP ) --strip-debug
617+ mod_strip_cmd = $(OBJCOPY ) --strip-debug
618+ ifeq ($(CONFIG_KALLSYMS_ALL ) ,$(CONFIG_KALLSYMS_STRIP_GENERATED ) )
619+ mod_strip_cmd += --wildcard $(addprefix --strip-symbols ,$(strip-symbols ) )
620+ endif
612621else
613- mod_strip_cmd = $(STRIP ) $(INSTALL_MOD_STRIP )
622+ mod_strip_cmd = $(OBJCOPY ) $(INSTALL_MOD_STRIP )
614623endif # INSTALL_MOD_STRIP=1
615624else
616- mod_strip_cmd = true
625+ mod_strip_cmd = false
617626endif # INSTALL_MOD_STRIP
618627export mod_strip_cmd
619628
@@ -743,6 +752,7 @@ last_kallsyms := 2
743752endif
744753
745754kallsyms.o := .tmp_kallsyms$(last_kallsyms ) .o
755+ kallsyms.h := $(wildcard include/config/kallsyms/* .h) $(wildcard include/config/kallsyms/* /* .h)
746756
747757define verify_kallsyms
748758 $(Q )$(if $($(quiet ) cmd_sysmap) , \
@@ -767,24 +777,41 @@ endef
767777
768778# Generate .S file with all kernel symbols
769779quiet_cmd_kallsyms = KSYM $@
770- cmd_kallsyms = $ (NM ) -n $< | $( KALLSYMS ) \
771- $(if $(CONFIG_KALLSYMS_ALL ) ,--all-symbols) > $@
780+ cmd_kallsyms = { test $* -eq 0 || $ (NM ) -n $< ; } \
781+ | $( KALLSYMS ) $(if $(CONFIG_KALLSYMS_ALL ) ,--all-symbols) >$@
772782
773- .tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o : % .o: % .S scripts FORCE
783+ quiet_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
774788 $(call if_changed_dep,as_o_S)
775789
776- .tmp_kallsyms% .S : .tmp_vmlinux% $(KALLSYMS )
790+ ifeq ($(CONFIG_KALLSYMS_STRIP_GENERATED ) ,y)
791+ strip-ext := .stripped
792+ endif
793+
794+ .tmp_kallsyms% .S : .tmp_vmlinux% $(strip-ext ) $(KALLSYMS ) $(kallsyms.h )
777795 $(call cmd,kallsyms)
778796
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+
802+ ifneq ($(CONFIG_DEBUG_INFO ) ,y)
803+ .tmp_vmlinux% : LDFLAGS_vmlinux += -S
804+ endif
779805# .tmp_vmlinux1 must be complete except kallsyms, so update vmlinux version
780- .tmp_vmlinux1 : $(vmlinux-lds ) $(vmlinux-all ) FORCE
781- $(call if_changed_rule,ksym_ld)
806+ .tmp_vmlinux % : $(vmlinux-lds ) $(vmlinux-all ) FORCE
807+ $(if $( filter 1, $* ) , $( call if_changed_rule,ksym_ld) , $( call if_changed,vmlinux__) )
782808
783- .tmp_vmlinux2 : $( vmlinux-lds ) $( vmlinux-all ) .tmp_kallsyms1.o FORCE
784- $(call if_changed,vmlinux__)
809+ .tmp_vmlinux0 $( strip-ext ) :
810+ $(Q ) echo " placeholder " > $@
785811
786- .tmp_vmlinux3 : $(vmlinux-lds ) $(vmlinux-all ) .tmp_kallsyms2.o FORCE
787- $(call if_changed,vmlinux__)
812+ .tmp_vmlinux1 : .tmp_kallsyms0.o
813+ .tmp_vmlinux2 : .tmp_kallsyms1.o
814+ .tmp_vmlinux3 : .tmp_kallsyms2.o
788815
789816# Needs to visit scripts/ before $(KALLSYMS) can be used.
790817$(KALLSYMS ) : scripts ;
@@ -926,7 +953,7 @@ PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
926953# 2) Create the include2 directory, used for the second asm symlink
927954prepare3 : include/config/kernel.release
928955ifneq ($(KBUILD_SRC ) ,)
929- @echo ' Using $(srctree) as source for kernel'
956+ @$(kecho) ' Using $(srctree) as source for kernel'
930957 $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
931958 echo " $(srctree) is not clean, please run 'make mrproper'";\
932959 echo " in the '$(srctree)' directory.";\
@@ -983,7 +1010,7 @@ endef
9831010# directory for generated filesas used by some architectures.
9841011define create-symlink
9851012 if [ ! -L include/asm ]; then \
986- echo ' SYMLINK $@ -> include/asm-$(SRCARCH ) '; \
1013+ $( kecho ) ' SYMLINK $@ -> include/asm-$(SRCARCH ) '; \
9871014 if [ ! -d include/asm-$(SRCARCH ) ]; then \
9881015 mkdir -p include/asm-$(SRCARCH ) ; \
9891016 fi; \
@@ -1022,6 +1049,10 @@ include/linux/version.h: $(srctree)/Makefile FORCE
10221049include/linux/utsrelease.h : include/config/kernel.release FORCE
10231050 $(call filechk,utsrelease.h)
10241051
1052+ PHONY += headerdep
1053+ headerdep :
1054+ $(Q ) find include/ -name ' *.h' | xargs --max-args 1 scripts/headerdep.pl
1055+
10251056# ---------------------------------------------------------------------------
10261057
10271058PHONY += depend dep
@@ -1096,7 +1127,7 @@ all: modules
10961127PHONY += modules
10971128modules : $(vmlinux-dirs ) $(if $(KBUILD_BUILTIN ) ,vmlinux)
10981129 $(Q )$(AWK ) ' !x[$$0]++' $(vmlinux-dirs:%=$(objtree ) /%/modules.order ) > $(objtree ) /modules.order
1099- @echo ' Building modules, stage 2.' ;
1130+ @$( kecho ) ' Building modules, stage 2.' ;
11001131 $(Q )$(MAKE ) -f $(srctree ) /scripts/Makefile.modpost
11011132 $(Q )$(MAKE ) -f $(srctree ) /scripts/Makefile.fwinst obj=firmware __fw_modbuild
11021133
@@ -1270,7 +1301,8 @@ help:
12701301 @echo ' versioncheck - Sanity check on version.h usage'
12711302 @echo ' includecheck - Check for duplicate included header files'
12721303 @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' ; \
12741306 echo ' '
12751307 @echo ' Kernel packaging:'
12761308 @$(MAKE ) $(build ) =$(package-dir ) help
@@ -1360,7 +1392,7 @@ $(module-dirs): crmodverdir $(objtree)/Module.symvers
13601392 $(Q )$(MAKE ) $(build ) =$(patsubst _module_% ,% ,$@ )
13611393
13621394modules : $(module-dirs )
1363- @echo ' Building modules, stage 2.' ;
1395+ @$( kecho ) ' Building modules, stage 2.' ;
13641396 $(Q )$(MAKE ) -f $(srctree ) /scripts/Makefile.modpost
13651397
13661398PHONY += modules_install
@@ -1409,123 +1441,12 @@ endif # KBUILD_EXTMOD
14091441
14101442# Generate tags for editors
14111443# ---------------------------------------------------------------------------
1444+ quiet_cmd_tags = GEN $@
1445+ cmd_tags = $(CONFIG_SHELL ) $(srctree ) /scripts/tags.sh $@
14121446
1413- # We want __srctree to totally vanish out when KBUILD_OUTPUT is not set
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-
1417- ifeq ($(src ) ,$(obj ) )
1418- __srctree =
1419- else
1420- __srctree = $(srctree ) /
1421- endif
1422-
1423- ifeq ($(ALLSOURCE_ARCHS ) ,)
1424- ifeq ($(ARCH ) ,um)
1425- ALLINCLUDE_ARCHS := $(ARCH ) $(SUBARCH )
1426- else
1427- ALLINCLUDE_ARCHS := $(SRCARCH )
1428- endif
1429- else
1430- # Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour.
1431- ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS )
1432- endif
1433-
1434- ALLSOURCE_ARCHS := $(SRCARCH )
1435-
1436- define 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- )
1461- endef
1462-
1463- define all-sources
1464- $(call find-sources,'* .[chS]')
1465- endef
1466- define all-kconfigs
1467- $(call find-sources,'Kconfig* ')
1468- endef
1469- define all-defconfigs
1470- $(call find-sources,'defconfig')
1471- endef
1472-
1473- define 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
1498- endef
1499-
1500- quiet_cmd_cscope-file = FILELST cscope.files
1501- cmd_cscope-file = (echo \-k; echo \-q; $(all-sources ) ) > cscope.files
1502-
1503- quiet_cmd_cscope = MAKE cscope.out
1504- cmd_cscope = cscope -b -f cscope.out
1505-
1506- cscope : FORCE
1507- $(call cmd,cscope-file)
1508- $(call cmd,cscope)
1509-
1510- quiet_cmd_TAGS = MAKE $@
1511- define cmd_TAGS
1512- rm -f $@ ; \
1513- $(call xtags,etags)
1514- endef
1515-
1516- TAGS : FORCE
1517- $(call cmd,TAGS)
1518-
1519- quiet_cmd_tags = MAKE $@
1520- define cmd_tags
1521- rm -f $@ ; \
1522- $(call xtags,ctags)
1523- endef
1524-
1525- tags : FORCE
1447+ tags TAGS cscope : FORCE
15261448 $(call cmd,tags)
15271449
1528-
15291450# Scripts to check various things for consistency
15301451# ---------------------------------------------------------------------------
15311452
@@ -1604,7 +1525,11 @@ endif
16041525 $(Q )$(MAKE ) $(build ) =$(build-dir ) $(target-dir )$(notdir $@ )
16051526
16061527# 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
16081533 $(cmd_crmodverdir )
16091534 $(Q )$(MAKE ) KBUILD_MODULES=$(if $(CONFIG_MODULES ) ,1) \
16101535 $(build ) =$(build-dir )
@@ -1638,7 +1563,7 @@ cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \
16381563 $(if $(KBUILD_MODULES ) ,; rm -f $(MODVERDIR ) /* )
16391564
16401565a_flags = -Wp,-MD,$(depfile ) $(KBUILD_AFLAGS ) $(AFLAGS_KERNEL ) \
1641- $(NOSTDINC_FLAGS ) $(KBUILD_CPPFLAGS ) \
1566+ $(NOSTDINC_FLAGS ) $(LINUXINCLUDE ) $( KBUILD_CPPFLAGS ) \
16421567 $(modkern_aflags ) $(EXTRA_AFLAGS ) $(AFLAGS_$(basetarget ) .o )
16431568
16441569quiet_cmd_as_o_S = AS $@
0 commit comments