The process of executing the Linux top-level makefile !!! (1)

Source: Internet
Author: User

1. Make menuconfig

Version = 2
Patchlevel = 6
Sublevel = 26
Extraversion =
Name = rotary wombat

# * Documentation *
# To see a list of typical targets execute "make help"
# More info can be located in./readme
# Comments in this file are targeted only to the developer, do not
# Verify CT to learn how to build the kernel reading this file.

# Do not:
# O use make's built-in rules and variables
# (This increases performance and avoids hard-to-Debug behaviour );
# O print "entering directory ...";
Makeflags + =-rr -- no-print-directory
#-R prohibit the use of build-in rules
# -- No-print-Directory: do not print "entering directory .." on the screen .."
# Remember the variable shell, makeflags in the entire make Execution Process
# Always passed to all sub-make

# We are using a recursive build, so we need to do a little thinking
# To get the ordering right.
#
# Most importantly: sub-Makefiles shocould only ever modify files in
# Their own directory. If in some directory we have a dependency on
# A file in another dir (which doesn't happen often, but it's often
# Unavoidable when linking the built-in.o targets which finy
# Turn into vmlinux), we will call a sub make in that other dir, and
# After that we are sure that everything which is in that other dir
# Is now up to date.
#
# The only cases where we need to modify files which have global
# Effects are thus separated out and done before the recursive
# Descending is started. They are now explicitly listed as
# Prepare rule.

# To put more focus on warnings, be less verbose as default
# Use 'make v = 1' to see the full commands

Ifdef V # V = 1
Ifeq ("$ (origin v)", "command line ")
Kbuild_verbose = $ (v) # Use the value of V as the value of kbuild_verbose
Endif
Endif

Ifndef kbuild_verbose # That is, we do not echo by default.
# Echo: displays the command to be executed before the command is executed
Kbuild_verbose = 0
Endif
# Function origin does not operate on the value of a variable. It only tells you where the variable comes from.
# Syntax: $ (origin <variable>;) # The return values of the origin function are:
# "Undefined" has never been defined. "default" is a default definition.
# "Environment" is an environment variable,
# The variable "file" is defined in makefile.
# The variable "command line" is defined by the command line.
# "Override" is redefined by the override indicator
# "Automatic" is an automation variable in command running.

# Call a source code checker (by default, "sparse") as part of
# C compilation. Call a static analysis tool as the c Compiler
# Section
# Use 'make C = 1' to enable checking of only re-compiled files.
# Use 'make C = 2' to enable checking of * all * source files, regardless
# Of whether they are re-compiled or not.
#
# See the file "Documentation/sparse.txt" for more details, including
# Where to get the "sparse" utility.
Ifdef C
Ifeq ("$ (origin C)", "command line ")
KBUILD_CHECKSRC = $ (C)
Endif
Endif
Ifndef KBUILD_CHECKSRC
KBUILD_CHECKSRC = 0
Endif

# Use M to specify the directory of the external Module
# Use make M = dir to specify directory of external module to build
# Old syntax make... subdirs = $ PWD is still supported
# Setting the environment variable kbuild_extmod take precedence
# Is an external module defined here ??
# When M variables or subdirs are defined, an external module is compiled.

Ifdef subdirs
Kbuild_extmod? = $ (Subdirs )#? = The Conditional Value assignment operator only returns
# Valid if no definition is available
Endif
Ifdef m
Ifeq ("$ (origin m)", "command line ")
Kbuild_extmod: = $ (m)
Endif
Endif

# Kbuild supports saving output files in a separate directory.
# To locate output files in a separate directory two syntaxes are supported.
# In both cases the working directory must be the root of the kernel SRC.
#1) O =
# Use "make o = DIR/to/store/output/files /"
#
#2) Set kbuild_output
# Set the environment variable kbuild_output to point to the directory
# Where the output files shall be placed.
# Export kbuild_output = DIR/to/store/output/files/
# Make
#
# The O = assignment takes precedence over the kbuild_output Environment
# Variable.

# Kbuild_src is set on invocation of make in OBJ directory
# Kbuild_src is not intended to be used by the regular user (for now)
################### Start of make ################## #
######################################## ############
Ifeq ($ (kbuild_src),) # If kbuild_src is not defined, enter the following Layer for the first time
# Generally, you need to enter the top-level makefile twice.
# If it is defined, skip to the next step.
# OK, make called in directory where kernel SRC resides
# Do we want to locate output files in a separate directory?
Ifdef o # Put the output file in different folders
Ifeq ("$ (Origin O)", "command line ")
Kbuild_output: = $ (o) # used to specify the output directory of our output file
Endif
Endif

