-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure.in
472 lines (411 loc) · 12.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
dnl
dnl Autoconf configuration for squidGuard
dnl
AC_INIT(src/main.c)
AC_CONFIG_HEADER(src/config.h)
dnl
dnl Checks for programs.
dnl
AC_PROG_CC
AC_PROG_CPP
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_PROG_YACC
AC_PROG_LEX
AC_PATH_PROG(LYNX,lynx,false,$PATH:/usr/bin:/usr/local/bin/:/local/bin:/local/perl/bin:/usr/local/perl/bin)
AC_PATH_PROG(PERL,perl,no,$PATH:/usr/bin:/usr/local/bin/:/local/bin:/local/perl/bin:/usr/local/perl/bin)
if test $PERL = no; then
echo
echo "** No Perl found in the PATH. Perl is required"
echo " for blocked.cgi to work "
echo
fi
squiduser=squid
NOLOG1=
NOLOG2=
ldap_yacc=""
sg_config=/usr/local/squidGuard/squidGuard.conf
sg_dbhome=/usr/local/squidGuard/db
sg_logdir=/usr/local/squidGuard/log
sg_cfgdir=/usr/local/squidGuard
dbprefix=/usr/local
default_directory="/usr /usr/local"
db_lib=-L$dbprefix/BerkeleyDB/lib
db_inc=-I$dbprefix/BerkeleyDB/include
AC_DEFUN(FAIL_MESSAGE,[
echo
echo
echo "**********************************************"
echo " ERROR: unable to find" $1
echo " checked in the following places"
echo " "
echo " /usr /usr/local"
echo " "
echo "**********************************************"
echo
exit 1
])
dnl
dnl Handle command line arguments
dnl
AC_ARG_WITH(db,
[ --with-db=DIR location of the Berkley DB distribution],
db_distribution=$withval)
if test -n "$db_distribution"; then
db_lib="-L${db_distribution}/lib"
db_inc="-I${db_distribution}/include"
fi
AC_ARG_WITH(db_lib,
[ --with-db-lib=DIR location of the Berkley DB library],
[db_lib="-L${withval}"])
AC_ARG_WITH(db_inc,
[ --with-db-inc=DIR location of the Berkley DB include files],
[db_inc="-I${withval}"])
AC_ARG_WITH(sg_config,
[ --with-sg-config=FILE location of squidGuard config file],
sg_config=$withval)
AC_ARG_WITH(sg_logdir,
[ --with-sg-logdir=DIR location of squidGuard log file],
sg_logdir=$withval)
AC_ARG_WITH(sg_dbhome,
[ --with-sg-dbhome=DIR location of squidGuard db dirs],
sg_dbhome=$withval)
AC_ARG_WITH(nolog,
[ --with-nolog=ARG supress logging except for start and stop messages (default: ARG=no)],
nolog=$withval )
AC_ARG_WITH(squiduser,
[ --with-squiduser=USER do set squid user to USER (default: squid)],
squiduser=$withval)
if test -n "$sg_config"; then
AC_DEFINE(ACCONFIG)
changequote(, )dnl
sg_cfgdir=`echo $sg_config|sed "s%/[^/][^/]*$%%"`
changequote([, ])dnl
fi
if test -n "$sg_logdir"; then
AC_DEFINE(ACLOGDIR)
fi
if test -n "$sg_dbhome"; then
AC_DEFINE(ACDBHOME)
fi
CFLAGS="$CFLAGS $db_inc"
CXXFLAGS="$CXXFLAGS $db_inc"
CPPFLAGS="$CPPFLAGS $db_inc"
LDFLAGS="$LDFLAGS $db_lib"
dnl
dnl Checks for header files.
dnl
AC_HEADER_STDC
AC_CHECK_HEADERS(db.h regex.h unistd.h)
AC_CHECK_HEADER(db.h,,[
echo
echo "** No db.h found"
echo " The Berkley DB library is required for squidGuard"
echo " to compile. Get it from http://www.oracle.com"
echo " use --with-db=DIR or --with-db-inc=DIR to specify"
echo " its location. (default is $dbprefix/BerkeleyDB)"
echo
exit 1
])
if test $HAVE_REGEX.H = no; then
echo
echo "** No regex.h found"
echo " The regexp library is required for squidGuard"
echo " to compile. Get it from http://www.gnu.org"
echo
exit 1
fi
dnl
dnl Checks if runtime logmessages shall be suppressed. Is --nolog given?
dnl
AC_ARG_WITH(nolog)
if test "$nolog" = "yes" -o "$nolog" = "true"; then
echo "checking suppress runtime logging... yes"
NOLOG1="/* nolog option set:"
NOLOG2="*/"
else
echo "checking suppress runtime logging... no"
fi
dnl
dnl Checks if squid runtime user is set
dnl
AC_ARG_WITH(squiduser)
if test "$squiduser"; then
echo "checking squid runtime user ... $squiduser"
squiduser=$squiduser
fi
dnl
dnl Checks for libraries. Do in least-dependent to most-dependent order.
dnl
dnl Check ldap
AC_ARG_WITH(ldap,
AC_HELP_STRING([--with-ldap], [use ldap (default: no ldap)]))
if test "$with_ldap" = "yes" -o "$with_ldap" = "true"; then
AC_CHECK_LIB( ldap, ldap_init,
[
echo "checking for ldap support... yes"
with_ldap=yes
LIBS="$LIBS -lldap"
YACCLINE=" | LDAPUSERSEARCH WORD { sgSourceLdapUserSearch(\$2); }"
],[
AC_MSG_WARN([Cannot find LDAP libraries. LDAP support disabled])
with_ldap=no
])
else
echo "checking for ldap support... no"
with_ldap=no
YACCLINE=""
fi
if test "$with_ldap" = "yes"; then
AC_DEFINE(HAVE_LIBLDAP)
AC_RUN_IFELSE([
#include <ldap.h>
int main()
{
LDAP *p;
p = ldap_init("localhost", LDAP_PORT);
exit(0);
}
],,[
echo
echo "Unable to link to LDAP library."
echo
exit 1
],)
fi
dnl
dnl Checks for libraries. Do in least-dependent to most-dependent order.
dnl
dnl Check mysql
AC_ARG_WITH(mysql,
[ --with-mysql=DIR support for mysql],
[ with_mysql="$withval" ],
[ with_mysql=no ])
if test "$with_mysql" != "no"; then
if test "$with_mysql" = "yes"; then
mysql_directory="$default_directory";
mysql_fail="yes"
elif test -d "$withval"; then
mysql_directory="$withval"
mysql_fail="yes"
elif test "$with_mysql" = ""; then
mysql_directory="$default_directory";
mysql_fail="yes"
fi
AC_MSG_CHECKING(for mysql)
MYSQLLINE=" | USERQUERY WORD WORD WORD WORD { sgSourceUserQuery(\$2,\$3,\$4,\$5); }"
for i in $mysql_directory; do
if test -r $i/include/mysql/mysql.h; then
MYSQL_DIR=$i
MYSQL_INC_DIR=$i/include/mysql
elif test -r $i/include/mysql.h; then
MYSQL_DIR=$i
MYSQL_INC_DIR=$i/include
fi
done
if test -z "$MYSQL_DIR"; then
if test "$mysql_fail" != "no"; then
tmp=""
for i in $mysql_directory; do
tmp="$tmp $i/include $i/include/mysql"
done
FAIL_MESSAGE("mysql headers (mysql.h)", $tmp)
else
MYSQLLINE=""
AC_MSG_RESULT(no)
fi
else
for i in lib lib/mysql; do
str="$MYSQL_DIR/$i/libmysqlclient.*"
for j in `echo $str`; do
if test -r $j; then
MYSQL_LIB_DIR="$MYSQL_DIR/$i"
break 2
fi
done
done
if test -z "$MYSQL_LIB_DIR"; then
if test "$mysql_fail" != "no"; then
FAIL_MESSAGE("mysqlclient library",
"$MYSQL_DIR/lib $MYSQL_DIR/lib/mysql")
else
MYSQLLINE=""
AC_MSG_RESULT(no)
fi
else
AC_MSG_RESULT(yes)
LDFLAGS="${LDFLAGS} -L${MYSQL_LIB_DIR}"
CPPFLAGS="${CPPFLAGS} -I${MYSQL_INC_DIR}"
AC_CHECK_LIB(z, compress)
LIBS="-lmysqlclient ${LIBS}"
AC_DEFINE(HAVE_MYSQL)
fi
fi
else
MYSQLLINE=""
echo "checking for mysql support... no"
fi
dnl Check threads... ok if it fails
AC_CHECK_LIB(pthread,pthread_create,,[
echo
echo "Thread library not found, this may cause problems if your"
echo "db libraries require threading support, but most of the time"
echo "it is not an issue."
echo
])
dnl Check DB
LIBS="$LIBS -ldb"
AC_RUN_IFELSE([
#include <db.h>
int main()
{
int major, minor, patch;
float ver;
#if DB_VERSION_MAJOR
major = DB_VERSION_MAJOR;
minor = DB_VERSION_MINOR;
patch = DB_VERSION_PATCH;
#else
db_version(&major, &minor, &patch);
#endif
ver = major + ((float) minor / 1000);
if (ver >= 2.006)
exit (0);
exit (1);
}
], db_ok_version=yes, db_ok_version=no, db_ok_version=no)
if test $db_ok_version = no; then
echo
echo "** The Berkley DB library version 2.6.4 or newer"
echo " is required. Get it from http://www.oracle.com"
echo " use --with-db=DIR or --with-db-inc=DIR, "
echo " --with-db-lib=DIR to specify its location"
echo " (default is $dbprefix/BerkeleyDB)"
echo
exit 1;
fi
AC_RUN_IFELSE([
#include <db.h>
int main()
{
int major, minor, patch;
float ver;
#if DB_VERSION_MAJOR
major = DB_VERSION_MAJOR;
minor = DB_VERSION_MINOR;
patch = DB_VERSION_PATCH;
#else
db_version(&major, &minor, &patch);
#endif
ver = major + ((float) minor / 1000);
if (ver > 2.007 && ver < 3.002)
exit (1);
exit (0);
}
], db_ok_version=yes, db_ok_version=no, db_ok_version=no)
if test $db_ok_version = no; then
echo
echo "** The Berkley DB library version 3.2.* or newer"
echo " is required, when using 3.* versions of the library"
echo " Get it from http://www.oracle.com"
echo " use --with-db=DIR or --with-db-inc=DIR, "
echo " --with-db-lib=DIR to specify its location"
echo " (default is $dbprefix/BerkeleyDB)"
echo
exit 1;
fi
AC_RUN_IFELSE([
#include <db.h>
int main()
{
int major, minor, patch;
float ver;
#if DB_VERSION_MAJOR
major = DB_VERSION_MAJOR;
minor = DB_VERSION_MINOR;
patch = DB_VERSION_PATCH;
#else
db_version(&major, &minor, &patch);
#endif
ver = major + ((float) minor / 1000);
if (ver >= 3.002)
exit (0);
exit (1);
}
], dbg2_ok_version=yes, dbg2_ok_version=no, dbg2_ok_version=no)
if test $dbg2_ok_version = yes; then
AC_DEFINE(DB_VERSION_GT2)
fi
AC_RUN_IFELSE([
#include <db.h>
int main()
{
int major, minor, patch;
float ver;
#if DB_VERSION_MAJOR
major = DB_VERSION_MAJOR;
minor = DB_VERSION_MINOR;
patch = DB_VERSION_PATCH;
#else
db_version(&major, &minor, &patch);
#endif
ver = major + ((float) minor / 1000);
if (ver >= 4.002)
exit (0);
exit (1);
}
], dbg3_ok_version=yes, dbg3_ok_version=no, dbg3_ok_version=no)
if test $dbg3_ok_version = yes; then
AC_DEFINE(DB_VERSION_GT3)
fi
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_STRUCT_TM
dnl Checks for library functions.
AC_CHECK_FUNCS(regcomp, , AC_MSG_ERROR([No regcomp library function.]))
AC_CHECK_FUNCS(regerror, , AC_MSG_ERROR([No regerror library function.]))
AC_CHECK_FUNCS(regexec, , AC_MSG_ERROR([No regexec library function.]))
AC_CHECK_FUNCS(strdup, , AC_MSG_ERROR([No strdup library function.]))
AC_CHECK_FUNCS(strerror, , AC_MSG_ERROR([No strerror library function.]))
AC_CHECK_FUNCS(vsprintf, , AC_MSG_ERROR([No vsprintf library function.]))
AC_CHECK_FUNCS(sigaction)
AC_CHECK_FUNCS(signal)
VERSION=`pwd | sed 's%.*/squidGuard-%%'`
TESTDIR="`pwd`/test"
if test -f /bin/csh -a -f /bin/hostname -a -f /bin/domainname; then
if test "`/bin/domainname`" = .ost.eltele.no -o "`/bin/domainname`" = .teledanmark.no; then
FTPDIR="~ftp/pub/www/proxy/squidGuard"
FTPDIR=`/bin/csh -fc "test -d $FTPDIR && echo $FTPDIR" 2>/dev/null | grep -v '^~'` || FTPDIR="@FTPDIR@"
CGIFILE="~ftp/pub/www/proxy/squidGuard/contrib/squidGuard.cgi"
CGIFILE=`/bin/csh -fc "test -f $CGIFILE && echo $CGIFILE" 2>/dev/null | grep -v '^~'` || CGI="@CGI@"
SQUIDGUARDROBOT="~proxy/filter/robot/bin/squidGuardRobot"
SQUIDGUARDROBOT=`/bin/csh -fc "test -f $SQUIDGUARDROBOT && echo $SQUIDGUARDROBOT" 2>/dev/null | grep -v '^~'` || SQUIDGUARDROBOT="@SQUIDGUARDROBOT@"
SQUIDGUARDROBOTUA="~proxy/filter/robot/lib/RobotUserAgent.pm"
SQUIDGUARDROBOTUA=`/bin/csh -fc "test -f $SQUIDGUARDROBOT && echo $SQUIDGUARDROBOTUA" 2>/dev/null | grep -v '^~'` || SQUIDGUARDROBOTUA="@SQUIDGUARDROBOTUA@"
BLACKLISTS="$FTPDIR/contrib/blacklists.tar.gz"
BLACKLISTS=`/bin/csh -fc "test -f $BLACKLISTS && echo $BLACKLISTS" 2>/dev/null | grep -v '^~'` || BLACKLISTS="@BLACKLISTS@"
fi
fi
AC_SUBST(ac_n)
AC_SUBST(ac_c)
AC_SUBST(sg_config)
AC_SUBST(sg_cfgdir)
AC_SUBST(sg_logdir)
AC_SUBST(sg_dbhome)
AC_SUBST(NOLOG1)
AC_SUBST(NOLOG2)
AC_SUBST(YACCLINE)
AC_SUBST(MYSQLLINE)
AC_SUBST(squiduser)
AC_SUBST(VERSION)
AC_SUBST(PERL)
AC_SUBST(LYNX)
AC_SUBST(TESTDIR)
AC_SUBST(FTPDIR)
AC_SUBST(CGIFILE)
AC_SUBST(SQUIDGUARDROBOT)
AC_SUBST(SQUIDGUARDROBOTUA)
AC_SUBST(ROBOTEXCEPTIONS)
AC_SUBST(BLACKLISTS)
AC_OUTPUT(Makefile src/Makefile src/sgDiv.c src/sg.h src/sg.y test/Makefile test/test1.conf test/test2.conf samples/Makefile samples/sample.conf samples/squidGuard.cgi samples/squidGuard-simple.cgi samples/squidGuard-simple-de.cgi contrib/Makefile contrib/squidGuardRobot/squidGuardRobot contrib/sgclean/sgclean contrib/hostbyname/hostbyname)