Makfile in Android

Source: Internet
Author: User

What is makefile? Maybe a lot of WINODWS programmers don't know this stuff, because those Windows Ides do the work for you, but I think it's a good Android bottom-up programmer.
Makefile still have to understand.

Especially under the UNIX software compiler, you can not write your own makefile, will not write makefile, from a side to explain whether a person has the ability to complete large project.


As a result, makefile is related to the entire project's compilation rules. A source file in project is not counted, and it is placed in several folders by type, function, and module.
Makefile defines a set of rules to specify which files need to be compiled first, which files need to be compiled, which files need to be compiled again, and even more complex functional operations.
Because makefile is like a shell script. It is also possible to run the operating system commands. The advantage of makefile is that it is "self-initiated compilation". Once written,
Only a make command is required, and the whole project compiles itself, greatly improving the efficiency of software development.


Makefile Basic Tutorials. Documentation: http://blog.csdn.net/ruglcc/article/details/7814546
Because of the various compilation needs, you need to do the most important thing is to understand makefile. The most important is the assignment operation in makefile.
In makefile we often see =:?

= + = These assignment operators. So what's the difference between them? Let's do a simple experiment.

Create a new makefile. The contents are:
Ifdef Define_vre
VRE = "Hello world!"
Else
endif
Ifeq ($ (OPT), define)
VRE? = "Hello world! First! "
endif

Ifeq ($ (OPT), add)
VRE + = "kelly!"
endif
Ifeq ($ (OPT), recover)
VRE: = "Hello world! again! "
endif
All
@echo $ (VRE)
Typing the make command below:
Make define_vre=true opt=define output: Hello world!
Make define_vre=true opt=add output: Hello world! kelly!
Make define_vre=true opt=recover output: Hello world! again!
Make define_vre= opt=define output: Hello world! first!
Make define_vre= opt=add output: kelly!
Make define_vre= opt=recover output: Hello world! again!

From the results above, we can clearly see the difference between them.
= is the most important assignment
: = is the value before overwriting
= is the value that is given after the equal sign is assumed to be not assigned
+ = is the value added after the equals sign

have been tangled in the makefile "=" and ": =" The difference between what is the difference, because the variable is assigned, two symbols are in use. Online search, someone gave the answer, but I dull. I don't know what that means. A few seek without fruit, also put down. Read a blog today. Inadvertently found that the author has done a very good job of answering this question. Solve this problem can not help but sigh, sometimes give a sample is not clear? Why do you have to speak so academically? ^_^
1, "="
Make will expand the entire makefile and then determine the value of the variable. In other words, the value of the variable will be the last value specified in the entire makefile.

See Example:
x = foo
y = $ (x) bar
x = xyz
In the example above, the value of Y will be XYZ bar, not foo bar.
2, ": ="
": =" means that the value of the variable is determined by its position in the makefile. Rather than the end value of the entire makefile expansion.


x: = foo
Y: = $ (x) bar
x: = xyz
In the example above, the value of y will be foo bar. Instead of XYZ bar.

Documentation: http://www.cnblogs.com/wanqieddy/archive/2011/09/21/2184257.html

TIPS:

In addition, in the C language, the three-mesh operation:
Suppose that in a conditional statement, a conditional expression is often used when executing only a single assignment statement.

It not only makes the program concise, but also improves the efficiency of execution.


The conditional operator is the? And:, it is a three-mesh operator. That is, there are three of the number of participating operations.

The general form of conditional expressions consisting of conditional operators is:
Expression 1?

Expression 2: Expression 3
Its evaluation rule is: if the value of expression 1 is true, the value of expression 2 is used as the value of the conditional expression, otherwise the value of expression 2 as the value of the entire conditional expression.

Conditional expression Pass is often used in assignment statements.
such as conditional statements:
if (a>b) max=a;
else max=b;
Available conditional expressions are written as max= (a>b)? a:b; The semantics for running the statement are: If A>b is true, assign a to max, otherwise assign B to max.
When you use conditional expressions, you should also be aware of the following points:
1. The operator precedence of the conditional operator is lower than the relational operator and the arithmetic operator, but above the assignment.

So max= (a>b)?

A:b can remove parentheses and write as max=a>b?

A:b
2. Conditional operators?

And: is a pair of operators and cannot be used separately.


3. The binding direction of the conditional operator is from right to left.

Makfile in Android

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.