Merge branch 'kbuild/clean' into kbuild/kbuild
authorMichal Marek <mmarek@suse.cz>
Mon, 13 Sep 2010 15:20:59 +0000 (17:20 +0200)
committerMichal Marek <mmarek@suse.cz>
Mon, 13 Sep 2010 15:20:59 +0000 (17:20 +0200)
1  2 
Documentation/kbuild/makefiles.txt
Makefile

@@@ -320,7 -320,7 +320,7 @@@ more details, with real examples
      subdir-ccflags-y, subdir-asflags-y
        The two flags listed above are similar to ccflags-y and as-falgs-y.
        The difference is that the subdir- variants has effect for the kbuild
 -      file where they are present and all subdirectories.
 +      file where tey are present and all subdirectories.
        Options specified using subdir-* are added to the commandline before
        the options specified using the non-subdir variants.
  
@@@ -779,6 -779,13 +779,13 @@@ This will delete the directory debian, 
  Kbuild will assume the directories to be in the same relative path as the
  Makefile if no absolute path is specified (path does not start with '/').
  
+ To exclude certain files from make clean, use the $(no-clean-files) variable.
+ This is only a special case used in the top level Kbuild file:
+       Example:
+               #Kbuild
+               no-clean-files := $(bounds-file) $(offsets-file)
  Usually kbuild descends down in subdirectories due to "obj-* := dir/",
  but in the architecture makefiles where the kbuild infrastructure
  is not sufficient this sometimes needs to be explicit.
@@@ -923,33 -930,16 +930,33 @@@ When kbuild executes, the following ste
        The first example utilises the trick that a config option expands
        to 'y' when selected.
  
 -    CFLAGS_KERNEL     $(CC) options specific for built-in
 +    KBUILD_AFLAGS_KERNEL      $(AS) options specific for built-in
  
 -      $(CFLAGS_KERNEL) contains extra C compiler flags used to compile
 +      $(KBUILD_AFLAGS_KERNEL) contains extra C compiler flags used to compile
        resident kernel code.
  
 -    CFLAGS_MODULE     $(CC) options specific for modules
 +    KBUILD_AFLAGS_MODULE   Options for $(AS) when building modules
  
 -      $(CFLAGS_MODULE) contains extra C compiler flags used to compile code
 -      for loadable kernel modules.
 +      $(KBUILD_AFLAGS_MODULE) is used to add arch specific options that
 +      are used for $(AS).
 +      From commandline AFLAGS_MODULE shall be used (see kbuild.txt).
  
 +    KBUILD_CFLAGS_KERNEL      $(CC) options specific for built-in
 +
 +      $(KBUILD_CFLAGS_KERNEL) contains extra C compiler flags used to compile
 +      resident kernel code.
 +
 +    KBUILD_CFLAGS_MODULE   Options for $(CC) when building modules
 +
 +      $(KBUILD_CFLAGS_MODULE) is used to add arch specific options that
 +      are used for $(CC).
 +      From commandline CFLAGS_MODULE shall be used (see kbuild.txt).
 +
 +    KBUILD_LDFLAGS_MODULE   Options for $(LD) when linking modules
 +
 +      $(KBUILD_LDFLAGS_MODULE) is used to add arch specific options
 +      used when linking modules. This is often a linker script.
 +      From commandline LDFLAGS_MODULE shall be used (see kbuild.txt).
  
  --- 6.2 Add prerequisites to archprepare:
  
diff --combined Makefile
+++ b/Makefile
@@@ -1,8 -1,8 +1,8 @@@
  VERSION = 2
  PATCHLEVEL = 6
 -SUBLEVEL = 33
 -EXTRAVERSION = -rc6
 -NAME = Man-Eating Seals of Antiquity
 +SUBLEVEL = 35
 +EXTRAVERSION =
 +NAME = Sheep on Meth
  
  # *DOCUMENTATION*
  # To see a list of typical targets execute "make help"
