Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / rt / configure.ac
1 autoconf; exec ./configure $@
2 dnl
3 dnl Process this file with autoconf to produce a configure script
4 dnl
5 dnl Embed in generated ./configure script the following CVS info:
6 AC_REVISION($Revision: 1.4 $)dnl
7
8 dnl Setup autoconf
9 AC_PREREQ([2.53])
10 AC_INIT(RT, m4_esyscmd([( git describe --tags || cat ./.tag 2> /dev/null || echo "rt-3.9.EXPORTED" )| tr -d "\n"]), [rt-bugs@bestpractical.com])
11 AC_CONFIG_SRCDIR([lib/RT.pm])
12
13 dnl Save our incant early since $@ gets overwritten by some macros.
14 dnl ${ac_configure_args} is available later, but it's quoted differently
15 dnl and undocumented.  See http://www.spinics.net/lists/ac/msg10022.html.
16 AC_SUBST(CONFIGURE_INCANT, "$0 $@")
17
18 dnl Extract RT version number components
19 AC_SUBST([rt_version_major],
20         m4_bregexp(AC_PACKAGE_VERSION,[^rt-\(\w+\)\.\(\w+\)\.\(.+\)$],[\1]))
21 AC_SUBST([rt_version_minor],
22         m4_bregexp(AC_PACKAGE_VERSION,[^rt-\(\w+\)\.\(\w+\)\.\(.+\)$],[\2]))
23 AC_SUBST([rt_version_patch],
24         m4_bregexp(AC_PACKAGE_VERSION,[^rt-\(\w+\)\.\(\w+\)\.\(.+\)$],[\3]))
25 test "x$rt_version_major" = 'x' && rt_version_major=0
26 test "x$rt_version_minor" = 'x' && rt_version_minor=0
27 test "x$rt_version_patch" = 'x' && rt_version_patch=0
28
29 dnl Check for programs
30 AC_PROG_INSTALL
31 AC_ARG_VAR([PERL],[Perl interpreter command])
32 AC_PATH_PROG([PERL], [perl], [not found])
33 if test "$PERL" = 'not found'; then
34         AC_MSG_ERROR([cannot use $PACKAGE_NAME without perl])
35 fi
36
37
38 dnl WEB_HANDLER
39 AC_ARG_WITH(web-handler,
40     AC_HELP_STRING([--with-web-handler=LIST],
41         [comma separated list of web-handlers RT will be able to use.
42          Default is fastcgi. Valid values are modperl1, modperl2, fastcgi and standalone.
43          To successfully run RT you need only one.
44         ]),
45     WEB_HANDLER=$withval,
46     WEB_HANDLER=fastcgi)
47 my_web_handler_test=$($PERL -e 'print "ok" unless grep $_ !~ /^(modperl1|modperl2|fastcgi|standalone)$/i, grep defined && length, split /\s*,\s*/, $ARGV@<:@0@:>@' $WEB_HANDLER)
48 if test "$my_web_handler_test" != "ok"; then
49         AC_MSG_ERROR([Only modperl1, modperl2, fastcgi and standalone are valid web-handlers])
50 fi
51 AC_SUBST(WEB_HANDLER)
52
53 dnl Defaults paths for installation
54 AC_PREFIX_DEFAULT([/opt/rt4])
55 RT_ENABLE_LAYOUT
56
57
58 # ACRT_USER_EXISTS( users, variable, default )
59 # - users is a list of users [www apache www-docs]
60 #    from highest to lowest priority to high priority (i.e. first match)
61 # - variable is what you set with the result
62 #
63
64 AC_DEFUN([ACRT_USER_GUESS],
65  [ 
66    $2=$3
67    for x in $1; do
68     AC_MSG_CHECKING([if user $x exists]) 
69      AS_IF([ $PERL -e"exit( defined getpwnam('$x') ? 0 : 1)" ],
70            [ AC_MSG_RESULT([found]); $2=$x ; break],
71            [ AC_MSG_RESULT([not found]) ])
72    done
73   ])
74 AC_DEFUN([ACRT_GROUP_GUESS],
75  [ 
76    $2=$3
77    for x in $1; do
78     AC_MSG_CHECKING([if group $x exists]) 
79      AS_IF([ $PERL -e"exit( defined getgrnam('$x') ? 0 : 1)" ],
80            [ AC_MSG_RESULT([found]); $2=$x ; break],
81            [ AC_MSG_RESULT([not found]) ])
82    done
83   ])
84
85 dnl BIN_OWNER
86 AC_ARG_WITH(bin-owner,
87             AC_HELP_STRING([--with-bin-owner=OWNER],
88                            [user that will own RT binaries (default root)]),
89             BIN_OWNER=$withval,
90             BIN_OWNER=root)
91 AC_SUBST(BIN_OWNER)
92
93 dnl LIBS_OWNER
94 AC_ARG_WITH(libs-owner,
95             AC_HELP_STRING([--with-libs-owner=OWNER],
96                            [user that will own RT libraries (default root)]),
97             LIBS_OWNER=$withval,
98             LIBS_OWNER=root)
99 AC_SUBST(LIBS_OWNER)
100
101 dnl LIBS_GROUP
102 AC_ARG_WITH(libs-group,
103             AC_HELP_STRING([--with-libs-group=GROUP],
104                            [group that will own RT binaries (default bin)]),
105             LIBS_GROUP=$withval,
106             LIBS_GROUP=bin)
107 AC_SUBST(LIBS_GROUP)
108
109 dnl DB_TYPE
110 AC_ARG_WITH(db-type,
111             AC_HELP_STRING([--with-db-type=TYPE],
112                            [sort of database RT will use (default: mysql) (mysql, Pg, Oracle and SQLite are valid)]), 
113             DB_TYPE=$withval,
114             DB_TYPE=mysql)
115 if test "$DB_TYPE" != 'mysql' -a "$DB_TYPE" != 'Pg' -a "$DB_TYPE" != 'SQLite' -a "$DB_TYPE" != 'Oracle' ; then
116         AC_MSG_ERROR([Only Oracle, Pg, mysql and SQLite are valid db types])
117 fi
118 AC_SUBST(DB_TYPE)
119
120 dnl DATABASE_ENV_PREF
121 if test "$DB_TYPE" = 'Oracle'; then
122         test "x$ORACLE_HOME" = 'x' && AC_MSG_ERROR([Please declare the ORACLE_HOME environment variable])
123         DATABASE_ENV_PREF="\$ENV{'ORACLE_HOME'} = '$ORACLE_HOME';"
124 fi
125
126 AC_SUBST(DATABASE_ENV_PREF)
127
128 dnl DB_HOST
129 AC_ARG_WITH(db-host,
130             AC_HELP_STRING([--with-db-host=HOSTNAME],
131                            [FQDN of database server (default: localhost)]),
132             DB_HOST=$withval,
133             DB_HOST=localhost)
134 AC_SUBST(DB_HOST)
135
136 dnl DB_PORT
137 AC_ARG_WITH(db-port,
138             AC_HELP_STRING([--with-db-port=PORT],
139                            [port on which the database listens on]),
140             DB_PORT=$withval,
141             DB_PORT=)
142 AC_SUBST(DB_PORT)
143
144 dnl DB_RT_HOST
145 AC_ARG_WITH(db-rt-host,
146             AC_HELP_STRING([--with-db-rt-host=HOSTNAME],
147                            [FQDN of RT server which talks to the database server (default: localhost)]),
148             DB_RT_HOST=$withval,
149             DB_RT_HOST=localhost)
150 AC_SUBST(DB_RT_HOST)
151
152 dnl DB_DATABASE_ADMIN
153 if test "$DB_TYPE" = "Pg" ; then
154         DB_DBA="postgres"
155 else
156         DB_DBA="root"
157 fi
158 AC_ARG_WITH(db-dba,
159             AC_HELP_STRING([--with-db-dba=DBA],
160                            [name of database administrator (default: root or postgres)]),
161             DB_DBA=$withval,
162             DB_DBA="$DB_DBA")
163 AC_SUBST(DB_DBA)
164
165 dnl DB_DATABASE
166 AC_ARG_WITH(db-database,
167             AC_HELP_STRING([--with-db-database=DBNAME],
168                            [name of the database to use (default: rt4)]),
169             DB_DATABASE=$withval,
170             DB_DATABASE=rt4)
171 AC_SUBST(DB_DATABASE)
172
173 dnl DB_RT_USER
174 AC_ARG_WITH(db-rt-user,
175             AC_HELP_STRING([--with-db-rt-user=DBUSER],
176                            [name of database user (default: rt_user)]),
177             DB_RT_USER=$withval,
178             DB_RT_USER=rt_user)
179 AC_SUBST(DB_RT_USER)
180
181 dnl DB_RT_PASS
182 AC_ARG_WITH(db-rt-pass,
183             AC_HELP_STRING([--with-db-rt-pass=PASSWORD],
184                            [password for database user (default: rt_pass)]),
185             DB_RT_PASS=$withval,
186             DB_RT_PASS=rt_pass)
187 AC_SUBST(DB_RT_PASS)
188
189 dnl WEB_USER
190 AC_ARG_WITH(web-user,
191             AC_HELP_STRING([--with-web-user=USER],
192                            [user the web server runs as (default: www)]),
193             WEB_USER=$withval,
194             ACRT_USER_GUESS([www www-data apache httpd nobody],[WEB_USER],[www])
195 )
196 AC_SUBST(WEB_USER)
197
198 dnl WEB_GROUP
199 AC_ARG_WITH(web-group,
200             AC_HELP_STRING([--with-web-group=GROUP],
201                            [group the web server runs as (default: www)]),
202             WEB_GROUP=$withval,
203             ACRT_GROUP_GUESS([www www-data apache httpd nogroup nobody],[WEB_GROUP], [www]))
204 AC_SUBST(WEB_GROUP)
205
206 dnl RTGROUP
207 AC_ARG_WITH(rt-group,
208             AC_HELP_STRING([--with-rt-group=GROUP],
209                            [group to own all files (default: rt)]),
210             RTGROUP=$withval,
211             ACRT_GROUP_GUESS([rt3 rt $WEB_GROUP],[RTGROUP], [rt]))
212 AC_SUBST(RTGROUP)
213
214 dnl INSTALL AS ME
215 # XXX TODO: The command below to figure out the group brokenly relies on
216 # output order (and "id -gn" doesn't work on all platforms).
217 my_group=$(groups|cut -f1 -d' ')
218 my_user=${USER:-$LOGNAME}
219 AC_ARG_WITH(my-user-group,
220             AC_HELP_STRING([--with-my-user-group],
221                            [set all users and groups to current user/group]),
222             RTGROUP=$my_group
223             BIN_OWNER=$my_user
224             LIBS_OWNER=$my_user
225             LIBS_GROUP=$my_group
226             WEB_USER=$my_user
227             WEB_GROUP=$my_group)
228
229 # Test for valid database names
230 AC_MSG_CHECKING([if database name is set])
231           AS_IF([ echo $DB_DATABASE | $PERL -e 'exit(1) unless <> =~ /\S/' ],
232                 [ AC_MSG_RESULT([yes]) ],
233                 [ AC_MSG_ERROR([no.  database name is not set]) ]
234                )
235
236 AS_IF([ test "$DB_TYPE" = "mysql" ],
237       [ AC_MSG_CHECKING([if database name is valid])
238           AS_IF([ echo $DB_DATABASE | $PERL -e 'exit(1) if <> =~ /-/'],
239                 [ AC_MSG_RESULT([yes]) ],
240                 [ AC_MSG_ERROR([no.  database name ($DB_DATABASE) contains '-' which is not valid for mysql]) ]
241                )
242       ]
243      )
244
245
246 dnl Set the value of apachectl
247 AC_ARG_WITH(apachectl,
248             AC_HELP_STRING([--with-apachectl],
249                            [instruct RT where to find your apachectl]),
250             APACHECTL=$withval, 
251             APACHECTL=`which apachectl`)
252 AC_SUBST(APACHECTL)
253
254 dnl RT's "maintainer mode"
255 AC_ARG_WITH(devel-mode,[],RT_DEVEL_MODE=$withval,RT_DEVEL_MODE="0")
256 AC_ARG_ENABLE(devel-mode,
257             AC_HELP_STRING([--enable-devel-mode],
258                            [Turn on development aids that might hurt you in production]),
259             RT_DEVEL_MODE=$enableval,
260             RT_DEVEL_MODE=$RT_DEVEL_MODE)
261 if test "$RT_DEVEL_MODE" = yes; then
262         RT_DEVEL_MODE="1"
263 else
264         RT_DEVEL_MODE="0"
265 fi
266 AC_SUBST(RT_DEVEL_MODE)
267
268 dnl RT's GraphViz dependency charts
269 AC_CHECK_LIB([graph],[aginitlib],RT_GRAPHVIZ="1")
270 AC_ARG_WITH(graphviz,[],RT_GRAPHVIZ=$withval)
271 AC_ARG_ENABLE(graphviz,
272             AC_HELP_STRING([--enable-graphviz],
273                            [Turns on support for RT's GraphViz dependency charts]),
274             RT_GRAPHVIZ=$enableval)
275 if test "$RT_GRAPHVIZ" = yes; then
276         RT_GRAPHVIZ="1"
277 else
278         RT_GRAPHVIZ="0"
279 fi
280 AC_SUBST(RT_GRAPHVIZ)
281
282 dnl RT's GD pie and bar charts
283 AC_CHECK_PROG([RT_GD], [gdlib-config], "yes", "no")
284 AC_ARG_WITH(gd,[],RT_GD=$withval)
285 AC_ARG_ENABLE(gd,
286             AC_HELP_STRING([--enable-gd],
287                            [Turns on support for RT's GD pie and bar charts]),
288             RT_GD=$enableval)
289 if test "$RT_GD" = yes; then
290         RT_GD="1"
291 else
292         RT_GD="0"
293 fi
294 AC_SUBST(RT_GD)
295
296 dnl RT's GPG support
297 AC_CHECK_PROG([RT_GPG], [gpg], "yes", "no")
298 AC_ARG_ENABLE(gpg,
299             AC_HELP_STRING([--enable-gpg],
300                            [Turns on GNU Privacy Guard (GPG) support]),
301             RT_GPG=$enableval)
302 if test "$RT_GPG" = yes; then
303         RT_GPG="1"
304 else
305         RT_GPG="0"
306 fi
307 AC_SUBST(RT_GPG)
308
309 dnl SSL support for RT's mailgate
310 AC_ARG_WITH(ssl-mailgate,[],RT_SSL_MAILGATE=$withval,RT_SSL_MAILGATE="0")
311 AC_ARG_ENABLE(ssl-mailgate,
312             AC_HELP_STRING([--enable-ssl-mailgate],
313                            [Turns on support for HTTPS in rt-mailgate]),
314             RT_SSL_MAILGATE=$enableval,
315             RT_SSL_MAILGATE=$RT_SSL_MAILGATE)
316 if test "$RT_SSL_MAILGATE" = yes; then
317         RT_SSL_MAILGATE="1"
318 else
319         RT_SSL_MAILGATE="0"
320 fi
321 AC_SUBST(RT_SSL_MAILGATE)
322
323
324 dnl This section maps the variable names this script 'natively' generates
325 dnl to their existing names. They should be removed from here as the .in
326 dnl files are changed to use the new names.
327
328 dnl version numbers
329 AC_SUBST(RT_VERSION_MAJOR,              ${rt_version_major})
330 AC_SUBST(RT_VERSION_MINOR,              ${rt_version_minor})
331 AC_SUBST(RT_VERSION_PATCH,              ${rt_version_patch})
332
333 dnl layout paths
334 AC_SUBST([RT_PATH],                     ${exp_prefix})
335 AC_SUBST([RT_DOC_PATH],                 ${exp_manualdir})
336 AC_SUBST([RT_LOCAL_PATH],               ${exp_customdir})
337 AC_SUBST([RT_LIB_PATH],                 ${exp_libdir})
338 AC_SUBST([RT_LEXICON_PATH],                     ${exp_lexdir})
339 AC_SUBST([RT_ETC_PATH],                 ${exp_sysconfdir})
340 AC_SUBST([CONFIG_FILE_PATH],            ${exp_sysconfdir})
341 AC_SUBST([RT_BIN_PATH],                 ${exp_bindir})
342 AC_SUBST([RT_SBIN_PATH],                ${exp_sbindir})
343 AC_SUBST([RT_VAR_PATH],                 ${exp_localstatedir})
344 AC_SUBST([RT_MAN_PATH],                 ${exp_mandir})
345 AC_SUBST([RT_FONT_PATH],                        ${exp_fontdir})
346 AC_SUBST([RT_PLUGIN_PATH],                      ${exp_plugindir})
347 AC_SUBST([MASON_DATA_PATH],             ${exp_masonstatedir})
348 AC_SUBST([MASON_SESSION_PATH],          ${exp_sessionstatedir})
349 AC_SUBST([MASON_HTML_PATH],             ${exp_htmldir})
350 AC_SUBST([LOCAL_ETC_PATH],              ${exp_custometcdir})
351 AC_SUBST([MASON_LOCAL_HTML_PATH],       ${exp_customhtmldir})
352 AC_SUBST([LOCAL_LEXICON_PATH],          ${exp_customlexdir})
353 AC_SUBST([LOCAL_LIB_PATH],              ${exp_customlibdir})
354 AC_SUBST([LOCAL_PLUGIN_PATH],           ${exp_customplugindir})
355 AC_SUBST([RT_LOG_PATH],                 ${exp_logfiledir})
356
357 if test ${exp_sysconfdir} = "etc" -o ${exp_sysconfdir} = "etc/rt"; then
358 AC_SUBST([RT_PATH_R],                   ${exp_prefix})
359 AC_SUBST([RT_DOC_PATH_R],                       ${exp_prefix}/${exp_manualdir})
360 AC_SUBST([RT_LOCAL_PATH_R],             ${exp_prefix}/${exp_customdir})
361 AC_SUBST([RT_LIB_PATH_R],                       ${exp_prefix}/${exp_libdir})
362 AC_SUBST([RT_ETC_PATH_R],                       ${exp_prefix}/${exp_sysconfdir})
363 AC_SUBST([CONFIG_FILE_PATH_R],          ${exp_prefix}/${exp_sysconfdir})
364 AC_SUBST([RT_BIN_PATH_R],                       ${exp_prefix}/${exp_bindir})
365 AC_SUBST([RT_SBIN_PATH_R],              ${exp_prefix}/${exp_sbindir})
366 AC_SUBST([RT_VAR_PATH_R],                       ${exp_prefix}/${exp_localstatedir})
367 AC_SUBST([RT_MAN_PATH_R],                       ${exp_prefix}/${exp_mandir})
368 AC_SUBST([RT_FONT_PATH_R],                      ${exp_prefix}/${exp_fontdir})
369 AC_SUBST([RT_LEXICON_PATH_R],                   ${exp_prefix}/${exp_lexdir})
370 AC_SUBST([RT_PLUGIN_PATH_R],            ${exp_prefix}/${exp_plugindir})
371 AC_SUBST([MASON_DATA_PATH_R],           ${exp_prefix}/${exp_masonstatedir})
372 AC_SUBST([MASON_SESSION_PATH_R],                ${exp_prefix}/${exp_sessionstatedir})
373 AC_SUBST([MASON_HTML_PATH_R],           ${exp_prefix}/${exp_htmldir})
374 AC_SUBST([LOCAL_ETC_PATH_R],            ${exp_prefix}/${exp_custometcdir})
375 AC_SUBST([MASON_LOCAL_HTML_PATH_R],     ${exp_prefix}/${exp_customhtmldir})
376 AC_SUBST([LOCAL_LEXICON_PATH_R],                ${exp_prefix}/${exp_customlexdir})
377 AC_SUBST([LOCAL_LIB_PATH_R],            ${exp_prefix}/${exp_customlibdir})
378 AC_SUBST([LOCAL_PLUGIN_PATH_R],         ${exp_prefix}/${exp_customplugindir})
379 AC_SUBST([RT_LOG_PATH_R],                       ${exp_prefix}/${exp_logfiledir})
380 else
381 AC_SUBST([RT_PATH_R],                   ${exp_prefix})
382 AC_SUBST([RT_DOC_PATH_R],                       ${exp_manualdir})
383 AC_SUBST([RT_LOCAL_PATH_R],             ${exp_customdir})
384 AC_SUBST([RT_LIB_PATH_R],                       ${exp_libdir})
385 AC_SUBST([RT_LEXICON_PATH_R],                   ${exp_lexdir})
386 AC_SUBST([RT_ETC_PATH_R],                       ${exp_sysconfdir})
387 AC_SUBST([RT_PLUGIN_PATH_R],            ${exp_plugindir})
388 AC_SUBST([CONFIG_FILE_PATH_R],          ${exp_sysconfdir})
389 AC_SUBST([RT_BIN_PATH_R],                       ${exp_bindir})
390 AC_SUBST([RT_SBIN_PATH_R],              ${exp_sbindir})
391 AC_SUBST([RT_VAR_PATH_R],                       ${exp_localstatedir})
392 AC_SUBST([RT_MAN_PATH_R],                       ${exp_mandir})
393 AC_SUBST([RT_FONT_PATH_R],                      ${exp_fontdir})
394 AC_SUBST([MASON_DATA_PATH_R],           ${exp_masonstatedir})
395 AC_SUBST([MASON_SESSION_PATH_R],                ${exp_sessionstatedir})
396 AC_SUBST([MASON_HTML_PATH_R],           ${exp_htmldir})
397 AC_SUBST([LOCAL_ETC_PATH_R],            ${exp_custometcdir})
398 AC_SUBST([MASON_LOCAL_HTML_PATH_R],     ${exp_customhtmldir})
399 AC_SUBST([LOCAL_LEXICON_PATH_R],                ${exp_customlexdir})
400 AC_SUBST([LOCAL_PLUGIN_PATH_R],         ${exp_customplugindir})
401 AC_SUBST([LOCAL_LIB_PATH_R],            ${exp_customlibdir})
402 AC_SUBST([RT_LOG_PATH_R],                       ${exp_logfiledir})
403
404 fi
405
406 dnl Configure the output files, and generate them.
407
408 dnl Binaries that should be +x
409 AC_CONFIG_FILES([
410                  etc/upgrade/3.8-branded-queues-extension
411                  etc/upgrade/3.8-ical-extension
412                  etc/upgrade/split-out-cf-categories
413                  etc/upgrade/generate-rtaddressregexp
414                  etc/upgrade/upgrade-articles
415                  etc/upgrade/vulnerable-passwords
416                  sbin/rt-attributes-viewer
417                  sbin/rt-session-viewer
418                  sbin/rt-preferences-viewer
419                  sbin/rt-session-viewer
420                  sbin/rt-dump-metadata
421                  sbin/rt-setup-database
422                  sbin/rt-test-dependencies
423                  sbin/rt-email-digest
424                  sbin/rt-email-dashboards
425                  sbin/rt-clean-sessions
426                  sbin/rt-shredder
427                  sbin/rt-validator
428                  sbin/rt-email-group-admin
429                  sbin/rt-server
430                  sbin/rt-server.fcgi
431                  sbin/standalone_httpd
432                  sbin/rt-setup-fulltext-index
433                  sbin/rt-fulltext-indexer
434                  bin/rt-crontool
435                  bin/rt-mailgate
436                  bin/rt],
437                 [chmod ug+x $ac_file]
438                )
439
440 dnl All other generated files
441 AC_CONFIG_FILES([
442                  Makefile
443                  etc/RT_Config.pm
444                  lib/RT/Generated.pm
445                  t/data/configs/apache2.2+mod_perl.conf
446                  t/data/configs/apache2.2+fastcgi.conf],
447                )
448 AC_OUTPUT