1 # Copyright (C) 2002-2010 Stanislav Sinyagin
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17 # $Id: configure.ac,v 1.1 2010-12-27 00:03:31 ivan Exp $
18 # Stanislav Sinyagin <ssinyagin@yahoo.com>
22 AC_INIT([torrus],[1.0.9],[ssinyagin@users.sourceforge.net])
24 AC_CONFIG_AUX_DIR(conftools)
28 AC_PATH_PROG(PERL, perl, no)
30 # Need this for init.torrus
31 AC_PATH_PROG(SU, su, no)
32 AC_PATH_PROG(KILL, kill, no)
33 AC_PATH_PROG(SED, sed, no)
34 AC_PATH_PROG(FIND, find, no)
35 AC_PATH_PROG(RM, rm, no)
36 AC_PATH_PROG(SLEEP, sleep, no)
39 # This will generate doc pages from POD sources
40 AC_PATH_PROG(POD2TEXT, pod2text, no)
41 AM_CONDITIONAL([POD2TEXT_PRESENT], [test "$POD2TEXT" != no])
42 AC_PATH_PROG(POD2MAN, pod2man, no)
43 AM_CONDITIONAL([POD2MAN_PRESENT], [test "$POD2MAN" != no])
45 AC_ARG_ENABLE(pkgonly,
46 [AC_HELP_STRING([--enable-pkgonly],
47 [Skip all checking])])
48 AC_SUBST(enable_pkgonly)
50 AC_ARG_ENABLE(threads,
51 [AC_HELP_STRING([--disable-threads],
52 [Disable Perl threads usage])])
54 perllibdirs="\'\${perllibdir}\'"
57 AC_ARG_VAR(PERLINC, [[] Additional space-separated Perl library paths])
58 if test ! -z "$PERLINC"; then
60 PERLOPTS="${PERLOPTS} -I${d}"
61 perllibdirs=${perllibdirs}"\,\'"${d}"\'"
66 if ${PERL} -e 'use RRDs' 2>/dev/null; then :; else
67 if test "$enable_pkgonly" != yes; then
68 AC_MSG_NOTICE([RRDs.pm is not in default Perl search paths.])
69 AC_MSG_CHECKING([RRDtool in /usr/local/rrdtool*])
70 with_rrdtool=`ls -1dr /usr/local/rrdtool* | head -1`
71 if test -d $with_rrdtool; then
72 AC_MSG_RESULT([${with_rrdtool}])
74 AC_MSG_ERROR([Cannot find RRDtool])
78 with_rrdtool="/usr/local/rrdtool"
84 if test "$enable_pkgonly" != yes; then
85 if ${PERL} -I${with_rrdtool}/lib/perl -e 'use RRDs'; then :; else
86 AC_MSG_ERROR([Could not find RRDs perl module in ${with_rrdtool}])
89 perllibdirs=${perllibdirs}"\,\'"${with_rrdtool}"/lib/perl/\'"
93 [AC_HELP_STRING(--with-rrdtool=DIR,RRDTool location)],
94 test_rrdtool, find_rrdtool)
96 AC_SUBST(perllibdirs, [${perllibdirs}])
99 # Check the necessary Perl modules
101 if test "$enable_pkgonly" != yes; then
103 for module in 'BerkeleyDB' 'XML::LibXML' 'Template' \
104 'Proc::Daemon' 'Net::SNMP' 'URI::Escape' 'Apache::Session' \
107 AC_MSG_CHECKING([presence of $module])
108 if ${PERL} ${PERLOPTS} -e 'use '$module 2>/dev/null; then
111 AC_MSG_ERROR([Perl cannot find $module]);
115 # Check if Perl threads can be used.
116 # Requirements are: perl 5.8.8 with threads compiled,
117 # threads ver. 1.41 or higher, threads::shared ver. 1.03 or higher
120 if test x"$enable_threads" = xno; then
124 AC_MSG_CHECKING([if Perl version is 5.8.8 or higher])
125 if ${PERL} ${PERLOPTS} -e 'use 5.8.8' 2>/dev/null; then
131 if test ${perlithreads} -eq 1; then
132 AC_MSG_CHECKING([threading support in Perl])
133 if ${PERL} ${PERLOPTS} -e 'use threads' 2>/dev/null; then
140 if test ${perlithreads} -eq 1; then
141 AC_MSG_CHECKING([if threads module version is 1.41 or higher])
142 if ${PERL} ${PERLOPTS} -e \
143 'use threads; exit($threads::VERSION >= 1.41 ? 0:1)'; then
150 if test ${perlithreads} -eq 1; then
151 AC_MSG_CHECKING([if threads::shared module version is 1.03 or higher])
152 if ${PERL} ${PERLOPTS} -e \
153 'use threads; use threads::shared;
154 exit($threads::shared::VERSION >= 1.03 ? 0:1)'; then
161 if test ${perlithreads} -eq 0; then
162 AC_MSG_RESULT([No. Multithreading will not be used.])
166 AC_SUBST(perlithreads, [${perlithreads}])
169 AC_ARG_VAR(torrus_user, [[torrus] UID to run the daemons])
170 if test -z "$torrus_user"; then
171 torrus_user=torrus; fi
173 if test "$enable_pkgonly" != yes; then
174 AC_MSG_CHECKING([if user ${torrus_user} exists])
175 torrus_check_file=torrus_usercheck_$$
176 torrus_check_error=no
177 if ! touch ${torrus_check_file}; then
178 AC_MSG_ERROR([Cannot create ${torrus_check_file}])
179 elif ! chown ${torrus_user} ${torrus_check_file}; then
180 torrus_check_error=yes
182 rm -f ${torrus_check_file}
183 if test ${torrus_check_error} = yes; then
184 AC_MSG_ERROR([User ${torrus_user} does not exist])
191 # Set the var/db and var/cache ownership
193 AC_ARG_VAR(var_user, [[TORRUS_USER] Owner of db and cache directories])
194 AC_ARG_VAR(var_group, [[torrus] Group of db and cache directories])
195 AC_ARG_VAR(var_mode, [[775] Mode of db and cache directories])
197 AC_ARG_ENABLE(varperm,
198 [AC_HELP_STRING(--disable-varperm,
199 Disable db and cache access rights tuning)],
201 [enable_varperm="yes"])
202 AC_SUBST(enable_varperm)
204 AC_ARG_VAR(pkghome, [[PREFIX/torrus] Place for Torrus static files])
205 if test -z "$pkghome"; then
206 pkghome='${prefix}/torrus'; fi
208 AC_ARG_VAR(pkgbindir, [[PKGHOME/bin] Torrus executables])
209 if test -z "$pkgbindir"; then
210 pkgbindir='${pkghome}/bin'; fi
212 AC_ARG_VAR(cfgdefdir, [[PKGHOME/conf_defaults] torrus-config.pl and others])
213 if test -z "$cfgdefdir"; then
214 cfgdefdir='${pkghome}/conf_defaults'; fi
216 AC_ARG_VAR(pkgdocdir, [[PKGHOME/doc] Documentation files])
217 if test -z "$pkgdocdir"; then
218 pkgdocdir='${pkghome}/doc'; fi
220 AC_ARG_VAR(exmpdir, [[PKGHOME/examples] Examples])
221 if test -z "$exmpdir"; then
222 exmpdir='${pkghome}/examples'; fi
224 AC_ARG_VAR(perllibdir, [[PKGHOME/perllib] Torrus Perl libraries])
225 if test -z "$perllibdir"; then
226 perllibdir='${pkghome}/perllib'; fi
228 AC_ARG_VAR(pluginsdir, [[PKGHOME/plugins] Plugin configurations])
229 if test -z "$pluginsdir"; then
230 pluginsdir='${pkghome}/plugins'; fi
232 AC_ARG_VAR(plugtorruscfgdir, [[PLUGINSDIR/torrus-config]])
233 if test -z "$plugtorruscfgdir"; then
234 plugtorruscfgdir='${pluginsdir}/torrus-config'; fi
236 AC_ARG_VAR(plugdevdisccfgdir, [[PLUGINSDIR/devdiscover-config]])
237 if test -z "$plugdevdisccfgdir"; then
238 plugdevdisccfgdir='${pluginsdir}/devdiscover-config'; fi
240 AC_ARG_VAR(plugwrapperdir, [[PLUGINSDIR/wrapper]])
241 if test -z "$plugwrapperdir"; then
242 plugwrapperdir='${pluginsdir}/wrapper'; fi
245 AC_ARG_VAR(scriptsdir, [[PKGHOME/scripts] Script files])
246 if test -z "$scriptsdir"; then
247 scriptsdir='${pkghome}/scripts'; fi
249 AC_ARG_VAR(supdir, [[PKGHOME/sup] Supplementary files])
250 if test -z "$supdir"; then
251 supdir='${pkghome}/sup'; fi
253 AC_ARG_VAR(webplaindir, [[SUPDIR/webplain] Web interface plain files path])
254 if test -z "$webplaindir"; then
255 webplaindir='${supdir}/webplain'; fi
257 AC_ARG_VAR(webscriptsdir,
258 [[SUPDIR/webscripts] Directory for optional web scripts])
259 if test -z "$webscriptsdir"; then
260 webscriptsdir='${supdir}/webscripts'; fi
262 AC_ARG_VAR(tmpldir, [[PKGHOME/templates] Template files])
263 if test -z "$tmpldir"; then
264 tmpldir='${pkghome}/templates'; fi
266 AC_ARG_VAR(distxmldir, [[PKGHOME/xmlconfig] Distribution XML config files])
267 if test -z "$distxmldir"; then
268 distxmldir='${pkghome}/xmlconfig'; fi
270 AC_ARG_VAR(sitedir, [[SYSCONFDIR/torrus] Site configuration files])
271 if test -z "$sitedir"; then
272 sitedir='${sysconfdir}/torrus'; fi
274 AC_ARG_VAR(siteconfdir, [[SITEDIR/conf] Site configuration files])
275 if test -z "$siteconfdir"; then
276 siteconfdir='${sitedir}/conf'; fi
278 AC_ARG_VAR(tmpluserdir, [[SITEDIR/templates] User-defined Template files])
279 if test -z "$tmpluserdir"; then
280 tmpluserdir='${sitedir}/templates'; fi
282 AC_ARG_VAR(sitexmldir, [[SITEDIR/xmlconfig] Site XML configs])
283 if test -z "$sitexmldir"; then
284 sitexmldir='${sitedir}/xmlconfig'; fi
286 AC_ARG_VAR(logdir, [[/var/log/torrus] Log files])
287 if test -z "$logdir"; then
288 logdir='/var/log/torrus'; fi
290 AC_ARG_VAR(piddir, [[/var/run/torrus] PID files])
291 if test -z "$piddir"; then
292 piddir='/var/run/torrus'; fi
294 AC_ARG_VAR(varprefix, [[/var/torrus] Common prefix for runtime data])
295 if test -z "$varprefix"; then
296 varprefix='/var/torrus'; fi
298 AC_ARG_VAR(cachedir, [[VARPREFIX/cache] Renderer cache])
299 if test -z "$cachedir"; then
300 cachedir='${varprefix}/cache'; fi
302 AC_ARG_VAR(dbhome, [[VARPREFIX/db] Berkeley DB files])
303 if test -z "$dbhome"; then
304 dbhome='${varprefix}/db'; fi
306 AC_ARG_VAR(reportsdir, [[VARPREFIX/reports] Reports output])
307 if test -z "$reportsdir"; then
308 reportsdir='${varprefix}/reports'; fi
310 AC_ARG_VAR(seslockdir, [[VARPREFIX/session_data/lock] Web session locks])
311 if test -z "$seslockdir"; then
312 seslockdir='${varprefix}/session_data/lock'; fi
314 AC_ARG_VAR(sesstordir, [[VARPREFIX/session_data/store] Web session storage])
315 if test -z "$sesstordir"; then
316 sesstordir='${varprefix}/session_data/store'; fi
318 AC_ARG_VAR(wrapperdir, [[BINDIR] CLI wrapper])
319 if test -z "$wrapperdir"; then
320 wrapperdir='${bindir}'; fi
322 AC_ARG_VAR(mansec_usercmd, [[1] User commands man section])
323 if test -z "$mansec_usercmd"; then
324 mansec_usercmd='1'; fi
326 AC_ARG_VAR(mansec_misc, [[7] Miscellaneous man section])
327 if test -z "$mansec_misc"; then
330 AC_ARG_VAR(defrrddir, [[/srv/torrus/collector_rrd] Default RRD storage path])
331 if test -z "$defrrddir"; then
332 defrrddir='/srv/torrus/collector_rrd'; fi
335 AC_CONFIG_FILES([Makefile bin/Makefile configs/Makefile])
336 AC_CONFIG_FILES([doc/Makefile doc/manpages/Makefile])
337 AC_CONFIG_FILES([examples/Makefile perllib/Makefile])
338 AC_CONFIG_FILES([sup/Makefile xmlconfig/Makefile])
340 AC_CONFIG_FILES([setup_tools/substvars.sh],[chmod +x setup_tools/substvars.sh])
341 AC_CONFIG_FILES([setup_tools/mkvardir.sh], [chmod +x setup_tools/mkvardir.sh])
342 AC_CONFIG_FILES([init.d/torrus], [chmod +x init.d/torrus])
348 VARSAVE=configs/instvars
349 echo creating $VARSAVE
351 for VAR in $ac_subst_vars; do
353 DEFS | PACKAGE* | INSTALL* | VERSION | ACLOCAL | AUTO* | MAKEINFO |\
354 install_sh | AM* | am* | ac* | ECHO* | build* | host* | target* |\
355 CYG* | PATH_SEPARATOR | AWK | STRIP | mkdir* |\
360 echo ${VAR}=\'${VAL}\' >>$VARSAVE