Skip to content

Commit

Permalink
Improved Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
zappala committed Sep 17, 2016
1 parent 48eb5fd commit e9c726b
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions echo/Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Makefile for echo client and server

CXX= g++ $(CCFLAGS)
CXX= g++ $(CXXFLAGS)

ECHO-SERVER= echo-server.o server.o
ECHO-CLIENT= echo-client.o client.o
OBJS = $(ECHO-SERVER) $(ECHO-CLIENT)

LIBS=

CCFLAGS= -g
CXXFLAGS= -g

all: echo-server echo-client
all: server client

echo-server:$(ECHO-SERVER)
server:$(ECHO-SERVER)
$(CXX) -o server $(ECHO-SERVER) $(LIBS)

echo-client:$(ECHO-CLIENT)
client:$(ECHO-CLIENT)
$(CXX) -o client $(ECHO-CLIENT) $(LIBS)

clean:
Expand All @@ -24,11 +24,7 @@ clean:
realclean:
rm -f $(OBJS) $(OBJS:.o=.d) server client

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

# These lines ensure that dependencies are handled automatically.
%.d: %.cc
$(SHELL) -ec '$(CC) -M $(CPPFLAGS) $< \
| sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
[ -s $@ ] || rm -f $@'

include $(OBJS:.o=.d)
-include $(OBJS:.o=.d)

0 comments on commit e9c726b

Please sign in to comment.