forked from jsuto/piler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.in
487 lines (345 loc) · 11.3 KB
/
configure.in
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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
AC_INIT
AC_CONFIG_SRCDIR([src/piler.c])
AC_CONFIG_HEADERS([piler-config.h])
CONFIGURE_PARAMS_FILE=params.h
PARAMS=$@
dnl Checks for programs.
AC_PROG_CC
dnl AM_PROG_CC_STDC
AC_PROG_MAKE_SET
AC_PROG_INSTALL
dnl Checks for header files.
AC_CHECK_HEADERS(sys/socket.h sys/time.h syslog.h signal.h ctype.h unistd.h)
AC_SUBST(defs)
AC_SUBST(INCDIR)
AC_SUBST(LIBDIR)
AC_SUBST(OBJS)
AC_SUBST(RUNNING_USER)
AC_SUBST(SUBDIRS)
AC_SUBST(MAKE)
AC_SUBST(sql_includes)
AC_SUBST(sql_libs)
AC_SUBST(sql_obj)
AC_SUBST(libclamav_extra_libs)
AC_SUBST(id_bin)
AC_SUBST(iv)
have_libclamav="no"
have_libtool="no"
have_clamd="no"
have_antivirus="no"
have_mysql="no"
have_psql="no"
have_tre="no"
have_zip="no"
have_zlib="no"
have_tweak_sent_time="no"
database=""
pdftotext="no"
catdoc="no"
catppt="no"
ppthtml="no"
xls2csv="no"
unrtf="no"
tnef="no"
timeout_binary=""
have_static_build="no"
have_compat_storage_layout="no"
antispam_libs="-lz -lm -ldl -lcrypto -lssl"
defs=""
objs=""
user_obj=""
sql_obj=""
os=`uname -s`
id_bin="id"
MAKE="make"
if test "$os" = "SunOS"; then MAKE="gmake"; fi
rm -f $CONFIGURE_PARAMS_FILE
LDD_VERSION=`ldd --version | head -1`
GCC_VERSION=''
if test -f `which gcc`; then gcc -v 2> aa; GCC_VERSION=`tail -1 aa`; rm -f aa; fi
if test "$os" = "SunOS"; then
echo "#define CONFIGURE_PARAMS \"Build Date: "`date`'\\n" \\' > $CONFIGURE_PARAMS_FILE
else
echo "#define CONFIGURE_PARAMS \"Build Date: "`date`"\\nldd version: $LDD_VERSION\\ngcc version: $GCC_VERSION\\nOS: "`uname -a`"\n"\" \\ > $CONFIGURE_PARAMS_FILE
fi
echo "\"Configure command: ./configure $PARAMS\"" >> $CONFIGURE_PARAMS_FILE
SUBDIRS="src etc util init.d systemd unit_tests webui"
dnl static build
AC_ARG_ENABLE(static-build,
[ --enable-static-build build statically linked executables (default: dynamically linked)], have_static_build=$enableval, have_static_build="no")
dnl
AC_ARG_ENABLE(compat-layout,
[ --enable-compat-layout support for older storage layout (default: no)], have_compat_storage_layout=$enableval, have_compat_storage_layout="no")
dnl clamd
AC_ARG_ENABLE(clamd,
[ --enable-clamd build clamd antivirus support], want_clamd=$enableval, want_clamd="no")
if test "$want_clamd" = "yes"; then
have_clamd="yes"
have_antivirus="yes"
fi
AC_ARG_ENABLE(memcached,
[ --enable-memcached build memcached support], want_memcached=$enableval, want_memcached="no")
AC_ARG_ENABLE(tweak-sent-time,
[ --tweak-sent-time tweak sent time], have_tweak_sent_time=$enableval, have_tweak_sent_time="no")
dnl math library
AC_CHECK_HEADERS(math.h, have_math=yes, have_math=no)
AC_CHECK_LIB([m],[fabs],[AC_CHECK_LIB(m, fabs)],[have_math=yes],[""; exit])ac_cv_lib_m=ac_cv_lib_m_main
dnl openssl library
AC_CHECK_HEADERS(openssl/sha.h, have_crypto=yes, have_crypto=no)
AC_CHECK_LIB([crypto],[SHA256_Init],[AC_CHECK_LIB(crypto, SHA256_Init, have_crypto=yes, echo "libcrypto is not found"; have_crypto=no)],[],[])ac_cv_lib_crypto=ac_cv_lib_crypto_main
AC_CHECK_HEADERS(openssl/ssl.h, have_ssl=yes, have_ssl=no)
AC_CHECK_LIB([ssl],[SSL_write],[AC_CHECK_LIB(ssl, SSL_write, have_ssl=yes, echo "libssl is not found"; have_ssl=no)],[],[])ac_cv_lib_ssl=ac_cv_lib_ssl_main
if test "$have_crypto" = "no" || test "$have_ssl" = "no"; then
echo "please install openssl developer package"
exit 1
fi
dnl TRE library
AC_CHECK_HEADERS(tre/tre.h, have_tre=yes, echo "tre.h is not found")
AC_CHECK_LIB([tre],[main],[AC_CHECK_LIB(tre, regcomp, have_tre=yes, echo "libtre.so is not found"; have_tre=no)],[],[])ac_cv_lib_tre=ac_cv_lib_tre_main
if test "$have_tre" = "no"; then
echo "please install the tre development packages"
exit 1;
fi
dnl libzip
AC_CHECK_HEADERS(zip.h, have_zip=yes, echo "zip.h is not found")
AC_CHECK_LIB([zip],[main],[AC_CHECK_LIB(zip, zip_open, have_zip=yes, echo "libzip.so is not found"; have_zip=no)],[],[])ac_cv_lib_zip=ac_cv_lib_zip_main
dnl zlib
AC_CHECK_HEADERS(zlib.h, have_zlib=yes, echo "zlib.h is not found")
AC_CHECK_LIB([z],[main],[AC_CHECK_LIB(z, compress, have_zlib=yes, echo "libz.so is not found"; have_zlib=no)],[],[])ac_cv_lib_z=ac_cv_lib_z_main
if test "$have_zlib" = "no"; then
echo "please install the zlib development packages"
exit 1;
fi
AC_CHECK_PROG(MYSQL_CONFIG, mariadb_config, yes)
if test x$MYSQL_CONFIG = xyes; then
have_mysql="yes"
fi
if test "$have_mysql" = "yes"; then
sql_includes=`mariadb_config --cflags`
sql_libs=`mariadb_config --libs_r`
sql_obj="mysql.o"
database="mariadb"
echo "Found mariadb"
fi
if test "$have_mysql" = "no"; then
AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, yes)
if test x$MYSQL_CONFIG = xyes; then
have_mysql="yes"
fi
if test "$have_mysql" = "yes"; then
sql_includes=`mysql_config --cflags`
sql_libs=`mysql_config --libs_r`
sql_obj="mysql.o"
database="mysql"
echo "Found mysql"
fi
fi
if test "$have_mysql" = "no"; then
echo "MySQL support is not found"
exit 1
fi
dnl timeout binary
if test z`which timeout 2>/dev/null` != "z"; then
timeout_binary=`which timeout`
AC_DEFINE_UNQUOTED(TIMEOUT_BINARY, "$timeout_binary", [timeout binary])
fi
read -r version < VERSION
AC_DEFINE_UNQUOTED(VERSION, "$version" COMMIT_HASH )
dnl user running piler
AC_ARG_WITH(piler-user,
[ --with-piler-user=username what user the piler daemon shall be run as],
[ RUNNING_USER=$withval ],
[ RUNNING_USER=piler ]
)
dnl configure config directory
cfg_dir=`echo $sysconfdir | grep prefix`
if test -n "$cfg_dir"; then
if test "$prefix" = "NONE"
then
cfg_dir="$ac_default_prefix/etc"
my_prefix=$ac_default_prefix
else
cfg_dir="$prefix/etc"
my_prefix=$prefix
fi
else
cfg_dir="$sysconfdir"
fi
CFGDIR=$cfg_dir
AC_SUBST(CFGDIR)
AC_DEFINE_UNQUOTED(CONFDIR,"$cfg_dir",[where to look for the config file])
dnl configure data directory
data_dir=`echo $localstatedir | grep prefix`
if test -n "$data_dir"; then
if test "$prefix" = "NONE"
then
data_dir="$ac_default_prefix/var"
else
data_dir="$prefix/var"
fi
else
data_dir="$localstatedir"
fi
DATADIR=$data_dir
AC_SUBST(DATADIR)
AC_DEFINE_UNQUOTED(DATADIR,"$data_dir",[where to look for the data files])
dnl configure libexec directory
libexec_dir=`echo $libexecdir | grep prefix`
if test -n "$libexec_dir"; then
if test "$prefix" = "NONE"
then
libexec_dir="$ac_default_prefix/libexec"
else
libexec_dir="$prefix/libexec"
fi
else
libexec_dir="$libexecdir"
fi
LIBEXECDIR=$libexec_dir
AC_SUBST(LIBEXECDIR)
AC_DEFINE_UNQUOTED(LIBEXECDIR,"$libexec_dir",[where to look for the piler helpers])
dnl configure dataroot directory
dataroot_dir=`echo $datarootdir | grep prefix`
if test -n "$dataroot_dir"; then
if test "$prefix" = "NONE"
then
dataroot_dir="$ac_default_prefix/share"
else
dataroot_dir="$prefix/share"
fi
else
dataroot_dir="$datarootdir"
fi
DATAROOTDIR=$dataroot_dir
AC_SUBST(DATAROOTDIR)
AC_DEFINE_UNQUOTED(DATAROOTDIR,"$dataroot_dir",[where to look for the share data files])
dnl let us know if we are building on FreeBSD
if test "$os" = "FreeBSD"; then
defs="$defs -DFREEBSD"
antispam_libs="-lz -lm -lcrypto -lssl -liconv"
MAKE="gmake"
fi
if test "$os" = "Linux"; then
defs="$defs -D_GNU_SOURCE"
fi
if test "$os" = "SunOS"; then
AC_DEFINE(HAVE_DAEMON, 0, [daemon() support])
sunos_libs="-lnsl -lsocket"
if test -x /usr/xpg4/bin/id; then id_bin="/usr/xpg4/bin/id"; fi
fi
dnl whether we have antivirus support
if test "$have_clamd" = "yes" ; then
defs="$defs -DHAVE_ANTIVIRUS"
objs="$objs avir.o"
fi
echo; echo
echo "run as user: $RUNNING_USER"
echo "piler data directory: $data_dir/piler"
if test "$have_static_build" = "yes"; then
echo "link mode: static"
static="-static"
else
echo "link mode: dynamic"
fi
echo
if test "$have_compat_storage_layout" = "yes"; then
echo "support for older storage layout: yes"
AC_DEFINE_UNQUOTED(HAVE_SUPPORT_FOR_COMPAT_STORAGE_LAYOUT, 1, [compat storage layout support])
fi
if test "$have_mysql" = "yes"; then
echo "database: $database"
fi
if test "$have_tre" = "yes"; then
echo "tre library: yes"
defs="$defs -DHAVE_TRE"
antispam_libs="$antispam_libs -ltre"
fi
if test "$have_zip" = "yes"; then
echo "zip library: yes"
AC_DEFINE_UNQUOTED(HAVE_ZIP, 1, [libzip support])
antispam_libs="$antispam_libs -lzip"
else
echo "zip library: no"
fi
echo
if test "$have_clamd" = "yes"; then
echo "clamd support: yes"
objs="$objs clamd.o"
defs="$defs -DHAVE_CLAMD"
fi
if test "$want_memcached" = "yes"; then
echo "memcached support: yes"
objs="$objs memc.o"
defs="$defs -DHAVE_MEMCACHED"
fi
if test "$have_mysql" = "yes"; then
defs="$defs -DNEED_MYSQL"
fi
if test "$have_icc_guide" = "yes" && test "$have_mysql" = "yes"; then
sql_libs="$sql_libs -lguide"
fi
if test "$have_psql" = "yes"; then
defs="$defs -DNEED_PSQL"
fi
if test z`which pdftotext 2>/dev/null` != "z"; then
pdftotext=`which pdftotext`
AC_DEFINE_UNQUOTED(HAVE_PDFTOTEXT, "$pdftotext", [path to pdftotext])
fi
if test z`which catdoc 2>/dev/null` != "z"; then
catdoc=`which catdoc`
AC_DEFINE_UNQUOTED(HAVE_CATDOC, "$catdoc", [path to catdoc])
fi
if test z`which catppt 2>/dev/null` != "z"; then
catppt=`which catppt`
AC_DEFINE_UNQUOTED(HAVE_CATPPT, "$catppt", [path to catppt])
fi
if test z`which ppthtml 2>/dev/null` != "z"; then
ppthtml=`which ppthtml`
AC_DEFINE_UNQUOTED(HAVE_PPTHTML, "$ppthtml", [path to ppthtml])
fi
if test z`which xls2csv 2>/dev/null` != "z"; then
xls2csv=`which xls2csv`
AC_DEFINE_UNQUOTED(HAVE_XLS2CSV, "$xls2csv", [path to xls2csv])
fi
if test z`which unrtf 2>/dev/null` != "z"; then
unrtf=`which unrtf`
AC_DEFINE_UNQUOTED(HAVE_UNRTF, "$unrtf", [path to unrtf])
fi
if test z`which tnef 2>/dev/null` != "z"; then
tnef=`which tnef`
AC_DEFINE_UNQUOTED(HAVE_TNEF, "$tnef", [path to tnef])
fi
if test "$have_tweak_sent_time" = "yes"; then
AC_DEFINE_UNQUOTED(HAVE_TWEAK_SENT_TIME, 1, [tweak sent time])
fi
echo
echo "pdftotext: $pdftotext"
echo "catdoc: $catdoc"
echo "catppt: $catppt"
echo "ppthtml: $ppthtml"
echo "xls2csv: $xls2csv"
echo "unrtf: $unrtf"
echo "tnef: $tnef"
id -u $RUNNING_USER 2>/dev/null 1>/dev/null
if test $? -eq 1; then echo "the user \"$RUNNING_USER\" does not exists, please create it, first with adduser..."; fi
echo; echo
gcc_version="$(gcc -dumpversion)"
extra_cflags=""
if [[ "${gcc_version:0:1}" -gt 6 ]]; then
extra_cflags="-Wimplicit-fallthrough=2"
fi
CFLAGS="$static -std=c99 -O2 -fPIC -Wall -Wextra $extra_cflags -Wuninitialized -Wimplicit-fallthrough=2 -Wno-format-truncation -g"
LIBS="$antispam_libs $sunos_libs "
OBJS="dirs.o misc.o counters.o cfg.o sig.o decoder.o hash.o parser.o parser_utils.o rules.o smtp.o session.o bdat.o message.o attachment.o digest.o store.o archive.o tai.o import.o import_pilerexport.o import_maildir.o import_mailbox.o import_pop3.o import_imap.o imap.o pop3.o extract.o mydomains.o tokenizer.o screen.o $objs"
AC_CONFIG_FILES([Makefile src/Makefile etc/Makefile util/Makefile init.d/Makefile systemd/Makefile unit_tests/Makefile webui/Makefile contrib/imap/Makefile])
AC_OUTPUT
echo
echo
echo "IMPORTANT! If you upgrade, be sure to read https://www.mailpiler.org/upgrade-instructions/"
echo
echo
echo
echo "Did you know that piler has an enterprise edition as well?"
echo "Check out what it can do for you at https://mailpiler.com/#features"
echo
echo