Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of Linux make command

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

When working in the linux environment, it is inevitable to compile the source code of Cmax Cure + frequently, so the make command is often used by us. Of course, the make tool does not necessarily target C code, it can also maintain a variety of other code, for details, see: man make

Before listing the detailed parameters, let me introduce two points of knowledge that I have encountered and summed up.

The order in which 1.makefile looks (for GNUmake): GNUmakefile, makefile, and Makefile; Makefile is recommended (because it is usually closer to important files such as README).

2. The number of job for concurrent execution of make, with the parameter-j but not followed by the number of job, make will not limit the number of job for running make at the same time (as much as possible), especially for the make,-j parameter under multi-core and multi-threaded CPU architecture, which can significantly improve the compilation and build speed. Here is an experiment I did: make the latest code for qemu-kvm.git.

2.1 CPU is 4 cores and 8 threads: make takes 82s, make-j 4 takes 31s, make-j takes 27s.

2.2 CPU is single core and single thread: make takes 353%, make-j 2 takes 370%, make-j takes 396 s. (it is best not to use the-j parameter when using make under single-core and single-threaded CPU. Of course, this is only a test and may not reflect all kinds of real scenarios.)

All the parameter definitions for GNU make version 3.80 are listed below. Other versions of the make are more or less the same as those of manufacturers, but please refer to their respective product documentation for the specific parameters of the make of other manufacturers.

"- b"

"- m"

The purpose of these two parameters is to ignore compatibility with other versions of make.

"- B"

"- always-make"

Think that all targets need to be updated (recompiled).

"- C

"

"- directory="

Specifies the directory where the makefile is read. If there are multiple "- C" parameters, the make interpretation is that the following path takes the front as the relative path and the last directory as the specified directory. For example, "make-C ~ hchen/test-C prog" is equivalent to "make-C ~ hchen/test/prog".

"- debug [=]"

Output debugging information for make. It has several different levels to choose from, and if there are no parameters, it outputs the simplest debugging information. Here are the values for:

A-- that is, all, outputs all debugging information. (there will be a lot.)

B-- that is, basic, outputs only simple debugging information. That is, the output does not require recompilation of the target.

V-- that is, verbose, above the level of option b. The output information includes which makefile is parsed, dependent files that do not need to be recompiled (or dependent targets), and so on.

I-- that is, implicit, outputs all the implicit rules.

J-- that is, jobs, outputs the details of the command in the execution rule, such as the PID of the command, the return code, and so on.

M-- that is, makefile, outputs make to read makefile, update makefile, and execute makefile.

"- d"

It is 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="

"- makefile="

Specify the makefile that needs to be executed.

"- h"

"- help"

Displays help information.

"- I"

"- ignore-errors"

Ignore all errors during execution.

"- I

"

"- include-dir="

Specify a search target that contains makefile. You can use multiple "- I" parameters to specify multiple directories.

"- j []"

"--jobs [=]"

Refers to the number of commands running at the same time. If you don't have this jobsnum parameter after-j, make runs as many commands as it can. 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"

If something goes wrong, it will not stop running. If the generation of a target fails, then the goal that depends on it will not be executed.

"- l"

"--load-average [=

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 230

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report