forked from cmu15418/assignment4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (68 loc) · 2.44 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
OBJDIR=objs
SRCDIR=src
HARNESSDIR=$(SRCDIR)/asst4harness
DEPDIR=deps
LOGDIR=logs.*
# all should come first in the file, so it is the default target!
.PHONY: all run clean cleanlogs
all : worker master
run: run.sh worker master | $(LOGDIR)
./run.sh 1 tests/hello418.txt
SRCS=
DEPS=
WTF=
# Define our wonderful make functions.
include functions.mk
# Include all sub directories.
$(eval $(call define_program,worker, \
$(HARNESSDIR)/worker/main.cpp \
$(HARNESSDIR)/worker/work_engine.cpp \
$(SRCDIR)/myserver/worker.cpp \
))
$(eval $(call define_program,master, \
$(HARNESSDIR)/master/main.cpp \
$(HARNESSDIR)/master/main_loop.cpp \
$(SRCDIR)/myserver/master.cpp \
))
$(eval $(call define_library,comm, \
$(HARNESSDIR)/comm/comm.cpp \
$(HARNESSDIR)/comm/connect.cpp \
))
$(eval $(call define_library,types, \
$(HARNESSDIR)/types/types.cpp \
$(HARNESSDIR)/types/messages.cpp \
))
$(OBJDIR)/libcomm.a: $(OBJDIR)/libtypes.a
worker master: $(OBJDIR)/libcomm.a $(OBJDIR)/libtypes.a
# I don't want to have to learn csh syntax.
SHELL := /bin/bash
LIBS=libglog libevent libgflags
PKGCONFIG=PKG_CONFIG_PATH=external_lib/pkgconfig:$$PKG_CONFIG_PATH pkg-config
# Fail quickly if we can't find one of the libraries.
# Ok, this is really the point I should have switched to autoconf.
LIBS_NOTFOUND:=$(foreach lib,$(LIBS),$(shell $(PKGCONFIG) --exists $(lib); if [ $$? -ne 0 ]; then echo $(lib); fi))
ifneq ($(strip $(LIBS_NOTFOUND)),)
$(error "Libraries not found: '$(LIBS_NOTFOUND)'")
endif
CXX=g++
CXXFLAGS+=-Wall -Wextra -O2 -std=c++11
CPPFLAGS+=-I$(CURDIR)/src/asst4harness -I$(CURDIR)/src/asst4include $(foreach lib,$(LIBS), $(shell $(PKGCONFIG) --cflags $(lib)))
LDFLAGS+=-lpthread $(foreach lib,$(LIBS), $(shell $(PKGCONFIG) --libs $(lib))) -Xlinker -rpath -Xlinker external_lib
$(LOGDIR):
mkdir -p $@
local_server: $(OBJS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp Makefile
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -c -o $@
$(DEPDIR)/%.d: $(SRCDIR)/%.cpp Makefile
@set -e; rm -f $@; \
$(CXX) $(CXXFLAGS) -M $(CPPFLAGS) $< > $@.$$$$; \
sed 's,$(notdir $*)\.o[ :]*,$(OBJDIR)/$*.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
-include $(DEPS)
clean:
rm -rf $(OBJDIR) $(DEPDIR) master worker *.pyc
cleanlogs:
rm -rf $(LOGDIR) latedays.qsub.*
handin: all
tar -cf handin.tar writeup.pdf -C src myserver