forked from GNS3/ubridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
104 lines (87 loc) · 2.68 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
#!/usr/bin/make -f
#
# This file is part of ubridge, a program to bridge network interfaces
# to UDP tunnels.
#
# Copyright (C) 2015 GNS3 Technologies Inc.
#
# ubridge is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ubridge is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
NAME = ubridge
SRC = src/ubridge.c \
src/nio.c \
src/nio_udp.c \
src/nio_unix.c \
src/nio_ethernet.c \
src/nio_tap.c \
src/parse.c \
src/packet_filter.c \
src/pcap_capture.c \
src/pcap_filter.c \
src/hypervisor.c \
src/hypervisor_parser.c \
src/hypervisor_bridge.c
OBJ = $(SRC:.c=.o)
CC ?= gcc
CFLAGS += -Wall
BINDIR = /usr/local/bin
ifeq ($(shell uname), Darwin)
LIBS = -lpthread -lpcap
SRC += src/nio_fusion_vmnet.c \
else ifeq ($(shell uname -o), Cygwin)
CFLAGS += -DCYGWIN
LIBS = -lpthread -lwpcap
else
LIBS = -lpthread -lpcap
endif
# RAW Ethernet support for Linux
ifeq ($(shell uname), Linux)
CFLAGS += -DLINUX_RAW
SRC += src/nio_linux_raw.c \
src/hypervisor_docker.c \
src/hypervisor_iol_bridge.c \
src/hypervisor_brctl.c \
src/netlink/nl.c
endif
ifeq ($(SYSTEM_INIPARSER),1)
CFLAGS += -DUSE_SYSTEM_INIPARSER
LIBS += -liniparser
else
SRC += src/iniparser/iniparser.c \
src/iniparser/dictionary.c
endif
##############################
$(NAME) : $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(NAME) $(OBJ) $(LIBS)
.PHONY: clean
clean:
-rm -f $(OBJ)
-rm -f *~
-rm -f $(NAME)
all : $(NAME)
ifeq ($(shell uname), Darwin)
install : $(NAME)
cp $(NAME) $(BINDIR)
chown root:admin $(BINDIR)/$(NAME)
chmod 4750 $(BINDIR)/$(NAME)
else ifeq ($(shell uname), FreeBSD)
install : $(NAME)
cp $(NAME) $(DESTDIR)$(BINDIR)
chmod 4750 $(DESTDIR)$(BINDIR)/$(NAME)
else
install : $(NAME)
chmod +x $(NAME)
cp -p $(NAME) $(BINDIR)
setcap cap_net_admin,cap_net_raw=ep $(BINDIR)/$(NAME)
endif