2011-08-14 68 views
4

我有下面的makefile。例如,如果我做make USE_44=1 USE_O=1,我收到以下錯誤。這個Makefile有什麼問題

makefile:21: *** missing separator,其中第21行是elif ($(USE_S), 1)

請注意,如果我做make USE_44=1,它編譯罰款。

有人可以告訴我這裏有什麼問題,我該如何解決?

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.cpp 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 

回答

12

使用條件的正確方法在make documentation中列出。

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

elif無法識別。如果你想輸入else ifeq(...)它應該都是好的。

2

嘗試用:

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

這是根據該conditional syntax文檔用於GNU進行正確的語法。