@@@ -189,6 -189,7 +189,6 @@@ SUBARCH := $(shell uname -m | sed -e s/
  # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
  export KBUILD_BUILDHOST := $(SUBARCH)
  ARCH          ?= $(SUBARCH)
 -CROSS_COMPILE ?=
  CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
  
  # Architecture as present in compile.h
@@@ -331,9 -332,10 +331,9 @@@ CHECK             = spars
  
  CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
                  -Wbitwise -Wno-return-void $(CF)
 -MODFLAGS      = -DMODULE
 -CFLAGS_MODULE   = $(MODFLAGS)
 -AFLAGS_MODULE   = $(MODFLAGS)
 -LDFLAGS_MODULE  = -T $(srctree)/scripts/module-common.lds
 +CFLAGS_MODULE   =
 +AFLAGS_MODULE   =
 +LDFLAGS_MODULE  =
  CFLAGS_KERNEL =
  AFLAGS_KERNEL =
  CFLAGS_GCOV   = -fprofile-arcs -ftest-coverage
@@@ -352,12 -354,7 +352,12 @@@ KBUILD_CFLAGS   := -Wall -Wundef -Wstri
                   -Werror-implicit-function-declaration \
                   -Wno-format-security \
                   -fno-delete-null-pointer-checks
 +KBUILD_AFLAGS_KERNEL :=
 +KBUILD_CFLAGS_KERNEL :=
  KBUILD_AFLAGS   := -D__ASSEMBLY__
 +KBUILD_AFLAGS_MODULE  := -DMODULE
 +KBUILD_CFLAGS_MODULE  := -DMODULE
 +KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
  
  # Read KERNELRELEASE from include/config/kernel.release (if it exists)
  KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
@@@ -372,8 -369,6 +372,8 @@@ export HOSTCXX HOSTCXXFLAGS LDFLAGS_MOD
  export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
  export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV
  export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
 +export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
 +export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
  
  # When compiling out-of-tree modules, put MODVERDIR in the module
  # tree rather than in the kernel tree. The kernel tree might
@@@ -419,7 -414,7 +419,7 @@@ endi
  no-dot-config-targets := clean mrproper distclean \
                         cscope TAGS tags help %docs check% \
                         include/linux/version.h headers_% \
 -                       kernelrelease kernelversion
 +                       kernelversion
  
  config-targets := 0
  mixed-targets  := 0
@@@ -562,10 -557,6 +562,10 @@@ KBUILD_CFLAGS    += -
  KBUILD_AFLAGS += -gdwarf-2
  endif
  
 +ifdef CONFIG_DEBUG_INFO_REDUCED
 +KBUILD_CFLAGS         += $(call cc-option, -femit-struct-debug-baseonly)
 +endif
 +
  ifdef CONFIG_FUNCTION_TRACER
  KBUILD_CFLAGS += -pg
  endif
@@@ -612,7 -603,7 +612,7 @@@ endi
  # Use --build-id when available.
  LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
                              $(call cc-ldoption, -Wl$(comma)--build-id,))
 -LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID)
 +KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID)
  LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID)
  
  ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
@@@ -892,10 -883,80 +892,10 @@@ PHONY += $(vmlinux-dirs
  $(vmlinux-dirs): prepare scripts
        $(Q)$(MAKE) $(build)=$@
  
 -# Build the kernel release string
 -#
 -# The KERNELRELEASE value built here is stored in the file
 -# include/config/kernel.release, and is used when executing several
 -# make targets, such as "make install" or "make modules_install."
 -#
 -# The eventual kernel release string consists of the following fields,
 -# shown in a hierarchical format to show how smaller parts are concatenated
 -# to form the larger and final value, with values coming from places like
 -# the Makefile, kernel config options, make command line options and/or
 -# SCM tag information.
 -#
 -#     $(KERNELVERSION)
 -#       $(VERSION)                    eg, 2
 -#       $(PATCHLEVEL)                 eg, 6
 -#       $(SUBLEVEL)                   eg, 18
 -#       $(EXTRAVERSION)               eg, -rc6
 -#     $(localver-full)
 -#       $(localver)
 -#         localversion*               (files without backups, containing '~')
 -#         $(CONFIG_LOCALVERSION)      (from kernel config setting)
 -#       $(LOCALVERSION)               (from make command line, if provided)
 -#       $(localver-extra)
 -#         $(scm-identifier)           (unique SCM tag, if one exists)
 -#           ./scripts/setlocalversion (only with CONFIG_LOCALVERSION_AUTO)
 -#           .scmversion               (only with CONFIG_LOCALVERSION_AUTO)
 -#         +                           (only without CONFIG_LOCALVERSION_AUTO
 -#                                      and without LOCALVERSION= and
 -#                                      repository is at non-tagged commit)
 -#
 -# For kernels without CONFIG_LOCALVERSION_AUTO compiled from an SCM that has
 -# been revised beyond a tagged commit, `+' is appended to the version string
 -# when not overridden by using "make LOCALVERSION=".  This indicates that the
 -# kernel is not a vanilla release version and has been modified.
 -
 -pattern = ".*/localversion[^~]*"
 -string  = $(shell cat /dev/null \
 -         `find $(objtree) $(srctree) -maxdepth 1 -regex $(pattern) | sort -u`)
 -
 -localver = $(subst $(space),, $(string) \
 -                            $(patsubst "%",%,$(CONFIG_LOCALVERSION)))
 -
 -# scripts/setlocalversion is called to create a unique identifier if the source
 -# is managed by a known SCM and the repository has been revised since the last
 -# tagged (release) commit.  The format of the identifier is determined by the
 -# SCM's implementation.
 -#
 -# .scmversion is used when generating rpm packages so we do not loose
 -# the version information from the SCM when we do the build of the kernel
 -# from the copied source
 -ifeq ($(wildcard .scmversion),)
 -        scm-identifier = $(shell $(CONFIG_SHELL) \
 -                         $(srctree)/scripts/setlocalversion $(srctree))
 -else
 -        scm-identifier = $(shell cat .scmversion 2> /dev/null)
 -endif
 -
 -ifdef CONFIG_LOCALVERSION_AUTO
 -      localver-extra = $(scm-identifier)
 -else
 -      ifneq ($scm-identifier,)
 -              ifeq ($(LOCALVERSION),)
 -                      localver-extra = +
 -              endif
 -      endif
 -endif
 -
 -localver-full = $(localver)$(LOCALVERSION)$(localver-extra)
 -
  # Store (new) KERNELRELASE string in include/config/kernel.release
 -kernelrelease = $(KERNELVERSION)$(localver-full)
  include/config/kernel.release: include/config/auto.conf FORCE
        $(Q)rm -f $@
 -      $(Q)echo $(kernelrelease) > $@
 +      $(Q)echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" > $@
  
  
  # Things we need to do before we recursively start building the kernel
@@@ -1034,7 -1095,7 +1034,7 @@@ all: module
  #     using awk while concatenating to the final file.
  
  PHONY += modules
 -modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
 +modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
        $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
        @$(kecho) '  Building modules, stage 2.';
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
@@@ -1056,7 -1117,7 +1056,7 @@@ PHONY += modules_instal
  modules_install: _modinst_ _modinst_post
  
  PHONY += _modinst_
 -_modinst_: modules.builtin
 +_modinst_:
        @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
                echo "Warning: you may need to install module-init-tools"; \
                echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\
@@@ -1119,21 -1180,13 +1119,13 @@@ MRPROPER_FILES += .config .config.old .
  #
  clean: rm-dirs  := $(CLEAN_DIRS)
  clean: rm-files := $(CLEAN_FILES)
- clean-dirs      := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs) Documentation)
+ clean-dirs      := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation)
  
  PHONY += $(clean-dirs) clean archclean
  $(clean-dirs):
        $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
  
