2011-12-07 16 views
3

所以我創建了一個規則來將所有.c文件轉換爲.o文件。我使用變量$將規則的右側放入配方中。左邊是$ @,但右邊是空的。我記得我用$做了一個類似的Makefile,它工作。

CFLAGS =-c -g 

all:server client 

server:server.o 
     gcc -o server server.o 

client:client.o 
     gcc -o client client.o 

clean: 
     rm *.o server client 

%.o:%.c 
     gcc ${CFLAGS} -o [email protected] $ 
server.o : server.c 
client.o : client.c 

回答

4

應該是$<,而不是簡單的$。見info "(make) Automatic Variables"

+0

謝謝。這樣可行。我正在從一本書中學習,似乎錯過了'<'字符。 – Amumu

相關問題