-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (128 loc) · 3.82 KB
/
Makefile
File metadata and controls
153 lines (128 loc) · 3.82 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# This file doesn't contain any changes specific to the local
# installation (eg. any specific library paths etc.). See the
# .config file for these.
#
-include .config
-include */*/*.d
-include */*.d
# Compilers and mandatory libraries
CXX ?= g++
CC ?= $(CXX)
LDLIBS += -lstdc++
# Boost specific flags
LDFLAGS_BOOST ?= -L/opt/local/lib
CPPFLAGS_BOOST ?= -I/opt/local/include
LDLIBS_BOOST ?= -lboost_system -lboost_serialization -lboost_thread
# Compiler flags and optional additional Boost flags too!
CXXFLAGS += -Wall -pedantic -ansi -Wno-long-long -MMD -MP -pthread
CPPFLAGS += -I. $(CPPFLAGS_BOOST) -pthread
LDFLAGS += $(LDFLAGS_BOOST) -pthread
LDLIBS += $(LDLIBS_BOOST)
# Suffix rules
%.o: %.cpp
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
# Compile oodles object files
NET_CORE_OBJECTS := $(patsubst %.cpp,%.o,$(wildcard net/core/*.cpp))
NET_HTTP_OBJECTS := $(patsubst %.cpp,%.o,$(wildcard net/http/*.cpp))
NET_OOP_OBJECTS := $(patsubst %.cpp,%.o,$(wildcard net/oop/*.cpp))
SCHEDULER_OBJECTS := $(patsubst %.cpp,%.o,$(wildcard sched/*.cpp))
CRAWLER_OBJECTS := $(patsubst %.cpp,%.o,$(wildcard crawl/*.cpp))
UTILITY_OBJECTS := $(patsubst %.cpp,%.o,$(wildcard utility/*.cpp))
COMMON_OBJECTS := $(patsubst %.cpp,%.o,$(wildcard common/*.cpp))
URL_OBJECTS := $(patsubst %.cpp,%.o,$(wildcard url/*.cpp))
# Compile unit test object files
TEST_OBJECTS := $(patsubst %.cpp,%.o,$(wildcard test/*.cpp))
# Binary targets
TESTS = test/html-parser \
test/word-indexer \
test/url-parser \
test/url-tree \
test/url-scheduler \
test/allocator \
test/events \
test/protocol-handler \
test/oop-messages \
test/http-transfer
# Production system components
PROGRAMS = prog/scheduler \
prog/crawler
test/html-parser: test/html-parser.o \
$(COMMON_OBJECTS) \
$(UTILITY_OBJECTS) ;\
$(CXX) $(LDFLAGS) -o bin/$@ $^ $(LDLIBS)
test/word-indexer: test/word-indexer.o \
$(COMMON_OBJECTS) \
$(UTILITY_OBJECTS) ;\
$(CXX) $(LDFLAGS) -o bin/$@ $^ $(LDLIBS)
test/url-parser: test/url-parser.o \
$(COMMON_OBJECTS) \
$(URL_OBJECTS) \
$(UTILITY_OBJECTS) ;\
$(CXX) $(LDFLAGS) -o bin/$@ $^ $(LDLIBS)
test/url-tree: test/url-tree.o \
$(COMMON_OBJECTS) \
$(URL_OBJECTS) \
$(UTILITY_OBJECTS) ;\
$(CXX) $(LDFLAGS) -o bin/$@ $^ $(LDLIBS)
test/url-scheduler: test/url-scheduler.o \
$(COMMON_OBJECTS) \
$(URL_OBJECTS) \
$(UTILITY_OBJECTS) \
$(NET_CORE_OBJECTS) \
$(NET_OOP_OBJECTS) \
$(SCHEDULER_OBJECTS) ;\
$(CXX) $(LDFLAGS) -o bin/$@ $^ $(LDLIBS)
test/allocator: test/allocator.o \
$(COMMON_OBJECTS) \
$(UTILITY_OBJECTS) ;\
$(CXX) $(LDFLAGS) -o bin/$@ $^ $(LDLIBS)
test/events: test/events.o \
$(COMMON_OBJECTS) \
$(UTILITY_OBJECTS) ;\
$(CXX) $(LDFLAGS) -o bin/$@ $^ $(LDLIBS)
test/protocol-handler: test/protocol-handler.o \
$(COMMON_OBJECTS) \
$(UTILITY_OBJECTS) \
$(NET_CORE_OBJECTS) ;\
$(CXX) $(LDFLAGS) -o bin/$@ $^ $(LDLIBS)
test/oop-messages: test/oop-messages.o \
$(COMMON_OBJECTS) \
$(URL_OBJECTS) \
$(UTILITY_OBJECTS) \
$(NET_CORE_OBJECTS) \
$(NET_OOP_OBJECTS) \
$(SCHEDULER_OBJECTS) ;\
$(CXX) $(LDFLAGS) -o bin/$@ $^ $(LDLIBS)
test/http-transfer: test/http-transfer.o \
$(COMMON_OBJECTS) \
$(URL_OBJECTS) \
$(UTILITY_OBJECTS) \
$(NET_CORE_OBJECTS) \
$(NET_HTTP_OBJECTS) ;\
$(CXX) $(LDFLAGS) -o bin/$@ $^ $(LDLIBS)
prog/scheduler: prog/scheduler.o \
$(COMMON_OBJECTS) \
$(URL_OBJECTS) \
$(UTILITY_OBJECTS) \
$(NET_CORE_OBJECTS) \
$(NET_OOP_OBJECTS) \
$(SCHEDULER_OBJECTS) ;\
$(CXX) $(LDFLAGS) -o bin/$@ $^ $(LDLIBS)
prog/crawler: prog/crawler.o \
$(COMMON_OBJECTS) \
$(URL_OBJECTS) \
$(UTILITY_OBJECTS) \
$(NET_CORE_OBJECTS) \
$(NET_OOP_OBJECTS) \
$(SCHEDULER_OBJECTS) \
$(CRAWLER_OBJECTS) ;\
$(CXX) $(LDFLAGS) -o bin/$@ $^ $(LDLIBS)
# Phony targets
.PHONY: default all clean
# Make targets
default: all
all: $(TESTS) $(PROGRAMS)
clean:
-find `pwd` -depth -type f -name '*.[od]' -prune \
\! -path "`pwd`[/].git/*" -exec rm -f {} \;
-rm -f bin/*/*