- clean: archclean $(clean-dirs)
-       $(call cmd,rmdirs)
-       $(call cmd,rmfiles)
-       @find . $(RCS_FIND_IGNORE) \
-               \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
-               -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
-               -o -name '*.symtypes' -o -name 'modules.order' \
-               -o -name modules.builtin -o -name '.tmp_*.o.*' \
-               -o -name '*.gcno' \) -type f -print | xargs rm -f
+ clean: archclean
  
  # mrproper - Delete all generated files, including .config
  #
@@@ -1331,16 -1384,7 +1323,7 @@@ $(clean-dirs)
        $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
  
  clean:        rm-dirs := $(MODVERDIR)
- clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers \
-                    $(KBUILD_EXTMOD)/modules.order \
-                    $(KBUILD_EXTMOD)/modules.builtin
- clean: $(clean-dirs)
-       $(call cmd,rmdirs)
-       $(call cmd,rmfiles)
-       @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \
-               \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
-               -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
-               -o -name '*.gcno' \) -type f -print | xargs rm -f
+ clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers
  
  help:
        @echo  '  Building external modules.'
@@@ -1357,6 -1401,16 +1340,16 @@@ prepare: 
  scripts: ;
  endif # KBUILD_EXTMOD
  
+ clean: $(clean-dirs)
+       $(call cmd,rmdirs)
+       $(call cmd,rmfiles)
+       @find $(or $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
+               \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
+               -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
+               -o -name '*.symtypes' -o -name 'modules.order' \
+               -o -name modules.builtin -o -name '.tmp_*.o.*' \
+               -o -name '*.gcno' \) -type f -print | xargs rm -f
  # Generate tags for editors
  # ---------------------------------------------------------------------------
  quiet_cmd_tags = GEN     $@
@@@ -1402,9 -1456,9 +1395,9 @@@ checkstack
        $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
        $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH)
  
 -kernelrelease:
 -      $(if $(wildcard include/config/kernel.release), $(Q)echo $(KERNELRELEASE), \
 -      $(error kernelrelease not valid - run 'make prepare' to update it))
 +kernelrelease: include/config/kernel.release
 +      @echo $(KERNELRELEASE)
 +
  kernelversion:
        @echo $(KERNELVERSION)
  
@@@ -1481,7 -1535,6 +1474,7 @@@ cmd_crmodverdir = $(Q)mkdir -p $(MODVER
                    $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*)
  
  a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \
 +        $(KBUILD_AFLAGS_KERNEL)                              \
          $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CPPFLAGS) \
          $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)