【问题标题】:make: Error in ifneq: word unexpected (expecting ")")make:ifneq 中的错误:单词意外(预期为“)”)
【发布时间】:2012-09-29 04:26:15
【问题描述】:

我想为 LaTeX 文档创建一个 makefile(在这个最小的 例子)。当没有文件“makeindexstyle.ist”时,应该创建它(通过 运行 make makeindexstyle.ist) 并用于格式化索引。规则为 %.pdf 反映了这一点。但是,它还没有工作,我收到错误

ifneq (, ) {
/bin/sh: 1: Syntax error: word unexpected (expecting ")")
make: *** [master.pdf] Error 2

怎么了?

Parts from Makefile:

MASTER = master
TEX = slave

TEXI = texi2dvi -p

all: $(MASTER:=.pdf)

%.pdf: %.tex $(TEX:=.tex)
    ifneq ($(wildcard makeindexstyle.ist), ) { # if makeindexstyle.ist exists, compile and build index
        $(TEXI) $<
        make makeindexstyle.ist
        makeindex -c -s makeindexstyle.ist $(MASTER:=.idx)
    }
    endif
    $(TEXI) $<

makeindexstyle.ist:
    @(echo "...") > makeindexstyle.ist

更新: 我试图尽可能简单地查看错误的来源。除其他外(如引用),我试过这个:

%.pdf: %.tex $(TEX:=.tex)
    exist := $(wildcard "absolute-path-to-makeindexstyle.ist")
    ifneq ($strip $(exist)),)
             echo "foo"
    endif
    $(TEXI) $<

但结果是

exists := 
make: exists: Command not found
make: *** [book.pdf] Error 127

【问题讨论】:

    标签: makefile


    【解决方案1】:

    同时,我可以在 shell 端解决它:

    IDX = "makeindexstyle.ist"
    %.pdf: %.tex $(TEX:=.tex)
        @if test -f $(IDX); then \
            echo "foo"; \
        fi
        $(TEXI) $<
    

    【讨论】:

      【解决方案2】:

      这听起来像是 How do I check if file exists in Makefile? 或 How to conditional set up a Makefile variable by testing if a file exists 的副本。

      试试

      ifneq ($(wildcard makeindexstyle.ist),)
      

      没有空格。或者,在参数周围抛出""?

      【讨论】:

      • 谢谢,Quuxplusone。我知道这两个链接(以及许多其他链接)。尽管如此,这并不能解决问题。我也尝试了引用(尽管我认为没有必要),如此处所述:humbug.in/2012/…。仍然没有运气。我很快就会发布一个更新也失败了,也许这表明我在这里的错误思维方式。
      猜你喜欢
      • 2015-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-27
      • 2014-10-21
      • 2016-01-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多