我可以将变量作为命令行参数传递给GNU Makefile吗?换句话说,我想传递一些最终会成为Makefile变量的参数.
在makefile中,我可以从另一个规则调用规则吗?
相近:
rule1:
echo "bye"
rule2:
date
rule3:
@echo "hello"
rule1
Run Code Online (Sandbox Code Playgroud) 我想要一个像这样的makefile:
cudaLib :
# Create shared library with nvcc
ocelotLib :
# Create shared library for gpuocelot
build-cuda : cudaLib
make build
build-ocelot : ocelotLib
make build
build :
# build and link with the shared library
Run Code Online (Sandbox Code Playgroud)
即*Lib
任务创建一个直接在设备上运行cuda的库,或者分别在gpuocelot上运行cuda.
对于这两个构建任务,我需要运行相同的构建步骤,只创建库不同.
是否有替代直接运行make?
make build
Run Code Online (Sandbox Code Playgroud)
有什么后必备条件?
我创建了一个(非常简单的)makefile:
DEBUG = -DDEBUG
main: main.c add.c
gcc $(DEBUG) main.c add.c -o main -lm
Run Code Online (Sandbox Code Playgroud)
我想要(并且不知道该怎么做)是创建 makefile,以便如果用户打印make debug
,则代码将使用调试选项进行编译,但是仅打印时make
,调试将被排除在外。做这个的最好方式是什么?