Merge to Fedora kernel-2.6.7-1.492
[linux-2.6.git] / Makefile
index 211b410..6d0ffee 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 6
 SUBLEVEL = 7
-EXTRAVERSION = -1.441-vs1.9.1
+EXTRAVERSION = -1.492-ckrm.E15-vs1.9.1
 NAME=Zonked Quokka
 
 # *DOCUMENTATION*
@@ -290,8 +290,6 @@ STRIP               = $(CROSS_COMPILE)strip
 OBJCOPY                = $(CROSS_COMPILE)objcopy
 OBJDUMP                = $(CROSS_COMPILE)objdump
 AWK            = awk
-RPM            := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
-                       else echo rpm; fi)
 GENKSYMS       = scripts/genksyms/genksyms
 DEPMOD         = /sbin/depmod
 KALLSYMS       = scripts/kallsyms
@@ -334,8 +332,8 @@ depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
 
 # Files to ignore in find ... statements
 
-RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \) -prune -o
-RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS
+RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc \) -prune -o
+RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc
 
 # ===========================================================================
 # Rules shared between *config targets and build targets
@@ -409,13 +407,6 @@ scripts: scripts_basic include/config/MARKER
 
 scripts_basic: include/linux/autoconf.h
 
-
-# That's our default target when none is given on the command line
-# Note that 'modules' will be added as a prerequisite as well, 
-# in the CONFIG_MODULES part below
-
-all:   vmlinux
-
 # Objects we will link into vmlinux / subdirs we need to visit
 init-y         := init/
 drivers-y      := drivers/ sound/
@@ -449,6 +440,19 @@ endif
 
 include $(srctree)/arch/$(ARCH)/Makefile
 
+# Default kernel image to build when no specific target is given.
+# KBUILD_IMAGE may be overruled on the commandline or
+# set in the environment
+# Also any assingments in arch/$(ARCH)/Makefiel take precedence over
+# this default value
+export KBUILD_IMAGE ?= vmlinux
+
+# The all: target is the default when no target is given on the
+# command line.
+# This allow a user to issue only 'make' to build a kernel including modules
+# Defaults vmlinux but it is usually overriden in the arch makefile
+all: vmlinux
+
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 CFLAGS         += -Os
 else
@@ -544,10 +548,7 @@ define rule_vmlinux__
        echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
 endef
 
-define rule_vmlinux
-       $(rule_vmlinux__); \
-       $(NM) $@ | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
-endef
+do_system_map = $(NM) $(1) | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > $(2)
 
 LDFLAGS_vmlinux += -T arch/$(ARCH)/kernel/vmlinux.lds.s
 
@@ -561,30 +562,57 @@ LDFLAGS_vmlinux += -T arch/$(ARCH)/kernel/vmlinux.lds.s
 #        but due to the added section, some addresses have shifted
 #        From here, we generate a correct .tmp_kallsyms2.o
 #      o The correct .tmp_kallsyms2.o is linked into the final vmlinux.
+#      o Verify that the System.map from vmlinux matches the map from
+#        .tmp_vmlinux2, just in case we did not generate kallsyms correctly.
+#      o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using
+#        .tmp_vmlinux3 and .tmp_kallsyms3.o.  This is only meant as a
+#        temporary bypass to allow the kernel to be built while the
+#        maintainers work out what went wrong with kallsyms.
 
 ifdef CONFIG_KALLSYMS
 
-kallsyms.o := .tmp_kallsyms2.o
+ifdef CONFIG_KALLSYMS_EXTRA_PASS
+last_kallsyms := 3
+else
+last_kallsyms := 2
+endif
+
+kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
+
+define rule_verify_kallsyms
+       @$(call do_system_map, .tmp_vmlinux$(last_kallsyms), .tmp_System.map)
+       @cmp -s System.map .tmp_System.map || \
+               (echo Inconsistent kallsyms data, try setting CONFIG_KALLSYMS_EXTRA_PASS ; rm .tmp_kallsyms* ; false)
+endef
 
 quiet_cmd_kallsyms = KSYM    $@
 cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) $(foreach x,$(CONFIG_KALLSYMS_ALL),--all-symbols) > $@
 
-.tmp_kallsyms1.o .tmp_kallsyms2.o: %.o: %.S scripts FORCE
+.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE
        $(call if_changed_dep,as_o_S)
 
 .tmp_kallsyms%.S: .tmp_vmlinux%
        $(call cmd,kallsyms)
 
 .tmp_vmlinux1: $(vmlinux-objs) arch/$(ARCH)/kernel/vmlinux.lds.s FORCE
