-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
208 lines (171 loc) · 7.61 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#
# UFTP - UDP based FTP with multicast
#
# Copyright (C) 2001-2017 Dennis A. Bush, Jr. [email protected]
#
# This program 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.
#
# This program 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/>.
#
# Additional permission under GNU GPL version 3 section 7
#
# If you modify this program, or any covered work, by linking or
# combining it with the OpenSSL project's OpenSSL library (or a
# modified version of that library), containing parts covered by the
# terms of the OpenSSL or SSLeay licenses, the copyright holder
# grants you additional permission to convey the resulting work.
# Corresponding Source for a non-source form of such a combination
# shall include the source code for the parts of OpenSSL used as well
# as that of the covered work.
#
UNAME_S:=$(shell uname -s)
# default encryption none
NO_ENCRYPTION=1
ifdef NO_ENCRYPTION
ENC_OPTS=-DNO_ENCRYPTION
CRYPT_LIB=
else
ENC_OPTS=
CRYPT_LIB=-lcrypto
endif
# defaults
OPTIONS=-g -Wall $(ENC_OPTS)
LDLIBS=-lc -lm $(CRYPT_LIB)
MTFLAGS=
# FreeBSD
ifeq ("FreeBSD", "$(UNAME_S)")
OPTIONS=-g -Wall -DHAS_GETIFADDRS -DNO_DUAL -DSOCKADDR_LEN $(ENC_OPTS)
endif
# OSX, aka Darwin
ifeq ("Darwin", "$(UNAME_S)")
OPTIONS=-g -Wall -DHAS_GETIFADDRS $(ENC_OPTS)
endif
# Sun
ifeq ("SunOS", "$(UNAME_S)")
CC = cc
OPTIONS=-g -DBSD_COMP -DNO_DUAL -DNO_RECVMSG $(ENC_OPTS)
LDLIBS=-lnsl -lsocket -lm $(CRYPT_LIB)
CFLAGS+=`getconf LFS_CFLAGS`
OPENSSL=/usr/sfw
MTFLAGS=-mt
endif
# Linux
ifeq ("Linux", "$(UNAME_S)")
OPTIONS=-g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wformat=2 -Wwrite-strings -Wpointer-arith -Wcast-qual -Wshadow -Wno-missing-field-initializers -Wstrict-prototypes -Winline -Wbad-function-cast -DHAS_GETIFADDRS $(ENC_OPTS)
LDLIBS=-lm $(CRYPT_LIB)
CFLAGS+=`getconf LFS_CFLAGS`
endif
ifdef OPENSSL
INCLUDE=-I $(OPENSSL)/include
LIB=-L $(OPENSSL)/lib
endif
all: uftp uftpd uftpproxyd uftp_keymgt
test: testclient_multi
testclient_multi.o: testclient_multi.c uftp.h uftp_common.h encryption.h
testclient_multi: testclient_multi.o encrypt_openssl.o uftp_common.o
$(CC) $(OPTIONS) $(LIB) -o $@ $^ $(LDLIBS)
clean:
rm -f testclient_multi uftp uftpd uftpproxyd uftp_keymgt *.o
client_announce.o: client_announce.c client.h uftp_common.h uftp.h \
encryption.h client_common.h client_announce.h
client_common.o: client_common.c client.h uftp_common.h uftp.h \
encryption.h client_common.h
client_config.o: client_config.c client.h uftp_common.h uftp.h \
encryption.h client_config.h
client_fileinfo.o: client_fileinfo.c client.h uftp_common.h uftp.h \
encryption.h client_common.h client_fileinfo.h client_transfer.h
client_init.o: client_init.c client.h uftp_common.h uftp.h encryption.h \
client_init.h client_config.h client_common.h
client_loop.o: client_loop.c client.h uftp_common.h uftp.h encryption.h \
client_common.h client_loop.h client_announce.h client_fileinfo.h \
client_transfer.h heartbeat_send.h
client_main.o: client_main.c client_config.h client_init.h client_loop.h
client_transfer.o: client_transfer.c client.h uftp_common.h uftp.h \
encryption.h client_common.h client_transfer.h
server_announce.o: server_announce.c server.h uftp_common.h uftp.h \
encryption.h server_common.h server_announce.h
server_common.o: server_common.c server.h uftp_common.h uftp.h \
encryption.h server_common.h
server_config.o: server_config.c server.h uftp_common.h uftp.h \
encryption.h server_config.h
server_init.o: server_init.c server.h uftp_common.h uftp.h encryption.h \
server_config.h server_init.h
server_main.o: server_main.c server_config.h server_init.h server_send.h
server_phase.o: server_phase.c server.h uftp_common.h uftp.h encryption.h \
server_config.h server_common.h server_announce.h server_transfer.h
server_send.o: server_send.c server.h uftp_common.h uftp.h encryption.h \
server_send.h server_phase.h server_common.h
server_transfer.o: server_transfer.c server.h uftp_common.h uftp.h \
encryption.h server_common.h server_transfer.h
proxy_common.o: proxy_common.c proxy.h uftp_common.h uftp.h encryption.h \
proxy_common.h proxy_upstream.h
proxy_config.o: proxy_config.c proxy.h uftp_common.h uftp.h encryption.h \
proxy_config.h
proxy_downstream.o: proxy_downstream.c proxy.h uftp_common.h uftp.h \
encryption.h proxy_common.h proxy_downstream.h
proxy_init.o: proxy_init.c proxy.h uftp_common.h uftp.h encryption.h \
proxy_init.h proxy_config.h proxy_common.h
proxy_loop.o: proxy_loop.c proxy.h uftp_common.h uftp.h encryption.h \
proxy_common.h proxy_loop.h proxy_upstream.h proxy_downstream.h \
heartbeat_send.h
proxy_main.o: proxy_main.c proxy_config.h proxy_init.h proxy_loop.h
proxy_upstream.o: proxy_upstream.c proxy.h uftp_common.h uftp.h \
encryption.h proxy_common.h proxy_upstream.h proxy_downstream.h
uftp_keymgt.o: uftp_keymgt.c uftp_common.h uftp.h encryption.h
encrypt_openssl.o: encrypt_openssl.c uftp_common.h uftp.h encryption.h
encrypt_none.o: encrypt_none.c encryption.h
uftp_common.o: uftp_common.c uftp.h uftp_common.h encryption.h
heartbeat_send.o: heartbeat_send.c uftp_common.h uftp.h encryption.h \
heartbeat_send.h
ifdef NO_ENCRYPTION
UFTP_OBJS=uftp_common.o encrypt_none.o \
server_announce.o server_transfer.o server_send.o server_phase.o \
server_common.o server_config.o server_init.o server_main.o
UFTPD_OBJS=uftp_common.o encrypt_none.o \
client_loop.o client_announce.o client_fileinfo.o client_transfer.o \
client_common.o client_config.o client_init.o client_main.o heartbeat_send.o
UFTPPROXYD_OBJS=uftp_common.o encrypt_none.o \
proxy_loop.o proxy_upstream.o proxy_downstream.o \
proxy_common.o proxy_config.o proxy_init.o proxy_main.o heartbeat_send.o
UFTP_KEYMGT_OBJS=uftp_keymgt.o uftp_common.o encrypt_none.o
else
UFTP_OBJS=uftp_common.o encrypt_openssl.o \
server_announce.o server_transfer.o server_send.o server_phase.o \
server_common.o server_config.o server_init.o server_main.o
UFTPD_OBJS=uftp_common.o encrypt_openssl.o \
client_loop.o client_announce.o client_fileinfo.o client_transfer.o \
client_common.o client_config.o client_init.o client_main.o heartbeat_send.o
UFTPPROXYD_OBJS=uftp_common.o encrypt_openssl.o \
proxy_loop.o proxy_upstream.o proxy_downstream.o \
proxy_common.o proxy_config.o proxy_init.o proxy_main.o heartbeat_send.o
UFTP_KEYMGT_OBJS=uftp_keymgt.o uftp_common.o encrypt_openssl.o
endif
uftp: $(UFTP_OBJS)
$(CC) $(LDFLAGS) $(OPTIONS) $(LIB) -o $@ $^ $(LDLIBS) $(MTFLAGS) -lpthread
uftpd: $(UFTPD_OBJS)
$(CC) $(LDFLAGS) $(OPTIONS) $(LIB) -o $@ $^ $(LDLIBS)
uftpproxyd: $(UFTPPROXYD_OBJS)
$(CC) $(LDFLAGS) $(OPTIONS) $(LIB) -o $@ $^ $(LDLIBS)
uftp_keymgt: $(UFTP_KEYMGT_OBJS)
$(CC) $(LDFLAGS) $(OPTIONS) $(LIB) -o $@ $^ $(LDLIBS)
android:
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk APP_ABI="arm64-v8a"
%.o: %.c
$(CC) $(CPPFLAGS) $(OPTIONS) $(INCLUDE) $(CFLAGS) $(MTFLAGS) -c $<
install: all
install -m 755 -d $(DESTDIR)/usr/bin
install -m 755 -d $(DESTDIR)/usr/share/man/man1
install -m 755 uftp $(DESTDIR)/usr/bin
install -m 755 uftpd $(DESTDIR)/usr/bin
install -m 755 uftpproxyd $(DESTDIR)/usr/bin
install -m 755 uftp_keymgt $(DESTDIR)/usr/bin
install -m 644 uftp.1 uftpd.1 uftpproxyd.1 uftp_keymgt.1 $(DESTDIR)/usr/share/man/man1