-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
368 lines (308 loc) · 6.87 KB
/
configure.ac
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# Initate configure.ac
AC_INIT(MID,[1.4],,,[https://github.com/m0hithreddy/MID])
# Safety check in case user overwritten --srcdir
AC_CONFIG_SRCDIR([src/MID.c])
AC_CONFIG_AUX_DIR([build-aux])
# Checks for source files and other important files
AC_CHECK_FILES(
[${srcdir}/src/MID.c
${srcdir}/src/MID.h
${srcdir}/src/MID_http.c
${srcdir}/src/MID_http.h
${srcdir}/src/MID_arguments.c
${srcdir}/src/MID_arguments.h
${srcdir}/src/MID_interfaces.c
${srcdir}/src/MID_interfaces.h
${srcdir}/src/MID_socket.c
${srcdir}/src/MID_socket.h
${srcdir}/src/MID_ssl_socket.c
${srcdir}/src/MID_ssl_socket.h
${srcdir}/src/MID_structures.c
${srcdir}/src/MID_structures.h
${srcdir}/src/MID_unit.c
${srcdir}/src/MID_unit.h
${srcdir}/src/MID_functions.c
${srcdir}/src/MID_functions.h
${srcdir}/src/MID_state.c
${srcdir}/src/MID_state.h
${srcdir}/src/MID_err.h
${srcdir}/src/url_parser.c
${srcdir}/src/url_parser.h
${srcdir}/src/Makefile.am
${srcdir}/Makefile.am
${srcdir}/MID.conf],
[],
[AC_MSG_ERROR([Repository corrupted, redownload the source.])]
)
# Checks for necessary programs
AC_PROG_CC
AC_PROG_SED
AC_PROG_INSTALL
AC_PROG_AWK
AC_PROG_LN_S
AC_PROG_MKDIR_P
AC_CHECK_PROG([TXT2MAN],[txt2man],[yes])
if test "x${TXT2MAN}" != "xyes" ; then
AC_MSG_NOTICE([txt2man not found, no support for building man pages])
fi
AM_CONDITIONAL([TXT2MAN], [test "x${TXT2MAN}" = "xyes"])
# Some predefined headers
AC_FUNC_MALLOC
# Checks for system headers
AC_CHECK_HEADERS(
[stdio.h \
stdlib.h \
stddef.h \
string.h \
unistd.h \
netdb.h \
fcntl.h \
netinet/in.h \
sys/socket.h \
sys/file.h \
sys/stat.h \
sys/types.h \
sys/select.h \
sys/signalfd.h \
sys/time.h \
arpa/inet.h \
limits.h \
bits/sockaddr.h \
arpa/inet.h \
ifaddrs.h \
linux/if_link.h \
errno.h \
time.h \
pthread.h \
signal.h \
ctype.h],
[],
[AC_MSG_ERROR([${ac_header} is required but not found. Headers provided by libc, installed by default in all distributions.])]
)
# Checks for system functions
AC_CHECK_FUNCS(
[printf \
strcmp \
getuid \
geteuid \
fprintf \
snprintf \
sprintf \
pwrite \
pread \
exit \
atoi \
atol \
strtol \
malloc \
calloc \
free \
strcpy \
strncpy \
strcat \
strlen \
strstr \
strcasestr \
strdup \
bzero \
fileno \
fopen \
fclose \
flock \
fstat \
lseek \
ftruncate \
remove \
time \
memcpy \
memset \
memcmp \
sleep \
read \
write \
fcntl \
select \
signalfd \
getifaddrs \
getnameinfo \
getaddrinfo \
htons \
inet_pton \
socket \
setsockopt \
bind \
connect \
close \
shutdown \
inet_ntop \
sigemptyset \
sigaddset \
sigwait \
sigtimedwait \
isalpha \
tolower],
[],
[AC_MSG_ERROR([${ac_func} is required but not found. Should be included in libc, check the libc variant installed in your system.])]
)
#Checks for optional system functions
AC_CHECK_FUNCS(
[memndup],
[],
[]
)
# Checks for system symbols
AC_CHECK_DECLS(
[NULL,
LONG_MAX,
LONG_MIN,
LOCK_EX,
LOCK_UN,
LOCK_NB,
SEEK_SET,
SIGINT,
SIGQUIT,
SIGRTMIN,
SIG_BLOCK,
F_GETFL,
F_SETFL,
FD_ZERO,
FD_SET,
FD_ISSET,
EAGAIN,
EWOULDBLOCK,
EINTR,
AF_INET,
AF_INET6,
SOCK_STREAM,
IPPROTO_TCP,
AI_ADDRCONFIG,
INET_ADDRSTRLEN,
INET6_ADDRSTRLEN],
[],
[AC_MSG_ERROR([Symbol required but not found. Should be included in libc, check the libc variant installed in your system.])],
[[#include<stddef.h>
#include<limits.h>
#include<sys/file.h>
#include<errno.h>
#include<netinet/in.h>
#include<fcntl.h>
#include<signal.h>
#include<netdb.h>]]
)
# Pthread library checks
AC_CHECK_LIB(pthread,pthread_create, [], [AC_MSG_ERROR([-lpthread is required but not found. Installed by default in all distributions])])
AC_CHECK_FUNCS(
[pthread_create \
pthread_join \
pthread_mutex_init \
pthread_mutex_lock \
pthread_mutex_unlock \
pthread_mutex_destroy \
pthread_kill \
pthread_sigmask],
[],
[AC_MSG_ERROR([${ac_func} required but not found. Function provided by libpthread, installed by default in all distributions])]
)
#SSL library checks
AC_ARG_WITH([ssl], AC_HELP_STRING([--without-ssl],[disable SSL support]), [], [with_ssl=yes])
if test "x${with_ssl}" == "xyes" ; then
AC_CHECK_LIB(crypto,BIO_new,, [])
AC_CHECK_LIB(ssl,SSL_new,, [], [-lcrypto] )
if test "x${ac_cv_lib_crypto_BIO_new}" == "xyes" && test "x${ac_cv_lib_ssl_SSL_new}" == "xyes" ; then
AC_CHECK_HEADERS(
[openssl/ssl.h \
openssl/err.h \
openssl/evp.h \
openssl/tls1.h \
openssl/md5.h],
[],
[ssl_header_not_found="yes"]
)
AC_CHECK_FUNCS(
[TLS_method \
SSL_CTX_new \
SSL_new \
SSL_set_fd \
SSL_connect \
SSL_write \
SSL_read \
MD5_Init \
MD5_Update \
MD5_Final \
SSL_get_error \
ERR_get_error],
[],
[ssl_func_not_found="yes"]
)
AC_CHECK_DECLS(
[SSL_library_init,
OpenSSL_add_all_algorithms,
SSL_load_error_strings,
SSL_set_tlsext_host_name,
MD5_DIGEST_LENGTH,
SSL_ERROR_WANT_READ,
SSL_ERROR_WANT_WRITE,
SSL_ERROR_SYSCALL,
SSL_ERROR_ZERO_RETURN],
[],
[ssl_symbol_not_found="yes"],
[[#include <openssl/ssl.h>
#include <openssl/evp.h>
#include <openssl/tls1.h>
#include<openssl/md5.h>]]
)
if test "x${ssl_header_not_found}" != "xyes" && test "x${ssl_func_not_found}" != "xyes" && test "x${ssl_symbol_not_found}" != "xyes" ; then
AC_DEFINE([LIBSSL_SANE],[1],["libssl installed and found all required headers, functions and symbols"])
AC_MSG_NOTICE([libssl and libcrytpo sane, enabling SSL support...])
else
AC_MSG_NOTICE([libssl and libcrypto are installed, but required headers or functions or symbols not found. Disabling the SSL support!])
fi
else
AC_MSG_NOTICE([libssl or libcrypto not found! Support for SSL is disabled, try installing libssl-dev or similar packages and recompile the source for enabling the SSL support])
fi
else
AC_MSG_NOTICE([Disabling SSL support as per user requested!])
fi
# Zlib checks
AC_ARG_WITH([z], AC_HELP_STRING([--without-z],[disable GZIP support]), [], [with_z=yes])
if test "x${with_z}" == "xyes" ; then
AC_CHECK_LIB(z,inflate,[],[AC_MSG_NOTICE([libz not found! Support for gzipped encodings is disabled, try installing zlib1g-dev or similar packages and recompile the source for enabling the GZIP support])])
if test "x${ac_cv_lib_z_inflate}" == "xyes" ; then
AC_CHECK_HEADERS(
[zlib.h],
[],
[zlib_header_not_found=yes])
AC_CHECK_FUNCS(
[inflate \
inflateEnd],
[],
[zlib_func_not_found=yes])
AC_CHECK_DECLS(
[inflateInit2,
Z_FINISH,
Z_DATA_ERROR,
Z_NEED_DICT,
Z_MEM_ERROR,
Z_STREAM_END],
[],
[zlib_symbol_not_found="yes"],
[[#include <zlib.h>]]
)
if test "x${zlib_header_not_found}" != "xyes" && test "x${zlib_func_not_found}" != "xyes" && test "x${zlib_symbol_not_found}" != "xyes" ; then
AC_DEFINE([LIBZ_SANE],[1],["libz installed and found all required headers, functions and symbols"])
AC_MSG_NOTICE([libz sane, enabling GZIP support...])
else
AC_MSG_NOTICE([libz installed, but required headers or functions or symbols not found. Disabling the GZIP support!])
fi
fi
else
AC_MSG_NOTICE([Disabling GZIP support as per user requested!])
fi
# System Architecture
AC_CANONICAL_HOST
AC_DEFINE_UNQUOTED([HOST_ARCH], ["$host_os"], ["Host architecture"])
# Conclude configure.ac
AM_INIT_AUTOMAKE([subdir-objects])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_HEADERS([config.h])
AC_OUTPUT