Https://www.jianshu.com/p/57c01e97c9b8
What about calculations?
In the front we have makefile as a language of the main characteristics of a general description, it sets the target pattern and functional pattern, and a large number of macro ideas, has been able to write quite complex makefile.
However, unfortunately, although it is already very complicated, we will find in the actual android.mk that there are a lot of things in the light of the makefile string substitution can not do, how is this good?
In fact, that's why we talked about the shell function at the very beginning of the first lecture, because it was solved by shell scripting.
Let's look at a practical example: Core.mk The version number of make is greater than or equal to the 3.81 version of the script:
# Check for broken versions of make.# (allow any version under Cygwin since we don ' t actually build the platform there.)Ifeq (,$(FindString cygwin,$ (Shell Uname-sm)))IFNEQ (1,$(Strip $ (Shell Expr$ (make_version) \>= 3.81))) $ (warning ********************************************************************************)$ ( Warning * You is using version $ (make_version) of make.) $ (warning * Android can only is built by versions 3.81 and higher.) $ (warning * see https://source.android.com/source/download.html)$ (warning ********************** )$ (error stopping)endifendif
Evaluates the value of an expression-expr statement
The expr statement can be used to calculate the value of the result of a variable.
- Addition: +
- Subtraction:-
- Multiplication: \*
- Division:/
- Find remainder:%
Pay special attention to multiplication by adding a \ before *
Cancel the definition of a variable-unset statement
In the process of actually writing makefile, it is sometimes necessary to modify the environment variables. unset statements are available in the shell
Not much to say, directly on the example:
$(shell unset _JAVA_OPTIONS && java -version 2>&1)javac_version_str := $(shell unset _JAVA_OPTIONS && javac -version 2>&1)
What about the shell?
The shell is finally able to do some simple calculations, but to a certain extent to the size of the demand, or not, how to do?
In the ANDROID.MK system, you can see Python,ruby have been introduced, need to use, do not hesitate. The completion of the work is main, the method is not important.
Agent Jtag.
Links: Https://www.jianshu.com/p/57c01e97c9b8
Source: Pinterest
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.
ANDROID.MK (5) How to calculate?