aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-05-28 13:32:28 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-28 13:32:28 -0400
commit1347a2cebcb4cd6ca94eda0ebc8c5c6825bc4544 (patch)
tree495eb1b7071a0890c1fa58c12139ebd6305e0e82 /Makefile
parent90324cc1b11a211e37eabd8cb863e1a1561d6b1d (diff)
parentf7fc237e330deaaea4ba6726b603d4058d1e6b38 (diff)
Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull kbuild updates from Michal Marek. Fixed up nontrivial merge conflict in Makefile as per Stephen Rothwell and linux-next (and trivial arch/sparc/Makefile changes due to removed sparc32 logic). * 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: mips: Fix KBUILD_CPPFLAGS definition kbuild: fix ia64 link kbuild: document KBUILD_LDS, KBUILD_VMLINUX_{INIT,MAIN} and LDFLAGS_vmlinux kbuild: link of vmlinux moved to a script kbuild: refactor final link of sparc32 kbuild: drop unused KBUILD_VMLINUX_OBJS from top-level Makefile kbuild: Makefile: remove unnecessary check for m68knommu ARCH
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile231
1 files changed, 15 insertions, 216 deletions
diff --git a/Makefile b/Makefile
index b62c1e09444a..dda21c3efc7b 100644
--- a/Makefile
+++ b/Makefile
@@ -231,10 +231,6 @@ endif
231# Where to locate arch specific headers 231# Where to locate arch specific headers
232hdr-arch := $(SRCARCH) 232hdr-arch := $(SRCARCH)
233 233
234ifeq ($(ARCH),m68knommu)
235 hdr-arch := m68k
236endif
237
238KCONFIG_CONFIG ?= .config 234KCONFIG_CONFIG ?= .config
239export KCONFIG_CONFIG 235export KCONFIG_CONFIG
240 236
@@ -341,7 +337,6 @@ AWK = awk
341GENKSYMS = scripts/genksyms/genksyms 337GENKSYMS = scripts/genksyms/genksyms
342INSTALLKERNEL := installkernel 338INSTALLKERNEL := installkernel
343DEPMOD = /sbin/depmod 339DEPMOD = /sbin/depmod
344KALLSYMS = scripts/kallsyms
345PERL = perl 340PERL = perl
346CHECK = sparse 341CHECK = sparse
347 342
@@ -739,197 +734,21 @@ libs-y1 := $(patsubst %/, %/lib.a, $(libs-y))
739libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) 734libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y))
740libs-y := $(libs-y1) $(libs-y2) 735libs-y := $(libs-y1) $(libs-y2)
741 736
742# Build vmlinux 737# Externally visible symbols (used by link-vmlinux.sh)
743# --------------------------------------------------------------------------- 738export KBUILD_VMLINUX_INIT := $(head-y) $(init-y)
744# vmlinux is built from the objects selected by $(vmlinux-init) and 739export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y) $(net-y)
745# $(vmlinux-main). Most are built-in.o files from top-level directories 740export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
746# in the kernel tree, others are specified in arch/$(ARCH)/Makefile. 741export LDFLAGS_vmlinux
747# Ordering when linking is important, and $(vmlinux-init) must be first.
748#
749# vmlinux
750# ^
751# |
752# +-< $(vmlinux-init)
753# | +--< init/version.o + more
754# |
755# +--< $(vmlinux-main)
756# | +--< driver/built-in.o mm/built-in.o + more
757# |
758# +-< kallsyms.o (see description in CONFIG_KALLSYMS section)
759#
760# vmlinux version (uname -v) cannot be updated during normal
761# descending-into-subdirs phase since we do not yet know if we need to
762# update vmlinux.
763# Therefore this step is delayed until just before final link of vmlinux -
764# except in the kallsyms case where it is done just before adding the
765# symbols to the kernel.
766#
767# System.map is generated to document addresses of all kernel symbols
768
769vmlinux-init := $(head-y) $(init-y)
770vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y)
771vmlinux-all := $(vmlinux-init) $(vmlinux-main)
772vmlinux-lds := arch/$(SRCARCH)/kernel/vmlinux.lds
773export KBUILD_VMLINUX_OBJS := $(vmlinux-all)
774
775# Rule to link vmlinux - also used during CONFIG_KALLSYMS
776# May be overridden by arch/$(ARCH)/Makefile
777quiet_cmd_vmlinux__ ?= LD $@
778 cmd_vmlinux__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) -o $@ \
779 -T $(vmlinux-lds) $(vmlinux-init) \
780 --start-group $(vmlinux-main) --end-group \
781 $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o FORCE ,$^)
782
783# Generate new vmlinux version
784quiet_cmd_vmlinux_version = GEN .version
785 cmd_vmlinux_version = set -e; \
786 if [ ! -r .version ]; then \
787 rm -f .version; \
788 echo 1 >.version; \
789 else \
790 mv .version .old_version; \
791 expr 0$$(cat .old_version) + 1 >.version; \
792 fi; \
793 $(MAKE) $(build)=init
794
795# Generate System.map
796quiet_cmd_sysmap = SYSMAP
797 cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
798
799# Sort exception table at build time
800quiet_cmd_sortextable = SORTEX
801 cmd_sortextable = $(objtree)/scripts/sortextable
802
803# Link of vmlinux
804# If CONFIG_KALLSYMS is set .version is already updated
805# Generate System.map and verify that the content is consistent
806# Use + in front of the vmlinux_version rule to silent warning with make -j2
807# First command is ':' to allow us to use + in front of the rule
808define rule_vmlinux__
809 :
810 $(if $(CONFIG_KALLSYMS),,+$(call cmd,vmlinux_version))
811
812 $(call cmd,vmlinux__)
813 $(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
814
815 $(if $(CONFIG_BUILDTIME_EXTABLE_SORT), \
816 $(Q)$(if $($(quiet)cmd_sortextable), \
817 echo ' $($(quiet)cmd_sortextable) vmlinux' &&) \
818 $(cmd_sortextable) vmlinux)
819
820
821 $(Q)$(if $($(quiet)cmd_sysmap), \
822 echo ' $($(quiet)cmd_sysmap) System.map' &&) \
823 $(cmd_sysmap) $@ System.map; \
824 if [ $$? -ne 0 ]; then \
825 rm -f $@; \
826 /bin/false; \
827 fi;
828 $(verify_kallsyms)
829endef
830
831
832ifdef CONFIG_KALLSYMS
833# Generate section listing all symbols and add it into vmlinux $(kallsyms.o)
834# It's a three stage process:
835# o .tmp_vmlinux1 has all symbols and sections, but __kallsyms is
836# empty
837# Running kallsyms on that gives us .tmp_kallsyms1.o with
838# the right size - vmlinux version (uname -v) is updated during this step
839# o .tmp_vmlinux2 now has a __kallsyms section of the right size,
840# but due to the added section, some addresses have shifted.
841# From here, we generate a correct .tmp_kallsyms2.o
842# o The correct .tmp_kallsyms2.o is linked into the final vmlinux.
843# o Verify that the System.map from vmlinux matches the map from
844# .tmp_vmlinux2, just in case we did not generate kallsyms correctly.
845# o If 'make KALLSYMS_EXTRA_PASS=1" was used, do an extra pass using
846# .tmp_vmlinux3 and .tmp_kallsyms3.o. This is only meant as a
847# temporary bypass to allow the kernel to be built while the
848# maintainers work out what went wrong with kallsyms.
849
850last_kallsyms := 2
851
852ifdef KALLSYMS_EXTRA_PASS
853ifneq ($(KALLSYMS_EXTRA_PASS),0)
854last_kallsyms := 3
855endif
856endif
857
858kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
859
860define verify_kallsyms
861 $(Q)$(if $($(quiet)cmd_sysmap), \
862 echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \
863 $(cmd_sysmap) .tmp_vmlinux$(last_kallsyms) .tmp_System.map
864 $(Q)cmp -s System.map .tmp_System.map || \
865 (echo Inconsistent kallsyms data; \
866 echo This is a bug - please report about it; \
867 echo Try "make KALLSYMS_EXTRA_PASS=1" as a workaround; \
868 rm .tmp_kallsyms* ; /bin/false )
869endef
870
871# Update vmlinux version before link
872# Use + in front of this rule to silent warning about make -j1
873# First command is ':' to allow us to use + in front of this rule
874cmd_ksym_ld = $(cmd_vmlinux__)
875define rule_ksym_ld
876 :
877 +$(call cmd,vmlinux_version)
878 $(call cmd,vmlinux__)
879 $(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
880endef
881
882# Generate .S file with all kernel symbols
883quiet_cmd_kallsyms = KSYM $@
884 cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) \
885 $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) > $@
886 742
887.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE 743vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN)
888 $(call if_changed_dep,as_o_S)
889 744
890.tmp_kallsyms%.S: .tmp_vmlinux% $(KALLSYMS) 745# Final link of vmlinux
891 $(call cmd,kallsyms) 746 cmd_link-vmlinux = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux)
747quiet_cmd_link-vmlinux = LINK $@
892 748
893# .tmp_vmlinux1 must be complete except kallsyms, so update vmlinux version 749# Include targets which we want to
894.tmp_vmlinux1: $(vmlinux-lds) $(vmlinux-all) FORCE 750# execute if the rest of the kernel build went well.
895 $(call if_changed_rule,ksym_ld) 751vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) FORCE
896
897.tmp_vmlinux2: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms1.o FORCE
898 $(call if_changed,vmlinux__)
899
900.tmp_vmlinux3: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms2.o FORCE
901 $(call if_changed,vmlinux__)
902
903# Needs to visit scripts/ before $(KALLSYMS) can be used.
904$(KALLSYMS): scripts ;
905
906# Generate some data for debugging strange kallsyms problems
907debug_kallsyms: .tmp_map$(last_kallsyms)
908
909.tmp_map%: .tmp_vmlinux% FORCE
910 ($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@
911
912.tmp_map3: .tmp_map2
913
914.tmp_map2: .tmp_map1
915
916endif # ifdef CONFIG_KALLSYMS
917
918# Do modpost on a prelinked vmlinux. The finally linked vmlinux has
919# relevant sections renamed as per the linker script.
920quiet_cmd_vmlinux-modpost = LD $@
921 cmd_vmlinux-modpost = $(LD) $(LDFLAGS) -r -o $@ \
922 $(vmlinux-init) --start-group $(vmlinux-main) --end-group \
923 $(filter-out $(vmlinux-init) $(vmlinux-main) FORCE ,$^)
924define rule_vmlinux-modpost
925 :
926 +$(call cmd,vmlinux-modpost)
927 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@
928 $(Q)echo 'cmd_$@ := $(cmd_vmlinux-modpost)' > $(dot-target).cmd
929endef
930
931# vmlinux image - including updated kernel symbols
932vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o $(kallsyms.o) FORCE
933ifdef CONFIG_HEADERS_CHECK 752ifdef CONFIG_HEADERS_CHECK
934 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check 753 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check
935endif 754endif
@@ -939,22 +758,11 @@ endif
939ifdef CONFIG_BUILD_DOCSRC 758ifdef CONFIG_BUILD_DOCSRC
940 $(Q)$(MAKE) $(build)=Documentation 759 $(Q)$(MAKE) $(build)=Documentation
941endif 760endif
942 $(call vmlinux-modpost) 761 +$(call if_changed,link-vmlinux)
943 $(call if_changed_rule,vmlinux__)
944 $(Q)rm -f .old_version
945
946# build vmlinux.o first to catch section mismatch errors early
947ifdef CONFIG_KALLSYMS
948.tmp_vmlinux1: vmlinux.o
949endif
950
951modpost-init := $(filter-out init/built-in.o, $(vmlinux-init))
952vmlinux.o: $(modpost-init) $(vmlinux-main) FORCE
953 $(call if_changed_rule,vmlinux-modpost)
954 762
955# The actual objects are generated when descending, 763# The actual objects are generated when descending,
956# make sure no implicit rule kicks in 764# make sure no implicit rule kicks in
957$(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ; 765$(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
958 766
959# Handle descending into subdirectories listed in $(vmlinux-dirs) 767# Handle descending into subdirectories listed in $(vmlinux-dirs)
960# Preset locale variables to speed up the build process. Limit locale 768# Preset locale variables to speed up the build process. Limit locale
@@ -1181,8 +989,6 @@ endif # CONFIG_MODULES
1181 989
1182# Directories & files removed with 'make clean' 990# Directories & files removed with 'make clean'
1183CLEAN_DIRS += $(MODVERDIR) 991CLEAN_DIRS += $(MODVERDIR)
1184CLEAN_FILES += vmlinux System.map \
1185 .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
1186 992
1187# Directories & files removed with 'make mrproper' 993# Directories & files removed with 'make mrproper'
1188MRPROPER_DIRS += include/config usr/include include/generated \ 994MRPROPER_DIRS += include/config usr/include include/generated \
@@ -1428,6 +1234,7 @@ scripts: ;
1428endif # KBUILD_EXTMOD 1234endif # KBUILD_EXTMOD
1429 1235
1430clean: $(clean-dirs) 1236clean: $(clean-dirs)
1237 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
1431 $(call cmd,rmdirs) 1238 $(call cmd,rmdirs)
1432 $(call cmd,rmfiles) 1239 $(call cmd,rmfiles)
1433 @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ 1240 @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
@@ -1568,14 +1375,6 @@ quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
1568cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ 1375cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \
1569 $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) 1376 $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*)
1570 1377
1571a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \
1572 $(KBUILD_AFLAGS_KERNEL) \
1573 $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CPPFLAGS) \
1574 $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
1575
1576quiet_cmd_as_o_S = AS $@
1577cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
1578
1579# read all saved command lines 1378# read all saved command lines
1580 1379
1581targets := $(wildcard $(sort $(targets))) 1380targets := $(wildcard $(sort $(targets)))