-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
148 lines (110 loc) · 4.92 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
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
# Makefile
# Author: Martin Casado, David Underhill
all : sr
APP = sr
APP_TPP = sr_tpp
CC = gcc
# MODE controls whether the router gets/sends packets from/to the NetFPGA or VNS
MODE_NETFPGA = -D_CPUMODE_
MODE_VNS =
MODE = $(MODE_VNS)
include Makefile.common
DEBUG = -g
PERF = -O3
CFLAGS = -Wall -D_GNU_SOURCE $(DEBUG) $(ARCH) -I lwtcp -I cli $(MODE) $(MORE_FLAGS)
USER_LIBS=libsr_base.a liblwtcp.a
PFLAGS= -follow-child-processes=yes -cache-dir=/tmp/${USER}
PURIFY= purify ${PFLAGS}
#------------------------------------------------------------------------------
RESTRICTED_CLI_SRCS = cli/cli.c cli/cli_help.c cli/cli_main.c \
cli/search_state.c cli/cli_local.c \
cli/lex.yy.c cli/y.tab.c cli/helper.c
CLI_SRCS = cli/socket_helper.c $(RESTRICTED_CLI_SRCS) sr_lwtcp_glue.c
CLI_OBJS = $(patsubst cli/%.c, %.o, $(CLI_SRCS))
cli/lex.yy.c cli/lex.yy.o :
make -C cli lex.yy.o
cli/y.tab.c cli/y.tab.o :
make -C cli y.tab.o
#------------------------------------------------------------------------------
LWTCP_SRCS = lwtcp/tcp.c lwtcp/tcp_input.c lwtcp/tcp_output.c \
lwtcp/mem.c lwtcp/memp.c lwtcp/stats.c lwtcp/sys.c \
lwtcp/inet.c lwtcp/pbuf.c lwtcp/sys_arch.c \
lwtcp/sockets.c lwtcp/api_lib.c lwtcp/api_msg.c \
lwtcp/transport_subsys.c lwtcp/udp.c lwtcp/icmp.c lwtcp/ip_addr.c \
lwtcp/err.c
LWTCP_OBJS = $(patsubst lwtcp/%.c, %.o, $(LWTCP_SRCS))
liblwtcp.a : $(LWTCP_OBJS)
ar rcu liblwtcp.a $(LWTCP_OBJS)
#------------------------------------------------------------------------------
SR_BASE_SRCS = sr_base.c sr_dumper.c sr_integration.c sr_lwtcp_glue.c \
sr_vns.c sr_cpu_extension_nf2.c real_socket_helper.c sha1.c \
linked_list.c sr_arp_cache.c sr_common.c \
sr_arp_cache_entry.c sr_interface.c packet_dispatcher.c \
sr_neighbor.c sr_arp.c sr_ip.c sr_icmp.c sr_icmp_types.c \
sr_icmp_types_response.c sr_udp.c sr_ethernet.c sr_rtable.c \
sr_router.c sr_pwospf.c sr_pwospf_types.c sr_rt.c \
sr_icmp_types_send.c sr_neighbor_db.c sr_dijkstra.c sr_rtable_hw.c \
sr_reroute_multipath.c
SR_BASE_OBJS = $(patsubst %.c,%.o,$(SR_BASE_SRCS))
libsr_base.a : $(SR_BASE_OBJS)
ar rcu libsr_base.a $(SR_BASE_OBJS)
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
SR_SRCS_MAIN = sr_main.c
SR_SRCS_BASE = nf2util.c
SR_SRCS = $(SR_SRCS_MAIN) $(SR_SRCS_BASE)
SR_OBJS = $(patsubst %.c,%.o,$(SR_SRCS)) $(CLI_OBJS)
sr : $(SR_OBJS) $(USER_LIBS)
$(CC) $(CFLAGS) -o $(APP) $(SR_OBJS) $(LIBS) $(USER_LIBS)
#------------------------------------------------------------------------------
# CLI Test targe
TEST_CLI_APP = cli/test_cli.exe
TEST_CLI_SRCS = cli/cli_test.c $(SR_SRCS_BASE) $(RESTRICTED_CLI_SRCS)
TEST_CLI_OBJS = $(patsubst %.c,%.o,$(TEST_CLI_SRCS)) cli/socket_helper_to_stderr.o
cli/socket_helper_to_stderr.o : cli/socket_helper.c cli/socket_helper.h
make -C cli socket_helper_to_stderr.o
test_cli.exe: $(TEST_CLI_OBJS) $(USER_LIBS)
$(CC) $(CFLAGS) -o $(TEST_CLI_APP) $(TEST_CLI_OBJS) $(LIBS) $(USER_LIBS)
#------------------------------------------------------------------------------
ALL_SRCS = $(sort $(SR_SRCS) $(SR_BASE_SRCS) $(LWTCP_SRCS) $(CLI_SRCS))
ALL_LWTCP_SRCS = $(filter lwtcp/%.c, $(ALL_SRCS))
ALL_CLI_SRCS = $(filter cli/%.c, $(ALL_SRCS))
ALL_SR_SRCS_NO_LWTCP = $(filter-out lwtcp/%.c, $(ALL_SRCS))
ALL_SR_SRCS = $(filter-out cli/%.c, $(ALL_SR_SRCS_NO_LWTCP))
ALL_LWTCP_OBJS = $(patsubst lwtcp/%.c,%.o, $(ALL_LWTCP_SRCS))
ALL_CLI_OBJS = $(patsubst cli/%.c,%.o, $(ALL_CLI_SRCS))
ALL_SR_OBJS = $(patsubst %.c,%.o, $(ALL_SR_SRCS))
ALL_LWTCP_DEPS = $(patsubst lwtcp/%.c,.%.d,$(ALL_LWTCP_SRCS))
ALL_CLI_DEPS = $(patsubst cli/%.c,.%.d,$(ALL_CLI_SRCS))
ALL_SR_DEPS = $(patsubst %.c,.%.d,$(ALL_SR_SRCS))
$(ALL_SR_OBJS) : %.o : %.c
$(CC) -c $(CFLAGS) $< -o $@
$(ALL_LWTCP_OBJS) : %.o : ./lwtcp/%.c
$(CC) -c $(CFLAGS) $< -o $@
$(ALL_CLI_OBJS) : %.o : ./cli/%.c
$(CC) -c $(CFLAGS) $< -o $@
$(ALL_LWTCP_DEPS) : .%.d : ./lwtcp/%.c
$(CC) -MM $(CFLAGS) -I lwtcp/ $< > $@
$(ALL_CLI_DEPS) : .%.d : ./cli/%.c
$(CC) -MM $(CFLAGS) -I cli/ $< > $@
$(ALL_SR_DEPS) : .%.d : %.c
$(CC) -MM $(CFLAGS) -I lwtcp/ $< > $@
include $(ALL_LWTCP_DEPS)
include $(ALL_CLI_DEPS)
include $(ALL_SR_DEPS)
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
.PHONY : clean clean-deps dist
clean-byproducts:
rm -f *.o *~ core.* *.dump *.tar tags *.a test_arp_subsystem\
lwcli lwtcpsr sr_base.tar.gz
clean: clean-byproducts
rm -f $(APP) $(APP_TPP)
make -C cli clean
clean-deps:
rm -f .*.d
dist: clean clean-deps
(cd ..; tar --exclude-from=base/exclude -cvf sr_base.tar base/; gzip sr_base.tar; mv\
sr_base.tar.gz base/)
tags:
ctags *.c