makefile - error in using tab in makefile how to fix it
问题描述
when I try to do make for the makefile it shows me (makefile error missing separator. stop) my make file is
PROGS = $(patsubst %.c,%,$(SRCS))
all: $(PROGS)
%: %.c
arm-linux-gnueabihf-gcc --static $< -o $@
clean:
rm -f $(PROGS)
I try to use the following command but I could not solve my problem
cat -e -t -v Makefile
SRCS^I=^I$(wildcard^I*.c)^I$
PROGS^I=^I$(patsubst^I%.c,%,$(SRCS))$
all:^I$(PROGS)^I$
%:^I%.c^I$
arm-linux-gnueabihf-gcc^I--static^I$<^I-o^I$@^I$
clean:^I$
rm^I-f^I$(PROGS)^I$ ```
解决方案
疯狂的。您在所有不需要的地方都有 TAB 字符,并且在您必须拥有它们的任何(两个)地方都没有TAB 字符。我不知道你是怎么做到的。
在你的makefile上面你必须有TAB字符的地方是配方行。换句话说,您的 makefile 应如下所示cat -e -t -v Makefile
:
SRCS = $(wildcard *.c)$
PROGS = $(patsubst %.c,%,$(SRCS))$
all: $(PROGS)$
%: %.c$
^Iarm-linux-gnueabihf-gcc --static $< -o $@$
clean:$
^Irm -f $(PROGS)$
至于配置您的文本编辑器,即使在 Ubuntu 上,也有大量的文本编辑器,我们不知道您使用的是哪一个。
我建议你使用程序员的编辑器,它有一个特殊的模式,可以理解 makefile 的语法。