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 my_group=$($PERL -MPOSIX=getgid -le 'print scalar getgrgid getgid')
216 my_user=${USER:-$LOGNAME}
217 AC_ARG_WITH(my-user-group,
218             AC_HELP_STRING([--with-my-user-group],
219                            [set all users and groups to current user/group]),
220             RTGROUP=$my_group
221             BIN_OWNER=$my_user
222             LIBS_OWNER=$my_user
223             LIBS_GROUP=$my_group
224             WEB_USER=$my_user
225             WEB_GROUP=$my_group)
226
227 # Test for valid database names
228 AC_MSG_CHECKING([if database name is set])
229           AS_IF([ echo $DB_DATABASE | $PERL -e 'exit(1) unless <> =~ /\S/' ],
230                 [ AC_MSG_RESULT([yes]) ],
231                 [ AC_MSG_ERROR([no.  database name is not set]) ]
232                )
233
234 dnl Dependencies for testing and developing RT
235 AC_ARG_WITH(developer,[],RT_DEVELOPER=$withval,RT_DEVELOPER="0")
236 AC_ARG_ENABLE(developer,
237             AC_HELP_STRING([--enable-developer],
238                            [Add dependencies needed for testing and developing RT]),
239             RT_DEVELOPER=$enableval,
240             RT_DEVELOPER=$RT_DEVELOPER)
241 if test "$RT_DEVELOPER" = yes; then
242         RT_DEVELOPER="1"
243 else
244         RT_DEVELOPER="0"
245 fi
246 AC_SUBST(RT_DEVELOPER)
247
248 dnl RT's GraphViz dependency charts
249 AC_CHECK_PROG([RT_GRAPHVIZ], [dot], "yes", "no")
250 AC_ARG_WITH(graphviz,[],RT_GRAPHVIZ=$withval)
251 AC_ARG_ENABLE(graphviz,
252             AC_HELP_STRING([--enable-graphviz],
253                            [Turns on support for RT's GraphViz dependency charts]),
254             RT_GRAPHVIZ=$enableval)
255 if test "$RT_GRAPHVIZ" = yes; then
256         RT_GRAPHVIZ="1"
257 else
258         RT_GRAPHVIZ="0"
259 fi
260 AC_SUBST(RT_GRAPHVIZ)
261
262 dnl RT's GD pie and bar charts
263 AC_CHECK_PROG([RT_GD], [gdlib-config], "yes", "no")
264 AC_ARG_WITH(gd,[],RT_GD=$withval)
265 AC_ARG_ENABLE(gd,
266             AC_HELP_STRING([--enable-gd],
267                            [Turns on support for RT's GD pie and bar charts]),
268             RT_GD=$enableval)
269 if test "$RT_GD" = yes; then
270         RT_GD="1"
271 else
272         RT_GD="0"
273 fi
274 AC_SUBST(RT_GD)
275
276 dnl RT's GPG support
277 AC_CHECK_PROG([RT_GPG_DEPS], [gpg], "yes", "no")
278 if test "$RT_GPG_DEPS" = yes; then
279         RT_GPG_DEPS="1"
280 else
281         RT_GPG_DEPS="0"
282 fi
283 AC_ARG_ENABLE(gpg,
284             AC_HELP_STRING([--enable-gpg],
285                            [Turns on GNU Privacy Guard (GPG) support]),
286             RT_GPG=$enableval)
287 if test "$RT_GPG" = yes; then
288         RT_GPG="1"
289         RT_GPG_DEPS="1"
290 else
291         if test "$RT_GPG" = no; then
292                 RT_GPG="0"
293                 RT_GPG_DEPS="0"
294         else
295                 RT_GPG="0"
296         fi
297 fi
298 AC_SUBST(RT_GPG_DEPS)
299 AC_SUBST(RT_GPG)
300
301
302 dnl RT's SMIME support
303 AC_CHECK_PROG([RT_SMIME_DEPS], [openssl], "yes", "no")
304 if test "$RT_SMIME_DEPS" = yes; then
305         RT_SMIME_DEPS="1"
306 else
307         RT_SMIME_DEPS="0"
308 fi
309 AC_ARG_ENABLE(smime,
310             AC_HELP_STRING([--enable-smime],
311                            [Turns on Secure MIME (SMIME) support]),
312             RT_SMIME=$enableval)
313 if test "$RT_SMIME" = yes; then
314         RT_SMIME="1"
315         RT_SMIME_DEPS="1"
316 else
317         if test "$RT_SMIME" = no; then
318                 RT_SMIME="0"
319                 RT_SMIME_DEPS="0"
320         else
321                 RT_SMIME="0"
322         fi
323 fi
324 AC_SUBST(RT_SMIME_DEPS)
325 AC_SUBST(RT_SMIME)
326
327
328 dnl This section maps the variable names this script 'natively' generates
329 dnl to their existing names. They should be removed from here as the .in
330 dnl files are changed to use the new names.
331
332 dnl version numbers
333 AC_SUBST(RT_VERSION_MAJOR,              ${rt_version_major})
334 AC_SUBST(RT_VERSION_MINOR,              ${rt_version_minor})
335 AC_SUBST(RT_VERSION_PATCH,              ${rt_version_patch})
336
337 dnl layout paths
338 AC_SUBST([RT_PATH],                     ${exp_prefix})
339 AC_SUBST([RT_DOC_PATH],                 ${exp_manualdir})
340 AC_SUBST([RT_LOCAL_PATH],               ${exp_customdir})
341 AC_SUBST([RT_LIB_PATH],                 ${exp_libdir})
342 AC_SUBST([RT_LEXICON_PATH],                     ${exp_lexdir})
343 AC_SUBST([RT_STATIC_PATH],                      ${exp_staticdir})
344 AC_SUBST([RT_ETC_PATH],                 ${exp_sysconfdir})
345 AC_SUBST([CONFIG_FILE_PATH],            ${exp_sysconfdir})
346 AC_SUBST([RT_BIN_PATH],                 ${exp_bindir})
347 AC_SUBST([RT_SBIN_PATH],                ${exp_sbindir})
348 AC_SUBST([RT_VAR_PATH],                 ${exp_localstatedir})
349 AC_SUBST([RT_MAN_PATH],                 ${exp_mandir})
350 AC_SUBST([RT_FONT_PATH],                        ${exp_fontdir})
351 AC_SUBST([RT_PLUGIN_PATH],                      ${exp_plugindir})
352 AC_SUBST([MASON_DATA_PATH],             ${exp_masonstatedir})
353 AC_SUBST([MASON_SESSION_PATH],          ${exp_sessionstatedir})
354 AC_SUBST([MASON_HTML_PATH],             ${exp_htmldir})
355 AC_SUBST([LOCAL_ETC_PATH],              ${exp_custometcdir})
356 AC_SUBST([MASON_LOCAL_HTML_PATH],       ${exp_customhtmldir})
357 AC_SUBST([LOCAL_LEXICON_PATH],          ${exp_customlexdir})
358 AC_SUBST([LOCAL_STATIC_PATH],           ${exp_customstaticdir})
359 AC_SUBST([LOCAL_LIB_PATH],              ${exp_customlibdir})
360 AC_SUBST([LOCAL_PLUGIN_PATH],           ${exp_customplugindir})
361 AC_SUBST([RT_LOG_PATH],                 ${exp_logfiledir})
362
363 if test ${exp_sysconfdir} = "etc" -o ${exp_sysconfdir} = "etc/rt"; then
364 AC_SUBST([RT_PATH_R],                   ${exp_prefix})
365 AC_SUBST([RT_DOC_PATH_R],                       ${exp_prefix}/${exp_manualdir})
366 AC_SUBST([RT_LOCAL_PATH_R],             ${exp_prefix}/${exp_customdir})
367 AC_SUBST([RT_LIB_PATH_R],                       ${exp_prefix}/${exp_libdir})
368 AC_SUBST([RT_ETC_PATH_R],                       ${exp_prefix}/${exp_sysconfdir})
369 AC_SUBST([CONFIG_FILE_PATH_R],          ${exp_prefix}/${exp_sysconfdir})
370 AC_SUBST([RT_BIN_PATH_R],                       ${exp_prefix}/${exp_bindir})
371 AC_SUBST([RT_SBIN_PATH_R],              ${exp_prefix}/${exp_sbindir})
372 AC_SUBST([RT_VAR_PATH_R],                       ${exp_prefix}/${exp_localstatedir})
373 AC_SUBST([RT_MAN_PATH_R],                       ${exp_prefix}/${exp_mandir})
374 AC_SUBST([RT_FONT_PATH_R],                      ${exp_prefix}/${exp_fontdir})
375 AC_SUBST([RT_LEXICON_PATH_R],                   ${exp_prefix}/${exp_lexdir})
376 AC_SUBST([RT_STATIC_PATH_R],                    ${exp_prefix}/${exp_staticdir})
377 AC_SUBST([RT_PLUGIN_PATH_R],            ${exp_prefix}/${exp_plugindir})
378 AC_SUBST([MASON_DATA_PATH_R],           ${exp_prefix}/${exp_masonstatedir})
379 AC_SUBST([MASON_SESSION_PATH_R],                ${exp_prefix}/${exp_sessionstatedir})
380 AC_SUBST([MASON_HTML_PATH_R],           ${exp_prefix}/${exp_htmldir})
381 AC_SUBST([LOCAL_ETC_PATH_R],            ${exp_prefix}/${exp_custometcdir})
382 AC_SUBST([MASON_LOCAL_HTML_PATH_R],     ${exp_prefix}/${exp_customhtmldir})
383 AC_SUBST([LOCAL_LEXICON_PATH_R],                ${exp_prefix}/${exp_customlexdir})
384 AC_SUBST([LOCAL_STATIC_PATH_R],         ${exp_prefix}/${exp_customstaticdir})
385 AC_SUBST([LOCAL_LIB_PATH_R],            ${exp_prefix}/${exp_customlibdir})
386 AC_SUBST([LOCAL_PLUGIN_PATH_R],         ${exp_prefix}/${exp_customplugindir})
387 AC_SUBST([RT_LOG_PATH_R],                       ${exp_prefix}/${exp_logfiledir})
388 else
389 AC_SUBST([RT_PATH_R],                   ${exp_prefix})
390 AC_SUBST([RT_DOC_PATH_R],                       ${exp_manualdir})
391 AC_SUBST([RT_LOCAL_PATH_R],             ${exp_customdir})
392 AC_SUBST([RT_LIB_PATH_R],                       ${exp_libdir})
393 AC_SUBST([RT_LEXICON_PATH_R],                   ${exp_lexdir})
394 AC_SUBST([RT_STATIC_PATH_R],                    ${exp_staticdir})
395 AC_SUBST([RT_ETC_PATH_R],                       ${exp_sysconfdir})
396 AC_SUBST([RT_PLUGIN_PATH_R],            ${exp_plugindir})
397 AC_SUBST([CONFIG_FILE_PATH_R],          ${exp_sysconfdir})
398 AC_SUBST([RT_BIN_PATH_R],                       ${exp_bindir})
399 AC_SUBST([RT_SBIN_PATH_R],              ${exp_sbindir})
400 AC_SUBST([RT_VAR_PATH_R],                       ${exp_localstatedir})
401 AC_SUBST([RT_MAN_PATH_R],                       ${exp_mandir})
402 AC_SUBST([RT_FONT_PATH_R],                      ${exp_fontdir})
403 AC_SUBST([MASON_DATA_PATH_R],           ${exp_masonstatedir})
404 AC_SUBST([MASON_SESSION_PATH_R],                ${exp_sessionstatedir})
405 AC_SUBST([MASON_HTML_PATH_R],           ${exp_htmldir})
406 AC_SUBST([LOCAL_ETC_PATH_R],            ${exp_custometcdir})
407 AC_SUBST([MASON_LOCAL_HTML_PATH_R],     ${exp_customhtmldir})
408 AC_SUBST([LOCAL_LEXICON_PATH_R],                ${exp_customlexdir})
409 AC_SUBST([LOCAL_STATIC_PATH_R],         ${exp_customstaticdir})
410 AC_SUBST([LOCAL_PLUGIN_PATH_R],         ${exp_customplugindir})
411 AC_SUBST([LOCAL_LIB_PATH_R],            ${exp_customlibdir})
412 AC_SUBST([RT_LOG_PATH_R],                       ${exp_logfiledir})
413
414 fi
415
416 dnl Configure the output files, and generate them.
417
418 dnl Binaries that should be +x
419 AC_CONFIG_FILES([
420                  etc/upgrade/3.8-ical-extension
421                  etc/upgrade/4.0-customfield-checkbox-extension
422                  etc/upgrade/generate-rtaddressregexp
423                  etc/upgrade/sanity-check-stylesheets
424                  etc/upgrade/shrink-cgm-table
425                  etc/upgrade/shrink-transactions-table
426                  etc/upgrade/split-out-cf-categories
427                  etc/upgrade/switch-templates-to
428                  etc/upgrade/time-worked-history
429                  etc/upgrade/upgrade-articles
430                  etc/upgrade/vulnerable-passwords
431                  sbin/rt-attributes-viewer
432                  sbin/rt-session-viewer
433                  sbin/rt-preferences-viewer
434                  sbin/rt-session-viewer
435                  sbin/rt-dump-metadata
436                  sbin/rt-setup-database
437                  sbin/rt-test-dependencies
438                  sbin/rt-email-digest
439                  sbin/rt-email-dashboards
440                  sbin/rt-clean-sessions
441                  sbin/rt-shredder
442                  sbin/rt-validator
443                  sbin/rt-validate-aliases
444                  sbin/rt-email-group-admin
445                  sbin/rt-server
446                  sbin/rt-server.fcgi
447                  sbin/standalone_httpd
448                  sbin/rt-setup-fulltext-index
449                  sbin/rt-fulltext-indexer
450                  sbin/rt-serializer
451                  sbin/rt-importer
452                  bin/rt-crontool
453                  bin/rt-mailgate
454                  bin/rt],
455                 [chmod ug+x $ac_file]
456                )
457
458 dnl All other generated files
459 AC_CONFIG_FILES([
460                  Makefile
461                  etc/RT_Config.pm
462                  lib/RT/Generated.pm
463                  t/data/configs/apache2.2+mod_perl.conf
464                  t/data/configs/apache2.2+fastcgi.conf],
465                )
466 AC_OUTPUT