我对 Makefile 一窍不通,有人可以帮我调试一下吗?我正在使用 Code::Blocks 编译一个 C 项目,这是 makefile 的内容:
CC := gcc
CflaGS := -Isrc -g
BINDIR := build
SRC := src
_FILES := main.c crc.c mio0.c
FILES := $(patsubst %,$(SRC)/%,$(_FILES))
OUT := mio0-extract
.PHONY: all
all:
if [ ! -d "$(BINDIR)" ]; then mkdir $(BINDIR); fi
ifeq ($(OS),Windows_NT)
$(CC) -o $(BINDIR)/$(OUT).exe $(FILES) $(CflaGS)
else
$(CC) -o $(BINDIR)/$(OUT) $(FILES) $(CflaGS)
endif
.PHONY: clean
clean:
rm -rf $(BINDIR)
它在第 13 行失败(在“all:”之后)。我收到错误“目标 'all' 的配方失败”。
These are my build options (the other tabs are blank).
我创建了一个空项目并导入了 C 和 H 文件,然后进入了项目属性并勾选了“这是一个自定义 Makefile”。如何修复错误?
编辑:有人说我需要发布构建日志,所以在这里:
-------------- Build: Release in mio0-extract (compiler: GNU GCC Compiler)---------------
Checking if target is up-to-date: mingw32-make.exe -q -f Makefile
Running command: mingw32-make.exe -f Makefile
if [ ! -d "build" ]; then mkdir build; fi
! was unexpected at this time.
mingw32-make.exe: *** [all] Error 255
Makefile:13: recipe for target 'all' failed
Process terminated with status 2 (0 minute(s),0 second(s))
1 error(s),0 warning(s) (0 minute(s),0 second(s))
我尝试删除“!”但后来我得到“-d 此时出乎意料”。等等。同样,我不知道如何处理 Makefile,所以我不知道如何解决这个问题。