:= = += ?= in makefile
时间: 2023-09-06 09:12:50 浏览: 59
这些符号在 Makefile 中通常表示以下含义:
- `:=`:表示变量的值在定义时就立即展开,而不是在使用时才展开。
- `+=`:表示将后面的值追加到变量的原有值之后。
- `?=`:表示如果变量没有被定义过,则将后面的值赋给该变量。
举个例子,如果我们有如下代码:
```
VAR := value1
VAR += value2
VAR ?= value3
```
那么最终 `VAR` 的值将会是 `value1 value2`,因为 `:=` 立即展开了 `value1`,`+=` 将 `value2` 追加到 `value1` 后面,而 `?=` 并没有生效,因为 `VAR` 已经被定义过了。
相关问题
openwrt makefile 中 PKG_FIXUP:=autoreconf 什么意思
在 OpenWrt 中,`PKG_FIXUP` 是一个 Makefile 变量,用于在构建软件包时进行一些修复操作。`autoreconf` 是其中的一个选项,它会自动运行 `autoconf` 和 `automake` 工具,以生成或更新 `configure` 脚本和 Makefile.in 文件,以便软件包能够正确地进行编译和安装。因此,`PKG_FIXUP:=autoreconf` 表示在构建软件包时,应该自动运行 `autoreconf` 工具,以确保软件包的正确性和可用性。
cur_makefile := $(lastword $(MAKEFILE_LIST)) give me some examples to explain this assignment
Sure, here are a few examples to help explain this assignment:
Example 1:
Suppose you have a Makefile called "myproject/Makefile" in the following directory structure:
```
myproject/
├── src/
│ ├── file1.cpp
│ ├── file2.cpp
│ └── file3.cpp
├── include/
│ ├── header1.h
│ ├── header2.h
│ └── header3.h
└── Makefile
```
If you add the following line to your Makefile:
```
cur_makefile := $(lastword $(MAKEFILE_LIST))
```
Then the variable "cur_makefile" will be set to "myproject/Makefile".
Example 2:
Suppose you have a project with multiple Makefiles in different subdirectories, like this:
```
project/
├── Makefile
├── dir1/
│ ├── file1.cpp
│ ├── file2.cpp
│ └── Makefile
├── dir2/
│ ├── file3.cpp
│ ├── file4.cpp
│ └── Makefile
└── dir3/
├── file5.cpp
├── file6.cpp
└── Makefile
```
If you add the following line to the Makefile in each subdirectory:
```
cur_makefile := $(lastword $(MAKEFILE_LIST))
```
Then each subdirectory's Makefile will have its own "cur_makefile" variable set to its own path relative to the root directory. For example, the Makefile in "project/dir1" will have "cur_makefile" set to "project/dir1/Makefile", and so on.
I hope these examples help clarify how the "cur_makefile" variable can be used in a Makefile. Let me know if you have any further questions!