-       +$(call if_changed_rule,vmlinux__)
+       $(call if_changed_rule,vmlinux__)
 
 .tmp_vmlinux2: $(vmlinux-objs) .tmp_kallsyms1.o arch/$(ARCH)/kernel/vmlinux.lds.s FORCE
        $(call if_changed_rule,vmlinux__)
 
+.tmp_vmlinux3: $(vmlinux-objs) .tmp_kallsyms2.o arch/$(ARCH)/kernel/vmlinux.lds.s FORCE
+       $(call if_changed_rule,vmlinux__)
+
 endif
 
 #      Finally the vmlinux rule
 
+define rule_vmlinux
+       $(rule_vmlinux__); \
+       $(call do_system_map, $@, System.map)
+       $(rule_verify_kallsyms)
+endef
+
 vmlinux: $(vmlinux-objs) $(kallsyms.o) arch/$(ARCH)/kernel/vmlinux.lds.s FORCE
        $(call if_changed_rule,vmlinux)
 
@@ -795,8 +823,8 @@ endef
 
 # Directories & files removed with 'make clean'
 CLEAN_DIRS  += $(MODVERDIR)
-CLEAN_FILES += vmlinux System.map kernel.spec \
-                .tmp_kallsyms* .tmp_version .tmp_vmlinux*
+CLEAN_FILES += vmlinux System.map \
+                .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
 
 # Directories & files removed with 'make mrproper'
 MRPROPER_DIRS  += include/config include2
@@ -841,44 +869,26 @@ mrproper: clean archmrproper $(mrproper-dirs)
 .PHONY: distclean
 
 distclean: mrproper
-       @find . $(RCS_FIND_IGNORE) \
+       @find $(srctree) $(RCS_FIND_IGNORE) \
                \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
                -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
                -o -name '.*.rej' -o -size 0 \
                -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
                -type f -print | xargs rm -f
 
-# RPM target
-# ---------------------------------------------------------------------------
-
-.PHONY: rpm
-
-# Remove hyphens since they have special meaning in RPM filenames
-KERNELPATH=kernel-$(subst -,,$(KERNELRELEASE))
 
-#      If you do a make spec before packing the tarball you can rpm -ta it
-
-spec:
-       $(CONFIG_SHELL) $(srctree)/scripts/mkspec > $(objtree)/kernel.spec
-
-#      a) Build a tar ball
-#      b) generate an rpm from it
-#      c) and pack the result
-#      - Use /. to avoid tar packing just the symlink
+# Packaging of the kernel to various formats
+# ---------------------------------------------------------------------------
+# rpm target kept for backward compatibility
+package-dir    := $(srctree)/scripts/package
 
-rpm:   clean spec
-       set -e; \
-       cd .. ; \
-       ln -sf $(srctree) $(KERNELPATH) ; \
-       tar -cvz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. ; \
-       rm $(KERNELPATH)
+.PHONY: %-pkg rpm
 
-       set -e; \
-       $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version;\
-       mv -f $(objtree)/.tmp_version $(objtree)/.version;
+%pkg: FORCE
+       $(Q)$(MAKE) -f $(package-dir)/Makefile $@
+rpm: FORCE
+       $(Q)$(MAKE) -f $(package-dir)/Makefile $@
 
-       $(RPM) --target $(UTS_MACHINE) -ta ../$(KERNELPATH).tar.gz
-       rm ../$(KERNELPATH).tar.gz
 
 # Brief documentation of the typical targets used
 # ---------------------------------------------------------------------------
@@ -905,6 +915,8 @@ help:
        @echo  '  tags/TAGS       - Generate tags file for editors'
        @echo  '  cscope          - Generate cscope index'
        @echo  '  checkstack      - Generate a list of stack hogs'
+       @echo  'Kernel packaging:'
+       @$(MAKE) -f $(package-dir)/Makefile help
        @echo  ''
        @echo  'Documentation targets:'
        @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp
@@ -1070,7 +1082,7 @@ endif #ifeq ($(mixed-targets),1)
 .PHONY: checkstack
 checkstack:
        $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
-       $(PERL) scripts/checkstack.pl $(ARCH)
+       $(PERL) $(src)/scripts/checkstack.pl $(ARCH)
 
 # FIXME Should go into a make.lib or something 
 # ===========================================================================