This commit was generated by cvs2svn to compensate for changes in r8593,
[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.10 $)dnl
7
8 dnl Setup autoconf
9 AC_PREREQ(2.53)
10 AC_INIT(RT, [3.6.10], [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 SPEED_BIN
35 AC_ARG_WITH(speedycgi,
36             AC_HELP_STRING([--with-speedycgi=/path/to/speedy],
37                            [path to your speedycgi binary, if it exists]),
38             SPEEDY_BIN=$withval,
39             SPEEDY_BIN=/usr/local/bin/speedy) 
40 AC_SUBST(SPEEDY_BIN)
41
42
43 dnl Defaults paths for installation
44 AC_PREFIX_DEFAULT([/opt/rt3])
45 RT_ENABLE_LAYOUT
46
47
48 # ACRT_USER_EXISTS( users, variable, default )
49 # - users is a list of users [www apache www-docs]
50 #    from highest to lowest priority to high priority (i.e. first match)
51 # - variable is what you set with the result
52 #
53
54 AC_DEFUN([ACRT_USER_GUESS],
55  [ 
56    $2=$3
57    for x in $1; do
58     AC_MSG_CHECKING([if user $x exists]) 
59      AS_IF([ $PERL -e"exit( defined getpwnam('$x') ? 0 : 1)" ],
60            [ AC_MSG_RESULT([found]); $2=$x ; break],
61            [ AC_MSG_RESULT([not found]) ])
62    done
63   ])
64 AC_DEFUN([ACRT_GROUP_GUESS],
65  [ 
66    $2=$3
67    for x in $1; do
68     AC_MSG_CHECKING([if group $x exists]) 
69      AS_IF([ $PERL -e"exit( defined getgrnam('$x') ? 0 : 1)" ],
70            [ AC_MSG_RESULT([found]); $2=$x ; break],
71            [ AC_MSG_RESULT([not found]) ])
72    done
73   ])
74
75 dnl BIN_OWNER
76 AC_ARG_WITH(bin-owner,
77             AC_HELP_STRING([--with-bin-owner=OWNER],
78                            [user that will own RT binaries (default root)]),
79             BIN_OWNER=$withval,
80             BIN_OWNER=root)
81 AC_SUBST(BIN_OWNER)
82
83 dnl LIBS_OWNER
84 AC_ARG_WITH(libs-owner,
85             AC_HELP_STRING([--with-libs-owner=OWNER],
86                            [user that will own RT libraries (default root)]),
87             LIBS_OWNER=$withval,
88             LIBS_OWNER=root)
89 AC_SUBST(LIBS_OWNER)
90
91 dnl LIBS_GROUP
92 AC_ARG_WITH(libs-group,
93             AC_HELP_STRING([--with-libs-group=GROUP],
94                            [group that will own RT binaries (default bin)]),
95             LIBS_GROUP=$withval,
96             LIBS_GROUP=bin)
97 AC_SUBST(LIBS_GROUP)
98
99 dnl DB_TYPE
100 AC_ARG_WITH(db-type,
101             AC_HELP_STRING([--with-db-type=TYPE],
102                            [sort of database RT will use (default: mysql) (mysql, Pg, Oracle, Informix and SQLite are valid)]), 
103             DB_TYPE=$withval,
104             DB_TYPE=mysql)
105 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
106         AC_MSG_ERROR([Only Oracle, Informix, Pg, mysql and SQLite are valid db types])
107 fi
108 AC_SUBST(DB_TYPE)
109
110 dnl DATABASE_ENV_PREF
111 if test "$DB_TYPE" = 'Oracle'; then
112         test "x$ORACLE_HOME" = 'x' && AC_MSG_ERROR([Please declare the ORACLE_HOME environment variable])
113         DATABASE_ENV_PREF="\$ENV{'ORACLE_HOME'} = '$ORACLE_HOME';"
114 fi
115
116 dnl DATABASE_ENV_PREF
117 if test "$DB_TYPE" = 'Sybase'; then
118         test "x$SYBASE" = 'x' && AC_MSG_ERROR([Please declare the SYBASE_HOME environment variable])
119         DATABASE_ENV_PREF="\$ENV{'SYBASE'} = '$SYBASE';"
120 fi
121 AC_SUBST(DATABASE_ENV_PREF)
122
123 dnl DB_HOST
124 AC_ARG_WITH(db-host,
125             AC_HELP_STRING([--with-db-host=HOSTNAME],
126                            [FQDN of database server (default: localhost)]),
127             DB_HOST=$withval,
128             DB_HOST=localhost)
129 AC_SUBST(DB_HOST)
130
131 dnl DB_PORT
132 AC_ARG_WITH(db-port,
133             AC_HELP_STRING([--with-db-port=PORT],
134                            [port on which the database listens on]),
135             DB_PORT=$withval,
136             DB_PORT=)
137 AC_SUBST(DB_PORT)
138
139 dnl DB_RT_HOST
140 AC_ARG_WITH(db-rt-host,
141             AC_HELP_STRING([--with-db-rt-host=HOSTNAME],
142                            [FQDN of RT server which talks to the database server (default: localhost)]),
143             DB_RT_HOST=$withval,
144             DB_RT_HOST=localhost)
145 AC_SUBST(DB_RT_HOST)
146
147 dnl DB_DATABASE_ADMIN
148 if test "$DB_TYPE" = "Pg" ; then
149         DB_DBA="postgres"
150 else
151         DB_DBA="root"
152 fi
153 AC_ARG_WITH(db-dba,
154             AC_HELP_STRING([--with-db-dba=DBA],
155                            [name of database administrator (default: root or postgres)]),
156             DB_DBA=$withval,
157             DB_DBA="$DB_DBA")
158 AC_SUBST(DB_DBA)
159
160 dnl DB_DATABASE
161 AC_ARG_WITH(db-database,
162             AC_HELP_STRING([--with-db-database=DBNAME],
163                            [name of the database to use (default: rt3)]),
164             DB_DATABASE=$withval,
165             DB_DATABASE=rt3)
166 AC_SUBST(DB_DATABASE)
167
168 dnl DB_RT_USER
169 AC_ARG_WITH(db-rt-user,
170             AC_HELP_STRING([--with-db-rt-user=DBUSER],
171                            [name of database user (default: rt_user)]),
172             DB_RT_USER=$withval,
173             DB_RT_USER=rt_user)
174 AC_SUBST(DB_RT_USER)
175
176 dnl DB_RT_PASS
177 AC_ARG_WITH(db-rt-pass,
178             AC_HELP_STRING([--with-db-rt-pass=PASSWORD],
179                            [password for database user (default: rt_pass)]),
180             DB_RT_PASS=$withval,
181             DB_RT_PASS=rt_pass)
182 AC_SUBST(DB_RT_PASS)
183
184 dnl WEB_USER
185 AC_ARG_WITH(web-user,
186             AC_HELP_STRING([--with-web-user=USER],
187                            [user the web server runs as (default: www)]),
188             WEB_USER=$withval,
189             ACRT_USER_GUESS([www www-data apache httpd nobody],[WEB_USER],[www])
190 )
191 AC_SUBST(WEB_USER)
192
193 dnl WEB_GROUP
194 AC_ARG_WITH(web-group,
195             AC_HELP_STRING([--with-web-group=GROUP],
196                            [group the web server runs as (default: www)]),
197             WEB_GROUP=$withval,
198             ACRT_GROUP_GUESS([www www-data apache httpd nogroup nobody],[WEB_GROUP], [www]))
199 AC_SUBST(WEB_GROUP)
200
201 dnl RTGROUP
202 AC_ARG_WITH(rt-group,
203             AC_HELP_STRING([--with-rt-group=GROUP],
204                            [group to own all files (default: rt)]),
205             RTGROUP=$withval,
206             ACRT_GROUP_GUESS([rt3 rt $WEB_GROUP],[RTGROUP], [rt]))
207 AC_SUBST(RTGROUP)
208
209 dnl INSTALL AS ME
210 # XXX TODO: The command below to figure out the group brokenly relies on
211 # output order (and "id -gn" doesn't work on all platforms).
212 my_group=$(groups|cut -f1 -d' ')
213 my_user=${USER:-$LOGNAME}
214 AC_ARG_WITH(my-user-group,
215             AC_HELP_STRING([--with-my-user-group],
216                            [set all users and groups to current user/group]),
217             RTGROUP=$my_group
218             BIN_OWNER=$my_user
219             LIBS_OWNER=$my_user
220             LIBS_GROUP=$my_group
221             WEB_USER=$my_user
222             WEB_GROUP=$my_group)
223
224 # Test for valid database names
225 AS_IF([ test "$DB_TYPE" == "mysql" ],
226       [ AC_MSG_CHECKING([if database name is valid])
227           AS_IF([ echo $DB_DATABASE | $AWK '/-/ { exit 1 }' ],
228                 [ AC_MSG_RESULT([yes]) ],
229                 [ AC_MSG_ERROR([no.  database name ($DB_DATABASE) contains '-' which is not valid for mysql]) ]
230                )
231       ]
232      )
233
234
235 dnl Set the value of apachectl
236 AC_ARG_WITH(apachectl,
237             AC_HELP_STRING([--with-apachectl],
238                            [instruct RT where to find your apachectl]),
239
240             APACHECTL=$withval, 
241             APACHECTL=`which apachectl`)
242 AC_SUBST(APACHECTL)
243
244 dnl RT's standalone pure perl server
245 AC_ARG_WITH(devel-mode,
246             AC_HELP_STRING([--with-standalone],
247                            [Install modules for pure perl standalone server]),
248
249             RT_STANDALONE="1",
250             RT_STANDALONE="0")
251 AC_SUBST(RT_STANDALONE)
252
253 dnl RT's "maintainer mode"
254 AC_ARG_WITH(devel-mode,
255             AC_HELP_STRING([--with-devel-mode],
256                            [Turn on development aids that might hurt you in production]),
257
258             RT_DEVEL_MODE="1", 
259             RT_DEVEL_MODE="0")
260 AC_SUBST(RT_DEVEL_MODE)
261 dnl This section maps the variable names this script 'natively' generates
262 dnl to their existing names. They should be removed from here as the .in
263 dnl files are changed to use the new names.
264
265 dnl version numbers
266 AC_SUBST(RT_VERSION_MAJOR,              ${rt_version_major})
267 AC_SUBST(RT_VERSION_MINOR,              ${rt_version_minor})
268 AC_SUBST(RT_VERSION_PATCH,              ${rt_version_patch})
269
270 dnl layout paths
271 AC_SUBST([RT_PATH],                     ${exp_prefix})
272 AC_SUBST([RT_DOC_PATH],                 ${exp_manualdir})
273 AC_SUBST([RT_LOCAL_PATH],               ${exp_customdir})
274 AC_SUBST([RT_LIB_PATH],                 ${exp_libdir})
275 AC_SUBST([RT_ETC_PATH],                 ${exp_sysconfdir})
276 AC_SUBST([CONFIG_FILE_PATH],            ${exp_sysconfdir})
277 AC_SUBST([RT_BIN_PATH],                 ${exp_bindir})
278 AC_SUBST([RT_SBIN_PATH],                ${exp_sbindir})
279 AC_SUBST([RT_VAR_PATH],                 ${exp_localstatedir})
280 AC_SUBST([RT_MAN_PATH],                 ${exp_mandir})
281 AC_SUBST([MASON_DATA_PATH],             ${exp_masonstatedir})
282 AC_SUBST([MASON_SESSION_PATH],          ${exp_sessionstatedir})
283 AC_SUBST([MASON_HTML_PATH],             ${exp_htmldir})
284 AC_SUBST([LOCAL_ETC_PATH],              ${exp_custometcdir})
285 AC_SUBST([MASON_LOCAL_HTML_PATH],       ${exp_customhtmldir})
286 AC_SUBST([LOCAL_LEXICON_PATH],          ${exp_customlexdir})
287 AC_SUBST([LOCAL_LIB_PATH],              ${exp_customlibdir})
288 AC_SUBST([DESTDIR],                     ${exp_prefix})
289 AC_SUBST([RT_LOG_PATH],                 ${exp_logfiledir})
290
291 dnl Configure the output files, and generate them.
292
293 dnl Binaries that should be +x
294 AC_CONFIG_FILES([
295                  sbin/rt-dump-database
296                  sbin/rt-setup-database
297                  sbin/rt-test-dependencies
298                  bin/mason_handler.fcgi
299                  bin/mason_handler.scgi
300                  bin/standalone_httpd
301                  bin/rt-crontool
302                  bin/rt-mailgate
303                  bin/rt],
304                 [chmod ug+x $ac_file]
305                )
306
307 dnl All other generated files
308 AC_CONFIG_FILES([
309                  Makefile
310                  etc/RT_Config.pm
311                  lib/RT.pm
312                  bin/mason_handler.svc
313                  bin/webmux.pl],
314                )
315 AC_OUTPUT