Add to git.
[dlife.git] / configure.in
1 # DLIFE (C) 2000 Richard W.M. Jones <rich@annexia.org>
2 # and other authors listed in the ``AUTHORS'' file.
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 #
18 # $Id: configure.in,v 1.3 2002/04/05 17:02:25 rich Exp $
19
20 AC_INIT(cell.c)
21 AM_INIT_AUTOMAKE(dlife, 1.0.0)
22 AM_CONFIG_HEADER(config.h)
23
24 dnl Check for the basic compile environment.
25 AC_PROG_CC
26 AC_PROG_INSTALL
27 AC_PROG_MAKE_SET
28
29 dnl Enable compiler warnings.
30 if test "$CC" = "gcc"; then
31         CFLAGS="$CFLAGS -Wall -Werror"
32 fi
33
34 dnl Check for arguments to configure.
35 AC_ARG_ENABLE(
36   check,
37   [  --enable-check          Enable extra internal consistency checks (slow)],
38   CFLAGS="$CFLAGS -DCHECK=1"
39 )
40
41 AC_ARG_ENABLE(
42   profile,
43   [  --enable-profile        Enable code profiling],
44   CFLAGS="$CFLAGS -pg"
45 )
46
47 AC_ARG_ENABLE(
48   user-check,
49   [  --disable-user-check    Do not check for existance of dlife account],
50   user_check="no",
51   user_check="yes"
52 )
53
54 AC_ARG_ENABLE(
55   cron,
56   [  --enable-cron[=layout]  Install cron script to run dlife net client
57                           'layout' may be 'auto' (default), 'standard',
58                           or a path to crontab directory starting with /
59   --disable-cron          Do not install cron script],
60   install_cron="$enableval",
61   install_cron="yes"
62 )
63
64 AC_ARG_ENABLE(
65   rc,
66   [  --enable-rc[=layout]    Install rc script (runs dlife_soup at boot)
67                           'layout' may be 'auto' (default), 'standard',
68                           or a path to local rc directory starting with /
69   --disable-rc            Do not install rc script],
70   install_rc="$enableval",
71   install_rc="yes"
72 )
73
74 AC_ARG_WITH(
75   spool,
76   [  --with-spool=DIR        Spool directory (default typically /var/spool/dlife)],
77   SPOOLDIR="$withval",
78   FC_EXPAND_DIR(SPOOLDIR, '${localstatedir}/spool/dlife')
79 )
80
81 AC_ARG_WITH(
82   conf,
83   [  --with-conf=DIR         Config directory (default typically /etc/dlife)],
84   CONFDIR="$withval",
85   FC_EXPAND_DIR(CONFDIR, '${sysconfdir}/dlife')
86 )
87
88 dnl Check for ``dlife'' account.
89 if test "$user_check" = "yes"; then
90         AC_MSG_CHECKING([for dlife group])
91         if ! grep '^dlife:' /etc/group >/dev/null; then
92                 AC_MSG_ERROR([there is no 'dlife' group in /etc/group])
93         fi
94         AC_MSG_RESULT([found])
95
96         AC_MSG_CHECKING([for dlife user])
97         if ! grep '^dlife:' /etc/passwd >/dev/null; then
98                 AC_MSG_ERROR([there is no 'dlife' user in /etc/passwd])
99         fi
100         AC_MSG_RESULT([found])
101 fi
102
103 dnl Check for available functions.
104 AC_CHECK_FUNCS( \
105         closedir \
106         getpwnam \
107         getuid \
108         initgroups \
109         nice \
110         opendir \
111         openlog \
112         readdir \
113         setgid \
114         setuid \
115         syslog \
116         )
117
118 dnl Check for header files.
119 AC_CHECK_HEADERS( \
120         assert.h \
121         dirent.h \
122         errno.h \
123         fcntl.h \
124         grp.h \
125         pwd.h \
126         signal.h \
127         stddef.h \
128         stdint.h \
129         string.h \
130         sys/param.h \
131         sys/types.h \
132         syslog.h \
133         time.h \
134         unistd.h \
135         )
136
137 dnl Check for a place to install the crontab.
138 dnl The $install_cron variable will have one of the following possible
139 dnl values:
140 dnl   yes / auto      Try to determine cron dir by automatic means
141 dnl   no              Do not install crontab
142 dnl   standard        Use FSSTND layout (/etc/cron.d)
143 dnl   /path/to/dir/   Use given directory
144 dnl After this, $install_cron will contain either a path (beginning
145 dnl with /) or "no".
146
147 AC_MSG_CHECKING([crontab directory])
148
149 case "$install_cron" in
150 yes|auto)
151         if test -d $sysconfdir/cron.d; then
152                 install_cron=$sysconfdir/cron.d
153         else
154                 AC_MSG_ERROR([failed to find a directory to put crontabs in; try --help])
155         fi
156         ;;
157 standard)
158         install_cron=/etc/cron.d
159         ;;
160 /*)
161         dnl Do nothing.
162         ;;
163 no)
164         dnl Do nothing.
165         ;;
166 *)
167         AC_MSG_ERROR([unknown parameter given to --enable-cron])
168         ;;
169 esac
170
171 AC_MSG_RESULT($install_cron)
172 CRONDIR=$install_cron
173
174 AM_CONDITIONAL(INSTALL_CRON,[test "$install_cron" != "no"])
175
176 dnl Check for a place to install rc scripts
177 dnl The $install_rc variable will have one of the following possible
178 dnl values:
179 dnl   yes / auto      Try to determine rc dir by automatic means
180 dnl   no              Do not install rc script
181 dnl   standard        Use red hat / debian / FSSTND layout (/etc/init.d)
182 dnl   /path/to/dir/   Use given directory
183 dnl After this, $install_rc will contain either a path (beginning
184 dnl with /) or "no".
185
186 AC_MSG_CHECKING([rc directory])
187
188 case "$install_rc" in
189 yes|auto)
190         if test -d $sysconfdir/init.d; then
191                 install_rc=$sysconfdir/init.d
192         else
193                 AC_MSG_ERROR([failed to find a directory to put rc scripts in; try --help])
194         fi
195         ;;
196 standard)
197         install_rc=/etc/init.d
198         ;;
199 /*)
200         dnl Do nothing.
201         ;;
202 no)
203         dnl Do nothing.
204         ;;
205 *)
206         AC_MSG_ERROR([unknown parameter given to --enable-rc])
207         ;;
208 esac
209
210 AC_MSG_RESULT($install_rc)
211 RCDIR=$install_rc
212
213 AM_CONDITIONAL(INSTALL_RC,[test "$install_rc" != "no"])
214
215 AC_MSG_CHECKING([spool directory])
216 AC_MSG_RESULT($SPOOLDIR)
217
218 AC_MSG_CHECKING([config directory])
219 AC_MSG_RESULT($CONFDIR)
220
221 dnl Check for a place to install documentation.
222 AC_MSG_CHECKING([for a place to install documentation])
223 if test -d $prefix/share/doc; then
224         DOCDIR=$prefix/share/doc/$PACKAGE-$VERSION
225 else
226         DOCDIR=/tmp
227 fi
228 AC_MSG_RESULT($DOCDIR)
229
230 dnl Release date.
231 RELEASEDATE=`date +"%d %b %Y"`
232
233 dnl Variables to be substituted.
234 AC_SUBST(CRONDIR)
235 AC_SUBST(RCDIR)
236 AC_SUBST(SPOOLDIR)
237 AC_SUBST(CONFDIR)
238 AC_SUBST(DOCDIR)
239 AC_SUBST(RELEASEDATE)
240
241 dnl Variables to be placed in config.h.
242 AC_DEFINE_UNQUOTED(SPOOLDIR, "$SPOOLDIR")
243 AC_DEFINE_UNQUOTED(CONFDIR, "$CONFDIR")
244
245 dnl Generate output files.
246 AC_OUTPUT([
247         Makefile
248         dlife_client.pl
249         dlife_server.pl
250         dlife.spec
251         index.html
252         ])