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