This article from: http://zhangzhenyuan163.blog.163.com/blog/static/858193892011427104447462/
First, all the files generated after the success
1. Why do you need to manage tools make and makefile?
Compile implements the so-called automatic compilation and connection.
2. Make Tool
Generally, a slightly larger software project will have many source files. It is very difficult to manage the compilation and connection of a large number of source files, especially when the same management work needs to be repeated for many times due to errors in the program, it is even more annoying for the poet.
To address this issue, modern development tools are equipped with the project management tool make.exe. This tool runs a file called makefile. This file is compiled by the software developer and describes the compilation, connection steps, and corresponding management steps of the project source files. In this example, when a user crashes, the makestart project management tool make.exe can be used, and the tool will find and execute the makefile compiled by the user.
It must be pointed out that development as an embedded system cannot fully rely on IDE, because embedded applications often have some personalized requirements, and the code generated by IDE often cannot meet these requirements. Therefore, embedded design requires that program designers must be considerate and be aware of each step of design. Therefore, for embedded designers, if they do not master make and makefile to a certain extent, they cannot develop qualified embedded software.
3makefile Structure
The so-called MAKEFILE file is a file written using the DOS command, but these commands express the management of project files.
A makefile consists of several program segments, each of which has a set of commands used to complete project management. To label a program segment, there must be a label before it. When different segments need to be associated, one or more segments can be associated with the segments. Each associated label must contain a space before it.
Program segment number: Association program segment number 1 Association program segment number 2...
Command set
Note: All commands in the command set must start with the tab key.
Makefile code:
######################################## ##
# Create an executable file (exe)
Test. EXE:
Tlink @ testlink
######################################## ##
# Create each target file (OBJ)
Pa. OBJ:
BCC-C-ml-ic: \ BC \ include-LC: \ BC \ Lib Pa. c
PB. OBJ:
BCC-C-ml-ic: \ BC \ include-LC: \ BC \ Lib Pb. c
Test. OBJ:
BCC-C-ml-ic: \ BC \ include-LC: \ BC \ Lib test. c
Save the above program as the file name makefile. Note that the extension is not required.
In addition, you must first create the testlink file p21.
Input make pa. OBJ in sequence
Make PB. OBJ
Make test. OBJ
Make
Conclusion
The first segment of makefileis the default execution segment of make.exe, while the execution of other segments must be specified by the label in the make command.
To improve readability, this makefile uses the file name as the label, and the file name is the command of this program segment, that is, the target to be completed. The first program segment completes the connection of each target file to form the final executable file test. the other three programs compile the three source files respectively, thus forming the three target files Pa. OBJ Pb. OBJ test. OBJ