-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
179 lines (158 loc) · 6.84 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
PREFIX?=/usr/local
WITH_TCP_NODELAY?=1
WITH_LIBSSH2?=0
CPATH+=
LDLIBS+=
LDFLAGS+=
USER?=
CC=cc
CFLAGS += -O3 -Wall -DPREFIX='"$(PREFIX)"' -DWITH_TCP_NODELAY=$(WITH_TCP_NODELAY) -DWITH_LIBSSH2=$(WITH_LIBSSH2) $(CPATH)
WARP_OBJS = base64.o inifile.o logfile.o natlook.o network.o pidfile.o pidlist.o ssh2.o socks.o http.o ts-warp.o \
utility.o xedec.o
PASS_OBJS = ts-pass.o xedec.o
.PHONY: all clean examples-general examples-special install install-configs install-examples release \
deinstall uninstall version
all: ts-warp examples-special ts-pass
release: version all
version:
sh ./version.sh RELEASE
ts-warp: $(WARP_OBJS)
$(CC) $(CFLAGS) $(WARP_OBJS) $(LDFLAGS) $(LDLIBS) -o $@
ts-warp.sh:
sed 's|tswarp_prefix=.*|tswarp_prefix="$(PREFIX)"|' ts-warp.sh.in > ts-warp.sh
ts-warp_autofw.sh:
sed 's|tswarp_prefix=.*|tswarp_prefix="$(PREFIX)"|' ts-warp_autofw.sh.in > ts-warp_autofw.sh
examples-general:
sed "s|%USER%|$(USER)|" ./examples/ts-warp_general_iptables.sh.in > ./examples/ts-warp_iptables.sh
sed "s|%USER%|$(USER)|" ./examples/ts-warp_general_nftables.sh.in > ./examples/ts-warp_nftables.sh
sed "s|%USER%|$(USER)|" ./examples/ts-warp_general_pf_freebsd.conf.in > ./examples/ts-warp_pf_freebsd.conf
sed "s|%USER%|$(USER)|" ./examples/ts-warp_general_pf_macos.conf.in > ./examples/ts-warp_pf_macos.conf
sed "s|%USER%|$(USER)|" ./examples/ts-warp_general_pf_openbsd.conf.in > ./examples/ts-warp_pf_openbsd.conf
examples-special:
sed "s|%USER%|$(USER)|" ./examples/ts-warp_special_iptables.sh.in > ./examples/ts-warp_iptables.sh
sed "s|%USER%|$(USER)|" ./examples/ts-warp_special_nftables.sh.in > ./examples/ts-warp_nftables.sh
sed "s|%USER%|$(USER)|" ./examples/ts-warp_special_pf_freebsd.conf.in > ./examples/ts-warp_pf_freebsd.conf
sed "s|%USER%|$(USER)|" ./examples/ts-warp_special_pf_macos.conf.in > ./examples/ts-warp_pf_macos.conf
sed "s|%USER%|$(USER)|" ./examples/ts-warp_special_pf_openbsd.conf.in > ./examples/ts-warp_pf_openbsd.conf
ts-pass: $(PASS_OBJS)
$(CC) -o $@ $(PASS_OBJS)
install-examples:
# -------------------------------------------------------------------------------------------------------------------- #
# Examples (special version) are installed by default #
# -------------------------------------------------------------------------------------------------------------------- #
@[ -f .configured ] || { echo "FATAL: run \"make all\" command first!"; exit 1; }
install -d $(PREFIX)/etc/
install -m 644 ./examples/ts-warp.ini $(PREFIX)/etc/ts-warp.ini.sample
touch $(PREFIX)/etc/ts-warp.ini
chmod 640 $(PREFIX)/etc/ts-warp.ini
@case `uname -s` in \
Darwin) \
install -m 644 ./examples/ts-warp_pf_macos.conf $(PREFIX)/etc/ts-warp_pf.conf.sample; \
touch $(PREFIX)/etc/ts-warp_pf.conf \
;; \
FreeBSD) \
install -m 644 ./examples/ts-warp_pf_freebsd.conf $(PREFIX)/etc/ts-warp_pf.conf.sample; \
touch $(PREFIX)/etc/ts-warp_pf.conf \
;; \
OpenBSD) \
install -m 644 ./examples/ts-warp_pf_openbsd.conf $(PREFIX)/etc/ts-warp_pf.conf.sample; \
touch $(PREFIX)/etc/ts-warp_pf.conf \
;; \
Linux) \
install -m 755 ./examples/ts-warp_iptables.sh $(PREFIX)/etc/ts-warp_iptables.sh.sample; \
install -m 755 ./examples/ts-warp_nftables.sh $(PREFIX)/etc/ts-warp_nftables.sh.sample; \
touch $(PREFIX)/etc/ts-warp_iptables.sh $(PREFIX)/etc/ts-warp_nftables.sh \
;; \
*) \
echo "Unsupported OS" \
;; \
esac
install-configs:
# -------------------------------------------------------------------------------------------------------------------- #
# Danger zone! The targer is not run by default, it overwrites INSTALLED configuration files #
# -------------------------------------------------------------------------------------------------------------------- #
@[ -f .configured ] || { echo "FATAL: run \"make all\" command first!"; exit 1; }
install -d $(PREFIX)/etc/
install -b -m 640 ./examples/ts-warp.ini $(PREFIX)/etc/ts-warp.ini
@case `uname -s` in \
Darwin) \
install -b -m 644 ./examples/ts-warp_pf_macos.conf $(PREFIX)/etc/ts-warp_pf.conf \
;; \
FreeBSD) \
install -b -m 644 ./examples/ts-warp_pf_freebsd.conf $(PREFIX)/etc/ts-warp_pf.conf \
;; \
OpenBSD) \
install -b -m 644 ./examples/ts-warp_pf_openbsd.conf $(PREFIX)/etc/ts-warp_pf.conf \
;; \
Linux) \
install -b -m 755 ./examples/ts-warp_nftables.sh $(PREFIX)/etc/ts-warp_nftables.sh; \
install -b -m 755 ./examples/ts-warp_iptables.sh $(PREFIX)/etc/ts-warp_iptables.sh \
;; \
*) \
echo "Unsupported OS" \
;; \
esac
install: ts-warp.sh ts-warp_autofw.sh ts-pass install-examples
@[ -f .configured ] || { echo "FATAL: run \"make all\" command first!"; exit 1; }
chown "`cat .configured`" $(PREFIX)/etc/ts-warp*
install -d $(PREFIX)/bin/
install -m 755 -s ts-warp $(PREFIX)/bin/
install -m 755 -s ts-pass $(PREFIX)/bin/
install -m 755 ts-warp_autofw.sh $(PREFIX)/bin/
install -d $(PREFIX)/etc/
install -m 755 ts-warp.sh $(PREFIX)/etc/
install -d $(PREFIX)/var/log/
install -d $(PREFIX)/var/run/
install -d $(PREFIX)/var/spool/ts-warp/
install -d $(PREFIX)/man/
install -d $(PREFIX)/man/man1/
install -d $(PREFIX)/man/man5/
install -d $(PREFIX)/man/man8/
install -m 755 man/ts-pass.1 $(PREFIX)/man/man1
install -m 755 man/ts-warp.sh.1 $(PREFIX)/man/man1
install -m 755 man/ts-warp.5 $(PREFIX)/man/man5
install -m 755 man/ts-warp.8 $(PREFIX)/man/man8
install -d $(PREFIX)/share/
install -d $(PREFIX)/share/ts-warp/
install -m 644 CHANGELOG.md $(PREFIX)/share/ts-warp
install -m 644 CONTRIBUTORS.md $(PREFIX)/share/ts-warp
install -m 644 LICENSE $(PREFIX)/share/ts-warp
install -m 644 README.md $(PREFIX)/share/ts-warp
deinstall: uninstall
uninstall:
rm -f $(PREFIX)/bin/ts-warp
rm -f $(PREFIX)/bin/ts-pass
rm -f $(PREFIX)/bin/ts-warp_autofw.sh
rm -f $(PREFIX)/etc/ts-warp.sh
rm -f $(PREFIX)/etc/ts-warp.ini.sample
rm -f $(PREFIX)/etc/ts-warp_pf_openbsd.conf.sample
rm -f $(PREFIX)/etc/ts-warp_pf_freebsd.conf.sample
rm -f $(PREFIX)/etc/ts-warp_pf_macos.conf.sample
rm -f $(PREFIX)/etc/ts-warp_nftables.sh.sample
rm -f $(PREFIX)/etc/ts-warp_iptables.sh.sample
rm -f $(PREFIX)/var/log/ts-warp.log
rm -f $(PREFIX)/var/run/ts-warp.pid
rm -f $(PREFIX)/man/man1/ts-pass.1
rm -f $(PREFIX)/man/man1/ts-warp.sh.1
rm -f $(PREFIX)/man/man5/ts-warp.5
rm -f $(PREFIX)/man/man8/ts-warp.8
rm -f $(PREFIX)/share/ts-warp/CHANGELOG.md
rm -f $(PREFIX)/share/ts-warp/CONTRIBUTORS.md
rm -f $(PREFIX)/share/ts-warp/LICENSE
rm -f $(PREFIX)/share/ts-warp/README.md
rmdir $(PREFIX)/share/ts-warp/
clean:
rm -rf ts-warp ts-warp.sh ts-warp_autofw.sh ts-pass *.o *.dSYM *.core examples/*.conf examples/*.sh .configured
base64.o: base64.h
inifile.o: inifile.h
natlook.o: natlook.h
network.o: network.h
logfile.o: logfile.h
pidfile.o: pidfile.h
pidlist.o: pidlist.h
socks.o: socks.h
http.o: http.h
ssh2.o: ssh2.h
ts-warp.o: ts-warp.h
utility.o: utility.h
xedec.o: xedec.h