2011-12-15 106 views
0

我有下面的Makefile,由於某些原因,它依賴於文件ewapi.c。該文件執行一些SWIG命令並使用ewapi.i文件。我已經清除了ewapi.c的所有內容,並且Makefile成功運行。如果我刪除ewapi.c文件,make文件將無法完成。如果有幫助,異常堆棧如下。有關如何更改Makefile以使其不依賴於ewapi.c的任何想法?如何刪除Makefile對C文件的依賴關係

# BUILD_DIR and DIST_DIR are exported by build.xml 
# 
CMODE= 

SWIG = swig 
CC = $(PREFIX)gcc 
LD = $(CC) 

OBJ_DIR = $(BUILD_DIR)/obj 
AUTOGEN_DIR = $(BUILD_DIR)/auto-generated 
PACKAGE_DIR = $(AUTOGEN_DIR)/com/sample/jni 

PACKAGE = com.sample.jni 

INCLUDES = -I$(JAVA_INCLUDE) \ 
      -I$(SAMPLE_SDK_DIR)/include \ 
      -I$(JDK_HOME)/include 

LIB_INCLUDES = -L$(SAMPLE_SDK_DIR)/lib 

LIBS = /lib/libssl.so.4 \ 
     /lib/libcrypto.so.4 \ 
     -lSampleApi \ 
     -lm 

DIRS = $(PACKAGE_DIR) $(DIST_DIR) $(OBJ_DIR) $(AUTOGEN_DIR) 

CFLAGS = $(CMODE) -Wall -fpic $(INCLUDES) -O0 -g3 
SFLAGS = -java $(INCLUDES) -package $(PACKAGE) -outdir $(PACKAGE_DIR) 
LDFLAGS = -shared $(LIB_INCLUDES) $(LIBS) 

OBJECTS = $(OBJ_DIR)/ewapi_wrap.o $(OBJ_DIR)/ewapi.o 
TARGET = $(DIST_DIR)/libSample.so 

all: $(DIRS) $(TARGET) 

%_wrap.c: %.i 
    $(SWIG) $(SFLAGS) $< 

$(OBJ_DIR)/%.o: %.c 
    $(CC) $(CFLAGS) -c $< -o [email protected] 

$(TARGET): $(OBJECTS) 
    $(LD) $(OBJECTS) $(LDFLAGS) -o [email protected] 

$(DIRS): 
    mkdir -p [email protected] 

clean: 
    rm -rf $(TARGET) $(PACKAGE_DIR)/* $(TARGET) $(AUTOGEN_DIR) $(OBJ_DIR) 

異常堆棧(當我除去ewapi.c):

[exec] rm ewapi_wrap.c 
[exec] make-3.79.1-p7: *** No rule to make target `/test/build/obj/ewapi.o', needed by `/test/dist/libSample.so'. Stop. 

回答

1

OBJECTS包括$(OBJ_DIR)/ewapi.o; $(TARGET)的規則表示它取決於$(OBJECTS);並且all的規則說它取決於$(TARGET)。因此,需要有一種方法可以創建ewapi.o - 如果沒有ewapi.c,則無法構建ewapi.o,因此您會收到投訴。

可能的修正:

  • 更換ewapi.c
  • 從宏$(OBJECTS)刪除ewapi.o
+0

從宏$(OBJECTS)刪除eawpi.o做了詭計。謝謝 – c12 2011-12-15 01:33:23

1

OBJECTS刪除$(OBJ_DIR)/ewapi.o

+0

謝謝你的工作 – c12 2011-12-15 01:33:31