# That's our default target when none is given on the command line
Phony: = _ all
_ All:

# Cancel implicit rules on top makefile
$ (Curdir)/makefile:; # remake operation to check whether the current directory makefile is up-to-date
# The value of curdir is the current kernel source code directory current dir
# For the variable used by GNU make, curdir sets the path name of the current working directory

Ifneq ($ (kbuild_output),) # If the output directory is not empty, the output directory is set.
# Invoke a second make in the output directory, passing relevant variables
# Check that the output directory actually exists
Saved-output: = $ (kbuild_output)
Kbuild_output: = $ (shell CD $ (kbuild_output) &/bin/pwd) # test whether the directory is
# Yes. If yes, it is assigned to k build_output.
$ (If $ (kbuild_output),/# If <then-part> is null, the output directory does not exist.
$ (Error output directory "$ (saved-output)" does not exist) # The error function is used.
# The syntax of the IF function is: If <condition>, <then-part>
# Or if <condition>, <then part>, <else-part>

# The environment variable of make is called makecmdgoals, which stores the specified
# List of the ultimate goals. If you do not specify a target on the command line,
# This variable is null.
Phony + = $ (makecmdgoals) Sub-make
# Put any target given in the command line into the variable makecmdgoals
# Here, filter-out is returned. $ (makecmdgoals) except makefile _ all sub-make
# Other files;
$ (Filter-out _ all sub-make $ (curdir)/makefile, $ (makecmdgoals) _ all: Sub-make
$ (Q) @: # It only means canceling the echo.

# $ (KBUILD_VERBOSE: 1 =) Replace the variable. If it is 1, replace it with null.
# If KBUILD_VERBOSE = 1 or KBUILD_VERBOSE is NULL
# Then
# $ (MAKE)-C $ (KBUILD_OUTPUT) // echo
# Else
# @ $ (MAKE)-C $ (KBUILD_OUTPUT) // no echo
# Endif
Sub-make: FORCE
$ (If $ (KBUILD_VERBOSE: 1 =), @) $ (MAKE)-C $ (KBUILD_OUTPUT)/# KBUILD_OUTPUT = dir
KBUILD_SRC = $ (CURDIR )/
KBUILD_EXTMOD = "$ (KBUILD_EXTMOD)"-f $ (CURDIR)/Makefile /#
$ (Filter-out _ all sub-make, $ (MAKECMDGOALS) # indicates the target to be generated.
# Make-C dir KBUILD_SRC = 'pwd' KBUILD_EXTMOD = ""-f 'pwd'/Makefile [Targets]
# Here, Makefile is executed again, but in this case, our KBUILD
# After executing make again, skip-makefile: = 1 and
# Leave processing to above invocation of make
Skip-makefile: = 1
Endif # ifneq ($ (KBUILD_OUTPUT),) Here is ifneq
Endif # ifeq ($ (KBUILD_SRC),) # The End Of ifeq
######################################## ############
######################################## ############

Ifeq ($ (skip-makefile),) # If it is null, perform classification !!!!!!
# Endif # skip-makefile end the maximum ifeq structure at row 1813
# If building an external module we do not care about the all: rule
# But instead _ all depend on modules
PHONY + = all # declare a pseudo-target all
Ifeq ($ (KBUILD_EXTMOD),) # If the external module is defined as null, _ all depends on all
_ All: all
Else
_ All: modules # Otherwise, it depends on modules.
Endif

Srctree: = $ (if $ (KBUILD_SRC), $ (KBUILD_SRC), $ (CURDIR) # Check whether KBUILD_SRC is empty, # Set the source code directory
TOPDIR: = $ (srctree) # top-level directory
# FIXME-TOPDIR is obsolete, use srctree/objtree
Objtree: = $ (CURDIR) # CURDIR is the default environment variable of make.

Src: = $ (srctree) # Set the directory of the source file to the current directory.
Obj: =$ (objtree) # set the current directory for the output directory of the target file

VPATH: =$ (srctree) $ (if $ (KBUILD_EXTMOD),: $ (KBUILD_EXTMOD ))
# The search directory when the source file cannot be found in the current directory
Export srctree objtree VPATH TOPDIR
# Export is used to output the specified variable to the sub-make,

# SUBARCH tells the usermode build what the underlying arch is. That is set
# First, and if a usermode build is happening, the "ARCH = um" on the command
# Line overrides the setting of ARCH below. If a native build is happening,
# Then ARCH is assigned, getting whatever value it gets normally, and
# SUBARCH is subsequently ignored.
# Here is the specific model for obtaining the cpu. The variable SUBARCH exists.
# Sed-e s indicates replacement. Here, I .86 indicates replacement with i386.
# Replace sun4u with sparc64
# Use sed-e's/I .86/i386 'to enclose it''
SUBARCH: = $ (shell uname-m | sed-e s/I .86/i386/-e s/sun4u/sparc64 //
-E s/arm. */arm/-e s/sa110/arm //
-E s/s390x/s390/-e s/parisc64/parisc //
-E s/ppc. */powerpc/-e s/mips. */mips //
-E s/sh. */sh /)

# Cross compiling and selecting different set of gcc/bin-utils
#---------------------------------------------------------------------------
#
# When Ming cross compilation for other ubuntures ARCH shall be set
# To the target architecture. (See arch/* for the possibilities ).
# ARCH can be set during invocation of make:
# Make ARCH = ia64
# Another way is to have ARCH set in the environment.
# The default ARCH is the host where make is executed.

# CROSS_COMPILE specify the prefix used for all executables used
# During compilation. Only gcc and related bin-utils executables
# Are prefixed with $ (CROSS_COMPILE ).
# CROSS_COMPILE can be set on the command line
# Make CROSS_COMPILE = ia64-linux-
# Alternatively CROSS_COMPILE can be set in the environment.
# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some ubuntures assign CROSS_COMPILE in their arch/*/Makefile
Export KBUILD_BUILDHOST :=$ (SUBARCH) # Here we export the cpu Structure of the host
# KBUILD_BUILDHOST variable and input the sub-make
ARCH? = $ (SUBARCH)
# There are two methods to set the variable ARCH,
#1. In the command line, for example, make ARCH = ia64;
#2. Set environment variables, which are default in Environment Variables
# The ARCH value is the cpu architecture for executing make.
#"? = "Indicates that the ARCH condition is assigned a value. If no value is assigned before the ARCH condition, the value is assigned here.
# Success; otherwise, no value is assigned again.
CROSS_COMPILE? = # Set the cross-compilation tool in the embedded system
# Modify the cross-compiler path.

# Architecture as present in compile. h
UTS_MACHINE: = $ (ARCH)
SRCARCH: = $ (ARCH)

# Additional ARCH settings for x86
Ifeq ($ (ARCH), i386)
SRCARCH: = x86
Endif

Ifeq ($ (ARCH), x86_64)
SRCARCH: = x86
Endif

KCONFIG_CONFIG? =. Config # The generated configuration file

# SHELL used by kbuild here the if [-x file] In shel tests whether the file can be executed.
CONFIG_SHELL: = $ (shell if [-x "$ BASH"]; then echo $ BASH ;/
Else if [-x/bin/bash]; then echo/bin/bash ;/
Else echo sh; fi)

HOSTCC = gcc
Hostcxx = g ++
Hostcflags =-wall-wstrict-prototypes-O2-fomit-frame-pointer
Hostcxxflags =-O2

# Decide whether to build built-in, modular, or both.
# Normally, just do built-in.
Kbuild_modules: =
Kbuild_builtin: = 1

# If we have only "make modules", don't compile built-in objects. Compile built-in objects
# When we're building modules with modversions, we need to consider
# The built-in objects during the descend as well, in order
# Make sure the checksums are up to date before we record them.

# If you execute "make modules", re-process kbuild_builtin: = 1 here
Ifeq ($ (makecmdgoals), modules)
Kbuild_builtin: = $ (if $ (config_modversions), 1)
Endif

# If we have "make <whatever> modules", compile modules
# In addition to whatever we do anyway.
# Just "make" or "make all" shall build modules as well

# If you execute "make all", "make _ all", "make modules", or "make ",
# Re-process KBUILD_MODULES here
Ifneq ($ (filter all _ all modules, $ (MAKECMDGOALS),) # filter the specified string
# This indicates the compilation module if it is not empty.
KBUILD_MODULES: = 1
Endif

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.