gpt4 book ai didi

makefile - Makefile中的条件: missing separator error?

转载 作者:行者123 更新时间:2023-12-04 23:03:54 27 4
gpt4 key购买 nike

我想按照http://sunsite.ualberta.ca/Documentation/Gnu/make-3.79/html_chapter/make_7.html#SEC72的指南在Makefile中编写一些条件语句。但是,我收到错误Makefile:219: *** missing separator. Stop.,其中第219行是ifeq语句的行。带有-$(FC)的三行确实以制表符开头。

我正在使用GNU Make 3.81。任何帮助是极大的赞赏!

[...]

mod: $(MODBIN)

$(MODBIN): $(MODSRC)
ifeq($(FC),gfortran)
-$(FC) $(MODFLAGS) -J$(INCPATH) $(INCLUDE) -c -o $@ $(subst $(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
else ifeq($(FC),ifort)
-$(FC) $(MODFLAGS) -module $(INCPATH) $(INCLUDE) -c -o $@ $(subst $(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
else ifeq ($(FC),xlf2003_r)
-$(FC) $(MODFLAGS) -qmoddir=$(INCPATH) $(INCLUDE) -c -o $@ $(subst $(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
endif

io: $(IOBIN)

[...]

编辑:根据@ sagar-sakre的建议,我更改为:
[...]
mod: $(MODBIN)

$(MODBIN): $(MODSRC)
ifeq($(B3dC),gfortran)
-$(FC) $(MODFLAGS) -J$(INCPATH) $(INCLUDE) -c -o $@ $(subst $(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
else ifeq($(B3dC),ifort)
-$(FC) $(MODFLAGS) -module $(INCPATH) $(INCLUDE) -c -o $@ $(subst $(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
else ifeq ($(B3dC),xlf2003_r)
-$(FC) $(MODFLAGS) -qmoddir=$(INCPATH) $(INCLUDE) -c -o $@ $(subst $(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
endif endif endif

io: $(IOBIN)
[...]

但是,现在我收到此错误:
ifeq(xlf,gfortran)
/bin/sh: -c: line 0: syntax error near unexpected token `xlf,gfortran'
/bin/sh: -c: line 0: `ifeq(xlf,gfortran)'
make: *** [build/basic.o] Error 2

所以这里还是有问题的...

最佳答案

ifeq后应该有一个[空格]

mod: $(MODBIN)
$(MODBIN): $(MODSRC)
ifeq ($(FC),gfortran)
-$(FC) $(MODFLAGS) -J$(INCPATH) $(INCLUDE) -c -o $@ $(subst
$(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
else ifeq ($(FC),ifort)
-$(FC) $(MODFLAGS) -module $(INCPATH) $(INCLUDE) -c -o $@ $(subst
$(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
else ifeq ($(FC),xlf2003_r)
-$(FC) $(MODFLAGS) -qmoddir=$(INCPATH) $(INCLUDE) -c -o $@ $(subst
$(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
endif

一般的Makefile将是
target:dependencies
ifeq ( parm1, parm2)
[TAB] operation
else
[TAB] operation
endif

关于makefile - Makefile中的条件: missing separator error?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16770042/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com