forked from neilalexander/sigmavpn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
160 lines (115 loc) · 5.01 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
149
150
151
152
153
154
155
156
157
158
159
160
Zybo =
ifeq ($(ZYBO),1)
# This part is for the modified Makefile of SigmaVPN code
# It does make for the Linux running on Zybo,
# It uses libsodium and libpcap from the cross complilation directories
# Those directories are ../libsodium_installdir and ../libpcap-1.7.4
# Commands reach this part: make ZYBO=1, make ZYBO=1 clean, make ZYBO=1 install
PWD = $(shell pwd)
INSTALLDIR ?= $(PWD)/../BootFiles/sigmavpn/sigmavpn_installdir
BINDIR ?= $(INSTALLDIR)/bin
SYSCONFDIR ?= $(INSTALLDIR)/etc
LIBEXECDIR ?= $(INSTALLDIR)/lib/sigmavpn
SODIUM_INSTALLDIR ?= $(PWD)/../sigmavpn_deps/libsodium_installdir
SODIUM_CPPFLAGS ?= -I$(SODIUM_INSTALLDIR)/include
SODIUM_LDFLAGS ?= -Wl,-static -L$(SODIUM_INSTALLDIR)/lib -lsodium -Wl,-Bdynamic
LIBPCAP_PATH ?= $(PWD)/../sigmavpn_deps/libpcap-1.7.4
LIBPCAP_CPPFLAGS ?= -I$(LIBPCAP_PATH)
LIBPCAP_LDFLAGS ?= -L$(LIBPCAP_PATH) -lpcap
CC = arm-xilinx-linux-gnueabi-gcc
CFLAGS ?= -g3 -O2 -fPIC -Wall -Wextra -lc
CPPFLAGS += -g3 -O2 $(SODIUM_CPPFLAGS)
LDFLAGS += $(SODIUM_LDFLAGS) -ldl -pthread
DYLIB_CFLAGS ?= $(CFLAGS) -shared
TARGETS_OBJS = dep/ini.o main.o modules.o naclkeypair.o pack.o tai.o
TARGETS_BIN = naclkeypair sigmavpn
TARGETS_MODULES = proto/proto_hwtai.o \
proto/proto_raw.o proto/proto_nacl0.o proto/proto_nacltai.o \
intf/intf_tuntap.o intf/intf_private.o intf/intf_udp.o
TARGETS = $(TARGETS_OBJS) $(TARGETS_BIN) $(TARGETS_MODULES)
all: $(TARGETS)
clean:
rm -f $(TARGETS)
distclean: clean
install: all
mkdir -p $(BINDIR) $(SYSCONFDIR) $(LIBEXECDIR)
cp $(TARGETS_BIN) $(BINDIR)
cp $(TARGETS_MODULES) $(LIBEXECDIR)
proto/proto_hwtai.o: proto/proto_hwnacltai.c pack.o tai.o
$(CC) $(CPPFLAGS) $(SODIUM_CPPFLAGS) proto/proto_hwnacltai.c pack.o tai.o \
-o proto/proto_hwtai.o $(DYLIB_CFLAGS) $(SODIUM_LDFLAGS)
proto/proto_raw.o: proto/proto_raw.c
$(CC) $(CPPFLAGS) $(SODIUM_CPPFLAGS) proto/proto_raw.c -o \
proto/proto_raw.o $(DYLIB_CFLAGS) $(SODIUM_LDFLAGS)
proto/proto_nacl0.o: proto/proto_nacl0.c pack.o
$(CC) $(CPPFLAGS) $(SODIUM_CPPFLAGS) proto/proto_nacl0.c pack.o -o \
proto/proto_nacl0.o $(DYLIB_CFLAGS) $(SODIUM_LDFLAGS)
proto/proto_nacltai.o: proto/proto_nacltai.c pack.o tai.o
$(CC) $(CPPFLAGS) $(SODIUM_CPPFLAGS) proto/proto_nacltai.c pack.o tai.o -o \
proto/proto_nacltai.o $(DYLIB_CFLAGS) $(SODIUM_LDFLAGS)
intf/intf_tuntap.o: intf/intf_tuntap.c
$(CC) $(CPPFLAGS) intf/intf_tuntap.c -o intf/intf_tuntap.o $(DYLIB_CFLAGS)
intf/intf_private.o: intf/intf_private.c
$(CC) $(CPPFLAGS) $(LIBPCAP_CPPFLAGS) intf/intf_private.c -o \
intf/intf_private.o $(LIBPCAP_LDFLAGS) $(DYLIB_CFLAGS)
intf/intf_udp.o: intf/intf_udp.c
$(CC) $(CPPFLAGS) intf/intf_udp.c -o intf/intf_udp.o $(DYLIB_CFLAGS)
naclkeypair: naclkeypair.o
$(CC) -static -o naclkeypair naclkeypair.o $(LDFLAGS)
sigmavpn: main.o modules.o dep/ini.o
$(CC) -o sigmavpn main.o modules.o dep/ini.o $(LDFLAGS)
%.o: %.c $(HEADERS)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
else
# This part is for the original Makefile of SigmaVPN code
# It does make for the PC, with installed PCAP and libsodium libraries
# Regular commands reach to this part: make, make clean, make install
INSTALLDIR ?= /usr/local
BINDIR ?= $(INSTALLDIR)/bin
SYSCONFDIR ?= $(INSTALLDIR)/etc
LIBEXECDIR ?= $(INSTALLDIR)/lib/sigmavpn
SODIUM_CPPFLAGS ?= -I/usr/local/include
SODIUM_LDFLAGS ?= -L/usr/local/lib -lsodium
CFLAGS ?= -g3 -O2 -fPIC -Wall -Wextra
CPPFLAGS += -g3 -O2 $(SODIUM_CPPFLAGS)
LDFLAGS += $(SODIUM_LDFLAGS) -ldl -pthread
DYLIB_CFLAGS ?= $(CFLAGS) -shared
TARGETS_OBJS = dep/ini.o main.o modules.o naclkeypair.o pack.o tai.o
TARGETS_BIN = naclkeypair sigmavpn
TARGETS_MODULES = proto/proto_raw.o proto/proto_nacl0.o proto/proto_nacltai.o \
intf/intf_tuntap.o intf/intf_udp.o
#intf/intf_private.o
CC = gcc
TARGETS = $(TARGETS_OBJS) $(TARGETS_BIN) $(TARGETS_MODULES)
all: $(TARGETS)
clean:
rm -f $(TARGETS)
distclean: clean
install: all
mkdir -p $(BINDIR) $(SYSCONFDIR) $(LIBEXECDIR)
cp $(TARGETS_BIN) $(BINDIR)
cp $(TARGETS_MODULES) $(LIBEXECDIR)
proto/proto_raw.o: proto/proto_raw.c
$(CC) $(CPPFLAGS) $(SODIUM_CPPFLAGS) proto/proto_raw.c -o \
proto/proto_raw.o $(DYLIB_CFLAGS) $(SODIUM_LDFLAGS)
proto/proto_nacl0.o: proto/proto_nacl0.c pack.o
$(CC) $(CPPFLAGS) $(SODIUM_CPPFLAGS) proto/proto_nacl0.c pack.o -o \
proto/proto_nacl0.o $(DYLIB_CFLAGS) $(SODIUM_LDFLAGS)
proto/proto_nacltai.o: proto/proto_nacltai.c pack.o tai.o
$(CC) $(CPPFLAGS) $(SODIUM_CPPFLAGS) proto/proto_nacltai.c pack.o tai.o -o \
proto/proto_nacltai.o $(DYLIB_CFLAGS) $(SODIUM_LDFLAGS)
intf/intf_tuntap.o: intf/intf_tuntap.c
$(CC) $(CPPFLAGS) intf/intf_tuntap.c -o \
intf/intf_tuntap.o $(DYLIB_CFLAGS)
# intf/intf_private.o: intf/intf_private.c
# $(CC) $(CPPFLAGS) intf/intf_private.c -o \
# intf/intf_private.o -lpcap $(DYLIB_CFLAGS)
intf/intf_udp.o: intf/intf_udp.c
$(CC) $(CPPFLAGS) intf/intf_udp.c -o intf/intf_udp.o $(DYLIB_CFLAGS)
naclkeypair: naclkeypair.o
$(CC) -o naclkeypair naclkeypair.o $(LDFLAGS)
sigmavpn: main.o modules.o dep/ini.o
$(CC) -o sigmavpn main.o modules.o dep/ini.o $(LDFLAGS)
%.o: %.c $(HEADERS)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
endif