Is this makefile eliminating the .c file?
all: servidor
servidor: servidor.o
gcc -lpthread -o servidor.o
servidor.o:
clean:
gcc -c servidor.c
rm -rf servidor.o
Questions:
a)Is the clean: line eliminating the servidor.c fil开发者_StackOverflow社区e?
b)How can I modify the makefile so that it also compiles a client.c program and creates a client.o?
Your entire makefile should look like this:
LDLIBS=-lpthread
servidor: servidor.o client.o
clean:
<TAB>rm -f *.o
a)Is the clean: line eliminating the servidor.c file?
No. The line
gcc -c servidor.c
is just a lame way of ensuring servidor.o exists, and the subsequent rm does not fail. It should rather be
clean:
-rm -rf servidor.o
b)How can I modify the makefile so that it also compiles a client.c program and creates a client.o?
The easiest way is use built-in rules. If you add client, or client.o in any of a rule's prerequisites, it will be built automatically from client.c.
(and add -lpthread to LDLIBS if you need it for client.c)
the makefile seems so strange,i am not sue whether it can work or not? but i think it better as following:
all: client
client: client.o
gcc -lpthread -o client.o
client.o:
gcc -c client.c
clean:
rm -rf client.o
加载中,请稍侯......
精彩评论