2011-03-04 76 views
0

我想修改一个Makefile,但找不到这个规则。如何用同一个文件生成不同的对象

以下不起作用。我不知道如何将src写入obj规则。

# foo.c bar.c main.c 
SRC = $(wildcard *.c) 
OBJ_1 = $(patsubst %.c,%_1.o,$(SRC)) 
OBJ_2 = $(patsubst %.c,%_2.o,$(SRC)) 

GCC1 = vtcc 
GCC2 = vtcc 

LD_FLAGS= -lm -lpthread 

all: a1 a2 

# executables : 
a1: $(OBJ_1) 
    $(GCC1) $(LDFLAGS) $^ -o [email protected] 
a2: $(OBJ_2) 
    $(GCC2) $(LDFLAGS) $^ -o [email protected] 

# objects : 
$(OBJ_1) : $(SRC) 
    $(GCC1) -c $< -o [email protected] 

$(OBJ_2) : $(SRC) 
    $(GCC2) -c $< -o [email protected] 

回答

1

很难告诉你的问题是什么,但我觉得最后两个规则应该是:

# objects : 
$(OBJ_1) : %_1.o : %.c 
    $(GCC1) -c $< -o [email protected] 

$(OBJ_2) : %_2.o : %.c 
    $(GCC2) -c $< -o [email protected] 
+0

叶氏,原来如此!对于非问题抱歉,这是一天的结束,我重复了几次这个问题,在一个改写中删除它。 – 2011-03-08 09:00:29

相关问题