Skip to content

Commit e9c726b

Browse files
committed
Improved Makefile
1 parent 48eb5fd commit e9c726b

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

echo/Makefile

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Makefile for echo client and server
22

3-
CXX= g++ $(CCFLAGS)
3+
CXX= g++ $(CXXFLAGS)
44

55
ECHO-SERVER= echo-server.o server.o
66
ECHO-CLIENT= echo-client.o client.o
77
OBJS = $(ECHO-SERVER) $(ECHO-CLIENT)
88

99
LIBS=
1010

11-
CCFLAGS= -g
11+
CXXFLAGS= -g
1212

13-
all: echo-server echo-client
13+
all: server client
1414

15-
echo-server:$(ECHO-SERVER)
15+
server:$(ECHO-SERVER)
1616
$(CXX) -o server $(ECHO-SERVER) $(LIBS)
1717

18-
echo-client:$(ECHO-CLIENT)
18+
client:$(ECHO-CLIENT)
1919
$(CXX) -o client $(ECHO-CLIENT) $(LIBS)
2020

2121
clean:
@@ -24,11 +24,7 @@ clean:
2424
realclean:
2525
rm -f $(OBJS) $(OBJS:.o=.d) server client
2626

27+
%.o : %.cc
28+
$(CXX) -c -o $@ -MD -MP ${CPPFLAGS} ${CXXFLAGS} $<
2729

28-
# These lines ensure that dependencies are handled automatically.
29-
%.d: %.cc
30-
$(SHELL) -ec '$(CC) -M $(CPPFLAGS) $< \
31-
| sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
32-
[ -s $@ ] || rm -f $@'
33-
34-
include $(OBJS:.o=.d)
30+
-include $(OBJS:.o=.d)

0 commit comments

Comments
 (0)