Linux make command detailed

Source: Internet
Author: User
Tags builtin touch command

In the Linux environmentwork, it is often necessary to compile C + + source code frequently, so MakeOrders are often used by us. Of course the make tool does not necessarily target C code, it can also maintainotherVarious codes, see: Man make
   before enumerating its detailed parameters, let me introduce two points of knowledge that I have encountered and summed up.
   1.makefile search order (for GNU make): Gnumakefile, Makefile, makefile in turn, recommend the use of makefile this file (because it is usually closer to important files such as the Readme).
   2.-j parameter, the number of jobs concurrently executing make, with-j parameters but not following the job number. Make does not limit the number of jobs that run makes at the same time (as much as possible), especially for multi-core multi-threaded CPU architectures where the MAKE,-J parameter can have a noticeable build-up speed boost. Here's an experiment I did: Make the latest code for Qemu-kvm.git.
     2.1 CPU is 4 cores 8 threads: Make Time 82s, Make-j 4 Time consuming 31s, make-j time consuming 27s.
     2.2 CPU Single-core: Make Time 353, Make-j 2 Time consuming 370, make-j time consuming 396s. (Single-core one-way CPU with make is best not-j parameters, of course, this time is only a test , Does not necessarily reflect a variety of real-world scenarios)

The parameter definitions for all GNU make version 3.80 are listed below. other versions are similar to manufacturers ' make, but the specific parameters of other manufacturers ' made will refer to their respective product documentation.

"-B"
"-M"
The purpose of these two parameters is to ignore compatibility with other versions of make.

"-B"
"--always-make"
It is considered that all targets need to be updated (recompiled).

"-C <dir>"
"--directory=<dir>"
Specifies the directory to read makefile. If there are multiple "-c" arguments, make is interpreted as a trailing path with the previous as the relative path and the last directory as the specified directory. such as: "Make–c ~hchen/test–c prog" is equivalent to "Make–c ~hchen/test/prog".

"-DEBUG[=<OPTIONS>]"
Outputs debug information for make. It has several different levels to choose from, and if there are no parameters, the simplest debugging information is output. Here is the value of <options>:
a--, which is all, outputs all debugging information. (It's going to be very much)
b--, which is basic, only outputs simple debugging information. That is, the output does not require a target to recompile.
v--is verbose, above the level of the B option. The output information includes which makefile is parsed, does not need to be recompiled dependent files (or dependent targets), etc.
i--is also the implicit, the output of the implied rules.
j--, which is jobs, outputs details of the commands in the execution rules, such as the PID of the command, the return code, and so on.
m--is makefile, output make reads makefile, updates makefile, executes makefile information.

"-D"
Equivalent to "--debug=a".

"-E"
"--environment-overrides"
Indicates that the value of the environment variable overrides the value of the variable defined in makefile.

"-f=<file>"
"--file=<file>"
"--makefile=<file>"
Specifies the makefile to be executed.

"-H"
"--help"
Displays help information.

"-I."
"--ignore-errors"
All errors are ignored at execution time.

"-I <dir>"
"--include-dir=<dir>"
Specifies a search target that contains makefile. Multiple "-i" parameters can be used to specify multiple directories.

"-j [<jobsnum>]"
"--JOBS[=<JOBSNUM>]"
Refers to the number of simultaneous commands that are run. If you do not have this jobsnum parameter after-j, you can run as much as you like when you run the command. If there is more than one "-j" parameter, then only the last "-j" is valid. (Note that this parameter is useless in MS-DOS)

"-K"
"--keep-going"
The error does not stop running. If you fail to generate a target, then the target on which it is dependent will not be executed.

"-L <load>"
"--load-average[=<load]"
"-MAX-LOAD[=<LOAD>]"
Specifies the load of the make Run command.

"-N"
"--just-print"
"--dry-run"
"--recon"
Only the sequence of commands in the execution process is output, but not executed.

"-O <file>"
"--old-file=<file>"
"--assume-old=<file>"
Does not regenerate the specified <file>, even if the dependent file for this target is new to it.

"-P"
"--print-data-base"
Outputs all the data in the makefile, including all rules and variables. This parameter will let a simple makefile output a bunch of information. You can use the "MAKE-QP" command if you just want to output information and do not want to perform makefile. If you want to see the preset variables and rules before executing makefile, you can use "Make–p–f/dev/null". The output of this parameter will contain the file name and line number of your makefile file, so it would be useful to use this parameter to debug your makefile, especially if your environment variable is complicated.

"-Q"
"--question"
Do not run the command, nor output it. Simply check that the specified target needs to be updated. If it is 0, the description is to be updated, and if 2 it indicates an error occurred.

"-R"
"--no-builtin-rules"
Prohibit make to use any implied rules.

"-R"
"--no-builtin-variabes"
Prohibit make to use any implied rule that acts on a variable.

"-S"
"--silent"
"--quiet"
Output of the command is not output when the command is run.

"-S"
"--no-keep-going"
"--stop"
Cancels the function of the "-k" option. Because sometimes the make option is inherited from the environment variable "makeflags". So you can use this parameter on the command line to invalidate the "-k" option in the environment variable.

"-T"
"--touch"
The equivalent of a UNIX touch command, which only changes the target's modification date to the latest, which is to prevent the command that generated the target from running.

"-V"
"--version"
Output the version of Make program, copyright, and other information about make.

"-W"
"--print-directory"
Outputs the information before and after running makefile. This parameter is useful for tracking nested calls to make.

"--no-print-directory"
The "-w" option is prohibited.

"W <file>"
"--what-if=<file>"
"--new-file=<file>"
"--assume-file=<file>"
Suppose the target <file> needs to be updated, and if used with the "-n" option, then this parameter will output the run action when the target is updated. If there is no "-n" then it is like running the UNIX "touch" command, making the <file> modification time the current time.

"--warn-undefined-variables"
If make finds an undefined variable, it outputs a warning message

Linux make command detailed

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.