-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathMakefile.in
188 lines (175 loc) · 7.26 KB
/
Makefile.in
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#---------------------------------------------------------------------#
CC := @CC@
LUALIBPATH := @LUALIBPATH@
LUALIBNAME := @LIBLUANAME@
LUAINCPATH := @LUAINCPATH@
JEINCPATH := @JEINCPATH@
CFLAGS := @CFLAGS@
LDFLAGS := @LDFLAGS@
USEREADLINE := @USEREADLINE@
BROKERLIBPATH := @BROKERLIBPATH@
BROKERINCPATH := @BROKERINCPATH@
USEBROKER := @USEBROKER@
BINDIR := $(shell pwd)/bin
BINNAME := bricks
BIN := $(BINDIR)/$(BINNAME)
OSARCH := $(shell uname)
OSARCH := $(findstring $(OSARCH),FreeBSD Linux Darwin)
DEBUG_CFLAGS := -g -DDEBUG -Wall -Werror -Wunused-function -Wextra -D_GNU_SOURCE -D__USE_GNU
DEBUG_CFLAGS += -DDLUA -DDPKTENG -DDNMP -DDUTIL -DDIFACE -DDBKEND -DDPKTHASH -DDBRICK
INSTALL := @INSTALL@
INSTALL_PROGRAM := @INSTALL_PROGRAM@
INSTALL_DATA := @INSTALL_DATA@
# Top level hierarchy
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
bindir = @bindir@
sbindir = @sbindir@
includedir = @includedir@
libdir = @libdir@
mandir = @mandir@
sysconfdir = @sysconfdir@
#---------------------------------------------------------------------#
ifeq ($V,) # no echo
export MSG=@echo
export HIDE=@
else
export MSG=@\#
export HIDE=
endif
export OSARCH
export OBJDIR := $(shell pwd)/.objs
export CFLAGS += -O3 -pipe -Wall -Wunused-function -Wextra -Werror -D_GNU_SOURCE -D__USE_GNU
ifeq ($(USEREADLINE),1)
DEBUG_CFLAGS += -DLUA_USEREADLINE
export CFLAGS += -DLUA_USEREADLINE
export LDFLAGS += -lreadline
endif
ifeq ($(USEBROKER),1)
export CFLAGS += -DENABLE_BROKER -I$(BROKERINCPATH)
export DEBUG_CFLAGS += -DENABLE_BROKER -I$(BROKERINCPATH)
export LDFLAGS += -L$(BROKERLIBPATH) -lbroker
endif
export NETMAP_INCLUDE := -I$(shell pwd)/include/netmap
ifeq ($(OSARCH),FreeBSD)
export INCLUDE := -I$(shell pwd)/include -I$(LUAINCPATH)/ -Isys/sys/
export LIBS := -L$(LUALIBPATH)/ -llua-5.1 -lpthread -lpcap
export LDFLAGS += $(LIBS)
else
export INCLUDE := -I$(shell pwd)/include -I$(LUAINCPATH)/
export LIBS := -L$(LUALIBPATH)/ $(LUALIBNAME) -lpthread -lpcap
ifneq ($(strip $(JEINCPATH)),)
export INCLUDE += -I$(JEINCPATH)
export LDFLAGS += $(LIBS) -L$(JELIBPATH) -fno-builtin-malloc \
-fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free \
-fno-builtin-posix_memalign -ljemalloc
else
export LDFLAGS += $(LIBS)
endif
endif
#---------------------------------------------------------------------#
all: $(BINNAME)
objs:
mkdir -p $(OBJDIR)
chmod a+x .create_bricks.sh
bash ./.create_bricks.sh
cd src && $(MAKE)
objs-dbg:
$(eval export CFLAGS := $(DEBUG_CFLAGS))
mkdir -p $(OBJDIR)
chmod a+x .create_bricks.sh
bash ./.create_bricks.sh
cd src && $(MAKE)
$(BINNAME): objs
mkdir -p $(BINDIR)
$(MSG) " LD $@"
$(HIDE) $(CC) $(OBJDIR)/*.o $(LDFLAGS) -o $(BIN)
@printf "#!/usr/bin/env bash\n$(BINDIR)/$(BINNAME) -d $$""@"> $(BINDIR)/$(BINNAME)-server
@printf "#!/usr/bin/env bash\n$(BINDIR)/$(BINNAME) -s $$""@"> $(BINDIR)/$(BINNAME)-shell
@printf "#!/usr/bin/env bash\npkill $(BINNAME)"> $(BINDIR)/$(BINNAME)-kill-server
@printf "#!/usr/bin/env bash\n\# check if there is only one additional command-line argument\nif [ \$$\# -ne 2 ]\nthen\n\techo \"Usage:\"\n\techo \"\$$0 <interface_name> <split>\"\n\texit 1\nfi\necho \"\$$1\" > /tmp/bricks.iface\necho \"\$$2\" > /tmp/bricks.split\n$(sbindir)/$(BINNAME)-server -f $(sysconfdir)/$(BINNAME)-scripts/load-balance.lua" > $(BINDIR)/$(BINNAME)-load-balance
@printf "#!/usr/bin/env bash\n\# check if there is only one additional command-line argument\nif [ \$$\# -ne 2 ]\nthen\n\techo \"Usage:\"\n\techo \"\$$0 <interface_name> <split>\"\n\texit 1\nfi\necho \"\$$1\" > /tmp/bricks.iface\necho \"\$$2\" > /tmp/bricks.split\n$(sbindir)/$(BINNAME)-server -f $(sysconfdir)/$(BINNAME)-scripts/duplicate.lua" > $(BINDIR)/$(BINNAME)-duplicate
chmod a+x $(BINDIR)/$(BINNAME)-server
chmod a+x $(BINDIR)/$(BINNAME)-shell
chmod a+x $(BINDIR)/$(BINNAME)-kill-server
chmod a+x $(BINDIR)/$(BINNAME)-load-balance
chmod a+x $(BINDIR)/$(BINNAME)-duplicate
strip $(BIN)
run: $(BINNAME)
$(BIN) -f scripts/startup.lua
#---------------------------------------------------------------------#
debug: $(BINNAME)-debug
$(BINNAME)-debug: objs-dbg
mkdir -p $(BINDIR)
$(MSG) " LD $@-debug"
$(HIDE) $(CC) $(OBJDIR)/*.o $(LDFLAGS) -o $(BIN)
@printf "#!/usr/bin/env bash\n$(BINDIR)/$(BINNAME) -d $$""@" > $(BINDIR)/$(BINNAME)-server
@printf "#!/usr/bin/env bash\n$(BINDIR)/$(BINNAME) -s $$""@"> $(BINDIR)/$(BINNAME)-shell
@printf "#!/usr/bin/env bash\npkill $(BINNAME)"> $(BINDIR)/$(BINNAME)-kill-server
@printf "#!/usr/bin/env bash\necho \"\$$1\" > /tmp/bricks.iface\necho \"\$$2\" > /tmp/bricks.split\n$(sbindir)/$(BINNAME)-server -f $(sysconfdir)/$(BINNAME)-scripts/load-balance.lua" > $(BINDIR)/$(BINNAME)-load-balance
@printf "#!/usr/bin/env bash\necho \"\$$1\" > /tmp/bricks.iface\necho \"\$$2\" > /tmp/bricks.split\n$(sbindir)/$(BINNAME)-server -f $(sysconfdir)/$(BINNAME)-scripts/duplicate.lua" > $(BINDIR)/$(BINNAME)-duplicate
chmod a+x $(BINDIR)/$(BINNAME)-server
chmod a+x $(BINDIR)/$(BINNAME)-shell
chmod a+x $(BINDIR)/$(BINNAME)-kill-server
chmod a+x $(BINDIR)/$(BINNAME)-load-balance
chmod a+x $(BINDIR)/$(BINNAME)-duplicate
#---------------------------------------------------------------------#
clean:
cd src && $(MAKE) clean
$(RM) -rf include/brick.h
$(RM) -rf $(BINDIR) include/*~ tags scripts/*~ *~
distclean: clean
cd src && $(MAKE) distclean
$(RM) -rf Makefile autom4te.cache config.log config.status
$(RM) -rf scripts/duplicate.lua scripts/load-balance.lua scripts/startup-multi-threads.lua scripts/startup-one-thread.lua
chmod a-x .create_bricks.sh
.PHONY: clean
tags:
find . -name '*.c' -or -name '*.h' | xargs ctags
#---------------------------------------------------------------------#
ifeq ($(OSARCH),FreeBSD)
install-man:
@echo -e "\e[1;34mInstalling manual pages $<\e[0m"
gzip man/*
cp man/* /usr/share/man/man1/
makewhatis
gunzip man/*
else
install-man:
@echo -e "\e[1;34mInstalling manual pages $<\e[0m"
gzip man/*
cp man/* /usr/share/man/man1/
mandb
gunzip man/*
endif
install: install-man
@echo -e "\e[1;34mPlacing the binaries in the $(sbindir)/ directory $<\e[0m"
mkdir -p $(sbindir)
$(INSTALL_PROGRAM) $(BIN) $(sbindir)/
$(INSTALL_PROGRAM) $(BIN)-server $(sbindir)/
$(INSTALL_PROGRAM) $(BIN)-shell $(sbindir)/
$(INSTALL_PROGRAM) $(BIN)-kill-server $(sbindir)/
$(INSTALL_PROGRAM) $(BIN)-load-balance $(sbindir)/
$(INSTALL_PROGRAM) $(BIN)-duplicate $(sbindir)/
@echo -e "\e[1;34mPlacing the scripts in the $(sysconfdir)/$(BINNAME)-scripts/ directory $<\e[0m"
mkdir -p $(sysconfdir)/$(BINNAME)-scripts
cp -R scripts/* $(sysconfdir)/$(BINNAME)-scripts
uninstall:
@echo -e "\e[1;34mRemoving binaries... $<\e[0m"
$(RM) $(sbindir)/$(BINNAME)
$(RM) $(sbindir)/$(BINNAME)-server
$(RM) $(sbindir)/$(BINNAME)-shell
$(RM) $(sbindir)/$(BINNAME)-kill-server
$(RM) $(sbindir)/$(BINNAME)-load-balance
$(RM) $(sbindir)/$(BINNAME)-duplicate
@echo -e "\e[1;34mRemoving scripts... $<\e[0m"
$(RM) -r $(sysconfdir)/$(BINNAME)-scripts
@echo -e "\e[1;34mRemoving manpages... $<\e[0m"
$(RM) /usr/share/man/man1/$(BINNAME).1.gz
$(RM) /usr/share/man/man1/$(BINNAME)-server.1.gz
$(RM) /usr/share/man/man1/$(BINNAME)-kill-server.1.gz
$(RM) /usr/share/man/man1/$(BINNAME)-load-balance.1.gz
$(RM) /usr/share/man/man1/$(BINNAME)-duplicate.1.gz
$(RM) /usr/share/man/man1/$(BINNAME)-shell.1.gz
#---------------------------------------------------------------------#