-
-LDFLAGS_vmlinux += -T arch/$(ARCH)/kernel/vmlinux.lds.s
-
-# Generate section listing all symbols and add it into vmlinux
-# It's a three stage process:
-# o .tmp_vmlinux1 has all symbols and sections, but __kallsyms is
-# empty
-# Running kallsyms on that gives us .tmp_kallsyms1.o with
-# the right size
-# o .tmp_vmlinux2 now has a __kallsyms section of the right size,
-# 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.
-
-ifdef CONFIG_KALLSYMS
-
-kallsyms.o := .tmp_kallsyms2.o
-
-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
- $(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__)
-
-.tmp_vmlinux2: $(vmlinux-objs) .tmp_kallsyms1.o arch/$(ARCH)/kernel/vmlinux.lds.s FORCE
- $(call if_changed_rule,vmlinux__)
-
-endif
-
-# Finally the vmlinux rule
-
-vmlinux: $(vmlinux-objs) $(kallsyms.o) arch/$(ARCH)/kernel/vmlinux.lds.s FORCE
- $(call if_changed_rule,vmlinux)
-
-# The actual objects are generated when descending,
-# make sure no implicit rule kicks in
-
-$(sort $(vmlinux-objs)) arch/$(ARCH)/kernel/vmlinux.lds.s: $(vmlinux-dirs) ;
-
-# Handle descending into subdirectories listed in $(vmlinux-dirs)
-
-.PHONY: $(vmlinux-dirs)
-$(vmlinux-dirs): prepare-all scripts
- $(Q)$(MAKE) $(build)=$@
-
-# Things we need to do before we recursively start building the kernel
-# or the modules are listed in "prepare-all".
-# A multi level approach is used. prepare1 is updated first, then prepare0.
-# prepare-all is the collection point for the prepare targets.
-
-.PHONY: prepare-all prepare prepare0 prepare1
-
-# prepare1 is used to check if we are building in a separate output directory,
-# and if so do:
-# 1) Check that make has not been executed in the kernel src $(srctree)
-# 2) Create the include2 directory, used for the second asm symlink
-
-prepare1:
-ifneq ($(KBUILD_SRC),)
- @echo ' Using $(srctree) as source for kernel'
- $(Q)if [ -h $(srctree)/include/asm -o -f $(srctree)/.config ]; then \
- echo " $(srctree) is not clean, please run 'make mrproper'";\
- echo " in the '$(srctree)' directory.";\
- /bin/false; \
- fi;
- $(Q)if [ ! -d include2 ]; then mkdir -p include2; fi;
- $(Q)ln -fsn $(srctree)/include/asm-$(ARCH) include2/asm
-endif
-
-prepare0: prepare1 include/linux/version.h include/asm include/config/MARKER
-ifneq ($(KBUILD_MODULES),)
- $(Q)rm -rf $(MODVERDIR)
- $(Q)mkdir -p $(MODVERDIR)
-endif
-
-# All the preparing..
-prepare-all: prepare0 prepare
-
-# Leave this as default for preprocessing vmlinux.lds.S, which is now
-# done in arch/$(ARCH)/kernel/Makefile
-
-export AFLAGS_vmlinux.lds.o += -P -C -U$(ARCH)
-
-# Single targets
-# ---------------------------------------------------------------------------
-
-%.s: %.c scripts FORCE
- $(Q)$(MAKE) $(build)=$(@D) $@
-%.i: %.c scripts FORCE
- $(Q)$(MAKE) $(build)=$(@D) $@
-%.o: %.c scripts FORCE
- $(Q)$(MAKE) $(build)=$(@D) $@
-%/: scripts prepare FORCE
- $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D)
-%.lst: %.c scripts FORCE
- $(Q)$(MAKE) $(build)=$(@D) $@
-%.s: %.S scripts FORCE
- $(Q)$(MAKE) $(build)=$(@D) $@
-%.o: %.S scripts FORCE
- $(Q)$(MAKE) $(build)=$(@D) $@
-
-# FIXME: The asm symlink changes when $(ARCH) changes. That's
-# hard to detect, but I suppose "make mrproper" is a good idea
-# before switching between archs anyway.
-
-include/asm:
- @echo ' SYMLINK $@ -> include/asm-$(ARCH)'
- $(Q)if [ ! -d include ]; then mkdir -p include; fi;
- @ln -fsn asm-$(ARCH) $@
-
-# Split autoconf.h into include/linux/config/*
-
-include/config/MARKER: include/linux/autoconf.h
- @echo ' SPLIT include/linux/autoconf.h -> include/config/*'
- @scripts/basic/split-include include/linux/autoconf.h include/config
- @touch $@
-
-# Generate some files
-# ---------------------------------------------------------------------------
-
-# version.h changes when $(KERNELRELEASE) etc change, as defined in
-# this Makefile
-
-uts_len := 64
-
-define filechk_version.h
- if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
- echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
- exit 1; \
- fi; \
- (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
- echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
- echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \
- )
-endef
-
-include/linux/version.h: Makefile
- $(call filechk,version.h)
-
-# ---------------------------------------------------------------------------
-
-.PHONY: depend dep
-depend dep:
- @echo '*** Warning: make $@ is unnecessary now.'
-
-# ---------------------------------------------------------------------------
-# Modules
-
-ifdef CONFIG_MODULES
-
-# By default, build modules as well
-
-all: modules
-
-# Build modules
-
-.PHONY: modules
-modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
- @echo ' Building modules, stage 2.';
- $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
-
-
-# Target to prepare building external modules
-.PHONY: modules_prepare
-modules_prepare: prepare-all scripts
-
-# Target to install modules
-.PHONY: modules_install
-modules_install: _modinst_ _modinst_post
-
-.PHONY: _modinst_
-_modinst_:
- @if [ -z "`$(DEPMOD) -V | 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";\
- sleep 1; \
- fi
- @rm -rf $(MODLIB)/kernel
- @rm -f $(MODLIB)/build
- @mkdir -p $(MODLIB)/kernel
- @ln -s $(TOPDIR) $(MODLIB)/build
- $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
-
-# If System.map exists, run depmod. This deliberately does not have a
-# dependency on System.map since that would run the dependency tree on
-# vmlinux. This depmod is only for convenience to give the initial
-# boot a modules.dep even before / is mounted read-write. However the
-# boot script depmod is the master version.
-ifeq "$(strip $(INSTALL_MOD_PATH))" ""
-depmod_opts :=
-else
-depmod_opts := -b $(INSTALL_MOD_PATH) -r
-endif
-.PHONY: _modinst_post
-_modinst_post: _modinst_
- if [ -r System.map ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
-
-else # CONFIG_MODULES
-
-# Modules not configured
-# ---------------------------------------------------------------------------
-
-modules modules_install: FORCE
- @echo
- @echo "The present kernel configuration has modules disabled."
- @echo "Type 'make config' and enable loadable module support."
- @echo "Then build a kernel with module support enabled."
- @echo
- @exit 1
-
-endif # CONFIG_MODULES
-
-# Generate asm-offsets.h
-# ---------------------------------------------------------------------------
-
-define filechk_gen-asm-offsets
- (set -e; \
- echo "#ifndef __ASM_OFFSETS_H__"; \
- echo "#define __ASM_OFFSETS_H__"; \
- echo "/*"; \
- echo " * DO NOT MODIFY."; \
- echo " *"; \
- echo " * This file was generated by arch/$(ARCH)/Makefile"; \
- echo " *"; \
- echo " */"; \
- echo ""; \
- sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
- echo ""; \
- echo "#endif" )
-endef
-
-
-###
-# Cleaning is done on three levels.
-# make clean Delete most generated files
-# Leave enough to build external modules
-# make mrproper Delete the current configuration, and all generated files
-# make distclean Remove editor backup files, patch leftover files and the like
-
-# Directories & files removed with 'make clean'
-CLEAN_DIRS += $(MODVERDIR)
-CLEAN_FILES += vmlinux System.map kernel.spec \
- .tmp_kallsyms* .tmp_version .tmp_vmlinux*
-
-# Directories & files removed with 'make mrproper'
-MRPROPER_DIRS += include/config include2
-MRPROPER_FILES += .config .config.old include/asm .version \
- include/linux/autoconf.h include/linux/version.h \
- Module.symvers tags TAGS cscope*
-
-# clean - Delete most, but leave enough to build external modules
-#
-clean: rm-dirs := $(CLEAN_DIRS)
-clean: rm-files := $(CLEAN_FILES)
-clean-dirs := $(addprefix _clean_,$(vmlinux-alldirs))
-
-.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' \) \
- -type f -print | xargs rm -f
-
-# mrproper - Delete all generated files, including .config
-#
-mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
-mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
-mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts)
-
-.PHONY: $(mrproper-dirs) mrproper archmrproper
-$(mrproper-dirs):
- $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
-
-mrproper: clean archmrproper $(mrproper-dirs)
- $(call cmd,rmdirs)
- $(call cmd,rmfiles)
-
-# distclean
-#
-.PHONY: distclean
-
-distclean: mrproper
- @find . $(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
-
-rpm: clean spec
- set -e; \
- cd .. ; \
- ln -sf $(srctree) $(KERNELPATH) ; \
- tar -cvz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. ; \
- rm $(KERNELPATH)
-
- set -e; \
- $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version;\
- mv -f $(objtree)/.tmp_version $(objtree)/.version;
-
- $(RPM) --target $(UTS_MACHINE) -ta ../$(KERNELPATH).tar.gz
- rm ../$(KERNELPATH).tar.gz
-
-# Brief documentation of the typical targets used
-# ---------------------------------------------------------------------------
-
-boards := $(wildcard $(srctree)/arch/$(ARCH)/configs/*_defconfig)
-boards := $(notdir $(boards))
-
-help:
- @echo 'Cleaning targets:'
- @echo ' clean - remove most generated files but keep the config'
- @echo ' mrproper - remove all generated files + config + various backup files'
- @echo ''
- @echo 'Configuration targets:'
- @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
- @echo ''
- @echo 'Other generic targets:'
- @echo ' all - Build all targets marked with [*]'
- @echo '* vmlinux - Build the bare kernel'
- @echo '* modules - Build all modules'
- @echo ' modules_install - Install all modules'
- @echo ' dir/ - Build all files in dir and below'
- @echo ' dir/file.[ois] - Build specified target only'
- @echo ' rpm - Build a kernel as an RPM package'
- @echo ' tags/TAGS - Generate tags file for editors'
- @echo ' cscope - Generate cscope index'
- @echo ''
- @echo 'Documentation targets:'
- @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp
- @echo ''
- @echo 'Architecture specific targets ($(ARCH)):'
- @$(if $(archhelp),$(archhelp),\
- echo ' No architecture specific help defined for $(ARCH)')
- @echo ''
- @$(if $(boards), \
- $(foreach b, $(boards), \
- printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
- echo '')
-
- @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
- @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
- @echo ' make C=1 [targets] Check all c source with checker tool'
- @echo ''
- @echo 'Execute "make" or "make all" to build all targets marked with [*] '
- @echo 'For further info see the ./README file'
-
-
-# Documentation targets
-# ---------------------------------------------------------------------------
-%docs: scripts_basic FORCE
- $(Q)$(MAKE) $(build)=Documentation/DocBook $@
-
-else # KBUILD_EXTMOD
-
-###
-# External module support.
-# When building external modules the kernel used as basis is considered
-# read-only, and no consistency checks are made and the make
-# system is not used on the basis kernel. If updates are required
-# in the basis kernel ordinary make commands (without M=...) must
-# be used.
-#
-# The following are the only valid targets when building external
-# modules.
-# make M=dir clean Delete all automatically generated files
-# make M=dir modules Make all modules in specified dir
-# make M=dir Same as 'make M=dir modules'
-# make M=dir modules_install
-# Install the modules build in the module directory
-# Assumes install directory is already created
-
-# We are always building modules
-KBUILD_MODULES := 1
-.PHONY: crmodverdir
-crmodverdir:
- $(Q)mkdir -p $(MODVERDIR)
-
-module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
-.PHONY: $(module-dirs) modules
-$(module-dirs): crmodverdir
- $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
-
-modules: $(module-dirs)
- @echo ' Building modules, stage 2.';
- $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
-
-.PHONY: modules_install
-modules_install:
- $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
-
-clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))
-
-.PHONY: $(clean-dirs) clean
-$(clean-dirs):
- $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
-
-clean: rm-dirs := $(MODVERDIR)
-clean: $(clean-dirs)
- $(call cmd,rmdirs)
- @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \
- \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
- -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
- -type f -print | xargs rm -f
-
-help:
- @echo ' Building external modules.'
- @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
- @echo ''
- @echo ' modules - default target, build the module(s)'
- @echo ' modules_install - install the module'
- @echo ' clean - remove generated files in module directory only'
- @echo ''
-endif # KBUILD_EXTMOD
-
-# Generate tags for editors
-# ---------------------------------------------------------------------------
-
-define all-sources
- ( find . $(RCS_FIND_IGNORE) \
- \( -name include -o -name arch \) -prune -o \
- -name '*.[chS]' -print; \
- find arch/$(ARCH) $(RCS_FIND_IGNORE) \
- -name '*.[chS]' -print; \
- find security/selinux/include $(RCS_FIND_IGNORE) \
- -name '*.[chS]' -print; \
- find include $(RCS_FIND_IGNORE) \
- \( -name config -o -name 'asm-*' \) -prune \
- -o -name '*.[chS]' -print; \
- find include/asm-$(ARCH) $(RCS_FIND_IGNORE) \
- -name '*.[chS]' -print; \
- find include/asm-generic $(RCS_FIND_IGNORE) \
- -name '*.[chS]' -print )
-endef
-
-quiet_cmd_cscope-file = FILELST cscope.files
- cmd_cscope-file = $(all-sources) > cscope.files
-
-quiet_cmd_cscope = MAKE cscope.out
- cmd_cscope = cscope -k -b -q
-
-cscope: FORCE
- $(call cmd,cscope-file)
- $(call cmd,cscope)
-
-quiet_cmd_TAGS = MAKE $@
-cmd_TAGS = $(all-sources) | etags -
-
-# Exuberant ctags works better with -I
-
-quiet_cmd_tags = MAKE $@
-define cmd_tags
- rm -f $@; \
- CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \
- $(all-sources) | xargs ctags $$CTAGSF -a
-endef
-
-TAGS: FORCE
- $(call cmd,TAGS)
-
-tags: FORCE
- $(call cmd,tags)
-
-
-# Scripts to check various things for consistency
-# ---------------------------------------------------------------------------
-
-configcheck:
- find * $(RCS_FIND_IGNORE) \
- -name '*.[hcS]' -type f -print | sort \
- | xargs $(PERL) -w scripts/checkconfig.pl
-
-includecheck:
- find * $(RCS_FIND_IGNORE) \
- -name '*.[hcS]' -type f -print | sort \
- | xargs $(PERL) -w scripts/checkincludes.pl
-
-versioncheck:
- find * $(RCS_FIND_IGNORE) \
- -name '*.[hcS]' -type f -print | sort \
- | xargs $(PERL) -w scripts/checkversion.pl
-
-buildcheck:
- $(PERL) scripts/reference_discarded.pl
-
-endif #ifeq ($(config-targets),1)
-endif #ifeq ($(mixed-targets),1)
-
-.PHONY: checkstack
-checkstack:
- $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
- $(PERL) scripts/checkstack.pl $(ARCH)
-
-# FIXME Should go into a make.lib or something
-# ===========================================================================
-
-quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs)))
- cmd_rmdirs = rm -rf $(rm-dirs)
-
-quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
- cmd_rmfiles = rm -f $(rm-files)
-
-
-a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
- $(NOSTDINC_FLAGS) $(CPPFLAGS) \
- $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
-
-quiet_cmd_as_o_S = AS $@
-cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
-
-# read all saved command lines
-
-targets := $(wildcard $(sort $(targets)))
-cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
-
-ifneq ($(cmd_files),)
- $(cmd_files): ; # Do not try to update included dependency files
- include $(cmd_files)
-endif
-
-# execute the command and also postprocess generated .d dependencies
-# file
-
-if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
- $(filter-out $(cmd_$(1)),$(cmd_$@))\
- $(filter-out $(cmd_$@),$(cmd_$(1)))),\
- @set -e; \
- $(if $($(quiet)cmd_$(1)),echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';) \
- $(cmd_$(1)); \
- scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
- rm -f $(depfile); \
- mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
-
-# Usage: $(call if_changed_rule,foo)
-# will check if $(cmd_foo) changed, or any of the prequisites changed,
-# and if so will execute $(rule_foo)
-
-if_changed_rule = $(if $(strip $? \
- $(filter-out $(cmd_$(1)),$(cmd_$(@F)))\
- $(filter-out $(cmd_$(@F)),$(cmd_$(1)))),\
- @$(rule_$(1)))
-
-# If quiet is set, only print short version of command
-
-cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
-
-# filechk is used to check if the content of a generated file is updated.
-# Sample usage:
-# define filechk_sample
-# echo $KERNELRELEASE
-# endef
-# version.h : Makefile
-# $(call filechk,sample)
-# The rule defined shall write to stdout the content of the new file.
-# The existing file will be compared with the new one.
-# - If no file exist it is created
-# - If the content differ the new file is used
-# - If they are equal no change, and no timestamp update
-
-define filechk
- @set -e; \
- echo ' CHK $@'; \
- mkdir -p $(dir $@); \
- $(filechk_$(1)) < $< > $@.tmp; \
- if [ -r $@ ] && cmp -s $@ $@.tmp; then \
- rm -f $@.tmp; \
- else \
- echo ' UPD $@'; \
- mv -f $@.tmp $@; \