Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Makefile文件函数演示错误_Linux_Makefile - Fatal编程技术网

Linux Makefile文件函数演示错误

Linux Makefile文件函数演示错误,linux,makefile,Linux,Makefile,我试图用一个小makefile为我的演示获得makefile中的file函数的结果,如下所示: CMD = cat OBJECTS = Makefile Makefile-filter-func program : $(OBJECTS) $(file >$@.in) $(foreach O,$^,$(file >>$@.in,$O)) @echo The file has been created. all : $(CMD)

我试图用一个小makefile为我的演示获得makefile中的file函数的结果,如下所示:

CMD = cat

OBJECTS = Makefile Makefile-filter-func

program : $(OBJECTS)
        $(file >$@.in) $(foreach O,$^,$(file >>$@.in,$O))
        @echo The file has been created.
all : 
        $(CMD) $(CMDFLAGS) @$@.in
        @echo The file contents are printed.
        @rm $@.in
        @echo The file removed.
我想使用ls命令查看文件名,但此makefile有以下错误:

Makefile-file-func:7: *** recipe commences before first target.  Stop.

我哪里出错了。

可以在
make
(3.82版)的源代码中找到指向答案的指针,该文件:

有了这些信息,可以通过在正确的位置插入空格来重现您的问题。在下面的代码中,
~
表示空格,
表示
选项卡

program : $(OBJECTS)
~~~~~~~~$(file >$@.in) $(foreach O,$^,$(file >>$@.in,$O))
 <TAB>  @echo The file has been created.
程序:$(对象)
~~~~~~~~$(文件>$@.in)$(foreach O,$^,$(文件>>$@.in,$O))
@回显已创建的文件。
由于空格和制表符在您的问题中丢失,因此很难看出这是否也是您的情况


请注意,食谱通常应该以
选项卡开始

非常感谢@ReinierTorenbeek的回复。它解决了我的问题,并帮助我从您提供的链接的源代码中理解了配方。很高兴它有帮助,选项卡/空格总是让
make
恼火。
program : $(OBJECTS)
~~~~~~~~$(file >$@.in) $(foreach O,$^,$(file >>$@.in,$O))
 <TAB>  @echo The file has been created.