我希望编写一个 makefile 来自动编译我正在处理的项目,其中文件的数量可能会或可能不会改变。我还需要能够快速告诉 make 将文件编译为调试版本或发布版本(通过命令行定义区分)。经过一番研究,我发现了模式规则并制定了一个。这是我到目前为止的代码:
# Our folders
# ODIR - The .o file directory
# CDIR - The .cpp file directory
# HDIR - The .hpp file directory
ODIR = obj
CDIR = src
HDIR = inc
# Get our compiler and compiler commands out of the way
# CC - Our compiler
# CFNO - Our compiler flags for when we don't have an output file
# CF - Our compiler flags. This should be appended to any …Run Code Online (Sandbox Code Playgroud)