, because the other file's target source file already exists, so the compiler does not need to compile all the code to generate a new executable file, and only need to compile the changed source files, and then connect all the target files on it, which is very important in the large project development, This can reduce the compilation time from several hours to a few minutes. That's what make can do.Makefile Document Writing SpecificationThe Makefile
Makefile Learning (3) [version 2] And makefile learning Version 2Common embedded functions of make
1. function call
$ (Function arguments) # $ the referenced result is the result generated by the function.
2. Common functions in Makefile
1) $ (wildcard PATTERN) # match the files in the current directory
For example, src = $ (wildcard *. c) # Matches all. c files
Tags: blog Io ar SP file on 2014 Take a set of simple. c files as an example. The learning process from compiling commands to makefile. The GCC parameters are not described too much. The following files and content: Add. c int add(int a int b){ return a+b;} Sub. c int sub(int a ,int b){ return a-b;}Cal. h #ifndef __CAL_H_#define __CAL_H_int add(int,int);int sub(int,int);#endif Main. c #include There are three source files
By default, make will look for the makefile file to read and execute in the file name order in the working directory (the directory where the make is executed), looking for the file name in the following order: "Gnumakefile", "Makefile", "makefile".Usually you should use "makefile" or "
Lesson 3 make Makefile (I) and make makefilePreface:
The previous course explains the gcc compilation process to its practice. You can see that some of these steps can simplify compilation, however, due to the large number of parameters and the large number of files in the project, errors may occur, or even a lot of time is wasted on compilation. Therefore, this tool is also available in the linux system: makefile.Principle:
In fact, the essence of
Objective:You don't need to edit a slightly obscure makefile file when you build a C + + program using VS on Windows, and for starters, they don't even realize it's there. VS is to automatically generate makefile files and build the project. There is no denying that Visual Studio is an all-purpose IDE, it helps developers do a lot of work, but also reduce the threshold of the C + +, the significance is very
Use Makefile to optimize the entire process of Makefile
Take a set of simple. c files as an example. The learning process from compiling commands to Makefile.
The gcc parameters are not described too much. The following files and content:
Add. c
int add(int a int b){ return a+b;}
Sub. c
int sub(int a ,int b){ return a-b;}
Cal. h
#ifndef __CAL_H_#defi
Linux study note 6. makefile file manager and makefile file creation-Linux general technology-Linux programming and kernel information. For details, see the following. Splitting source program files is conducive to developing large programs and improving the efficiency of programming. But the more files are separated, the more compilation and Maintenance
Difficult. To prevent changes to one or more files i
Makefile condition judgment ---------- [Badboy], makefile condition badboy
Conditional judgment allows make to select different execution branches based on different running conditions. A conditional expression can be used to compare the value of a variable or a constant.
I. Example
In the following example, determine whether the $ (CC) variable is "gcc". If yes, use the GNU function to compile the target.
Assign values to variables in Makefile and assign values to makefile
Variable assignment in Makefile
BEIJING-Haidian District
First, the Makefile syntax is as follows:
Targets: prerequisites
Command
.........
Or:
Targets: prerequisites; command
Command
.........
Targets is a file name separated by spaces. Wildcards c
Finally, C ++ code porting was introduced to bootloader. The only achievement was familiarity with makefile. Some factory companies could not afford to be hurt. Every time they had to do something to meet the needs of factory-side testing, in order to be able to meet the requirements of the factory for testing in Boot, after discussion with the chip company, only C ++ can be obtained to boot, it is really a second decision that boot will eventually ac
When the make command executes, a makefile file is required to tell the make command how to compile and link the program.First, we use an example to illustrate Makefile's writing rules. In order to give everyone a perceptual knowledge. This example comes from the GNU Make manual, in which we have 8 C files, and 3 header files, and we're going to write a makefile to show how the Make command compiles and lin
Makefile topic: Automatic Generation of dependency (I), makefile topic1. Problem Introduction
1) Does the target file (. o) only depend on the source file (. c )?2) How does the compiler compile source files and header files?2. defects caused by compilation behaviors Preprocessor transfers the code in the header file
Insert directlyTo the source file compiler, you can only use
The source file after preproce
.
| -- Makefile
| -- Test1
| -- Makefile
| -- Bin
| '-- Test
| -- Hello. o
| -- Include
| '-- Hello. h
| '-- SRC
| '-- Hello. c
'-- Test2
| -- Makefile
| -- Bin
| '-- Test
| -- Hello. o
| -- Include
| '-- Hello. h
| -- OBJ
'-- SRC
'-- Hello. c
The makefile in the root directory calls the
same write, ESC then type: WQ exit:Enter the following main function code:Then save the exit, as follows to compile the run process:Iv. using Makefile to solve the problem of multi-file compiling and runningAs described in the red box in the previous section, if a program involves a lot of files, each has to write out, it is troublesome, so makefile appeared, please see the tutorial:After entering makefile
The boss wrote a very large Makefile, which contains many syntaxes: The boss makefile
A very large Makefile contains many syntaxes:
TARGET = api-loginINSTALL_PATH = /huishoubao/cgiinclude ../../implements/log/Makefile.loginclude ../../implements/tools/Makefile.toolsinclude ../../implements/db/Makefile.dbinclude ../../implements/configure/Makefile.configureinclud
Here are five steps to compile the Linux makefile:compile total of five parts1. Setting up the compilation environment set compile environment2. Get the source file to compile and convert the source file to the destination file (source and destination files) source to obj3. Compile the file as the target file objing4. Link the target file to an executable file or (packaged as) a dynamic library, or a static library linking5. Other aspects such as cleanThe following is a simple
Some of the basic rules of makefile are not mentioned. Some makefiles use a mix of Linux commands and functions, sometimes confusing.
The following is an example:
Example 1 (using Linux commands ):
# SDK makfile 1.0
Dir: = ../..Object: = $ (DIR)/lib/libui. This is the path and file name of the output target file-Include $ (DIR)/main/comdef Include files not included in source code # include xxxxxx
ALL: liball Ara $ (object) Rm MakeProgramUpd
A general Makefile framework and a general Makefile framework
First, make a simple record, and then gradually complete the details.
First, take the overall image as follows:
Among them, the most important file is: program_template.mk.
The following is the most important content of program_template.mk:
$(1)_COBJS = $$(patsubst $$($(1)_SDIR)%.c,$$($(1)_BIN)/%.o,$$($(1)_CSRCS))$(1)_OBJS = $$($(1)_COBJS)$(1)
Makefile variable assignment, makefile assignment
When defining the value of a variable, we can use other variables to construct the value of the variable. There are two methods in Makefile to define the value of the variable.First, let's look at the first method, that is, simply using the "=" sign, on the left side of "=" is the variable, and on the right side i
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.