开发者

What is wrong with this Makefile

I have the following makefile. If I do make USE_44=1 USE_O=1 for example, I receive the following error.

makefile:21: *** missing separator, where line 21 is elif ($(USE_S), 1).

Note that if I do make USE_44=1, it compiles fine.

Can someone tell me what is the problem here and how can I fix it?

USE_44 = 0
USE_IO = 0
USE_O = 0
USE_S = 0
USE_F = 0
USE_I = 0
USE_WL = 0

ifeq ($(USE_44), 0)
    CXX = g++
else
    CXX = g++44
endif

CXXFILES = main.cpp jacobcalc.cpp linkup.cpp slave1.cpp jacobcalc2.cpp slave2.cpp laplacalc.cp开发者_StackOverflow中文版p multi.cpp subblock.cpp replication.cpp hash.cpp

CXXFLAGS := -std=c++0x -O3 -o

ifeq ($(USE_O), 1)
    CXXFLAGS += progo -DWITHOUT_LOCKS -DWITHOUT_BARRIERS -DWITHOUT_MPROTECT 
elif ($(USE_S), 1)
    CXXFLAGS += progs -DWITHOUT_LOCKS -DWITHOUT_BARRIERS -DWITHOUT_MPROTECT -DSINGLE
elif ($(USE_F), 1)
    CXXFLAGS += progf -DNEGLECT_DET_LOCKS 
elif ($(USE_I), 1)
    CXXFLAGS += progi -DWITH_INSTR
elif ($(USE_WL), 1)
    CXXFLAGS += progwl -DWITHOUT_LOCKS 
else
    CXXFLAGS += prog
endif

ifeq ($(USE_IO), 1)
    CXXFLAGS += -DWITHOUT_IO
endif

#CFLAGS := $(CFLAGS) -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wdisabled-optimization
#CFLAGS := $(CFLAGS) -Wpadded -Winline -Wpointer-arith -Wsign-compare -Wendif-labels prog
LIBS := -lm -lpthread 

all:
    $(CXX) $(CXXFILES) $(LIBS) $(CXXFLAGS)

clean:
    rm -f prog* *.o


The correct way to use conditionals is outlined in the make documentation.

  conditional-directive
  text-if-one-is-true
  else conditional-directive
  text-if-true
  else
  text-if-false
  endif

elif is unrecognized. If you'd instead typed else ifeq(...) it should all be good.


Try with:

ifeq ($(USE_O), 1)
   ...
else ifeq ($(USE_S), 1)
   ...
endif

That's the correct syntax according the the conditional syntax docs for GNU Make.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