Rename 'cvs2cl.pl' to the more common 'cvs2cl'.
[mdsms.git] / configure.in
1 # $Id$
2
3 dnl Process this file with autoconf to produce a configure script.
4 AC_INIT(mdsms.c)
5 AM_INIT_AUTOMAKE(mdsms, 1.5.3)
6 AM_CONFIG_HEADER(config.h)
7 AM_MAINTAINER_MODE
8
9 dnl Configuration switches.
10
11 AC_MSG_CHECKING([whether debugging is requested])
12 AC_ARG_ENABLE(debug,
13 [  --enable-debug          enable debugging output to stderr],
14     enable_debug=$enableval, enable_debug=no)
15 AC_MSG_RESULT($enable_debug)
16
17 AC_MSG_CHECKING([whether included getopt is requested])
18 AC_ARG_WITH(included-getopt,
19 [  --with-included-getopt  use included getopt(3)],
20      with_getopt=$withval, with_getopt=no)
21 AC_MSG_RESULT($with_getopt)
22
23 AC_MSG_CHECKING([for user-specified lock directory])
24 AC_ARG_WITH(lock-directory,
25 [  --with-lock-directory   override default search for modem lock directory],
26      with_lock_directory=$withval, with_lock_directory=)
27 AC_MSG_RESULT($with_lock_directory)
28
29 AC_ARG_WITH(efence,
30 [  --without-efence        disable use of Electric Fence in maintainer-mode],
31     efence=$withval, efence=yes)
32
33 dnl Checks for programs.
34 AC_PROG_CC
35 if test "$USE_MAINTAINER_MODE" = yes;then
36         if test "$GCC" = yes;then
37                 CFLAGS="$CFLAGS -Wall -ansi -pedantic -ggdb3"
38                 if test x$efence != xno;then
39                         AC_CHECK_LIB(efence, EF_Exit)
40                 fi
41         fi
42 else
43         LDFLAGS="-s"
44         AC_DEFINE(NDEBUG)
45 fi
46
47 AC_PROG_CPP
48
49 dnl Checks for pathnames.
50
51 ALL_LINGUAS="cs"
52 AM_GNU_GETTEXT
53 AC_CHECK_HEADERS(libintl.h)
54
55 AC_MSG_CHECKING([for modem lock directory])
56 dirx=""
57 if test "$with_lock_directory" = no;then
58   AC_MSG_RESULT([user disabled])
59 else
60   if test yes = "$with_lock_directory" \
61            -o  -z   "$with_lock_directory";then
62     for dira in /usr /var         ;do
63                 for dirb in /spool ""         ;do
64                 for dirc in /uucp /locks /lock;do
65                   dir="${dira}${dirb}${dirc}"
66                   if test -d "$dir";then dirx="$dir";fi
67                         done;done;done
68     if test -z "$dirx";then
69             AC_MSG_RESULT([none found, disabled])
70     else
71                   AC_MSG_RESULT([$dirx])
72     fi
73   else
74     dirx="$with_lock_directory"
75                 if test -d "$dirx";then AC_MSG_RESULT([$dirx])
76                 else AC_MSG_RESULT([warning - directory doesn't exist: $dirx])
77                 fi
78         fi
79 fi
80 if test -z "$dirx";then AC_DEFINE(DEF_LOCKFILE,[""])
81 else AC_DEFINE_UNQUOTED(DEF_LOCKFILE,"${dirx}/LCK..%s")
82 fi
83
84 dnl Checks for libraries.
85
86 dnl Checks for header files.
87 AC_HEADER_STDC
88
89 dnl Checks for typedefs, structures, and compiler characteristics.
90
91 AC_C_CONST
92 AC_C_INLINE
93
94 dnl Checks for library functions.
95
96 if test "$with_getopt" = no;then
97         AC_CHECK_FUNCS(getopt_long)
98         fi
99
100 if test "$enable_debug" = yes;then
101         AC_DEFINE(DEBUG)
102         fi
103
104 AC_MSG_CHECKING(whether to use included getopt)
105 if test "$with_getopt" = yes -o "$ac_cv_func_getopt_long" != yes ;then
106         AC_LIBOBJ(getopt)
107         AC_LIBOBJ(getopt1)
108         AC_LIBSOURCE(getopt.h)
109         AC_MSG_RESULT(yes)
110 else AC_MSG_RESULT(no)
111 fi
112
113 AC_CHECK_HEADERS(assert.h ctype.h errno.h fcntl.h limits.h signal.h stdarg.h)
114 AC_CHECK_HEADERS(stdio.h stdlib.h string.h sys/poll.h sys/stat.h sys/time.h)
115 AC_CHECK_HEADERS(sys/types.h sys/wait.h termios.h time.h unistd.h)
116
117 AC_MSG_CHECKING([for LINE_MAX])
118 AC_TRY_COMPILE([
119 #ifdef HAVE_LIMITS_H
120 #include <limits.h>
121 #endif], [LINE_MAX;],
122         AC_DEFINE(HAVE_LINE_MAX)  AC_MSG_RESULT(yes),
123         AC_DEFINE(LINE_MAX, 4096) AC_MSG_RESULT(no))
124
125 AC_MSG_CHECKING([for CBAUD])
126 AC_TRY_COMPILE([
127 #ifdef HAVE_TERMIOS_H
128 #include <termios.h>
129 #endif], [CBAUD;],
130         AC_DEFINE(HAVE_CBAUD) AC_MSG_RESULT(yes),
131         AC_DEFINE(CBAUD, 0)   AC_MSG_RESULT(no))
132
133 AC_MSG_CHECKING([for CBAUDEX])
134 AC_TRY_COMPILE([
135 #ifdef HAVE_TERMIOS_H
136 #include <termios.h>
137 #endif], [CBAUDEX;],
138         AC_DEFINE(HAVE_CBAUDEX) AC_MSG_RESULT(yes),
139         AC_DEFINE(CBAUDEX, 0)   AC_MSG_RESULT(no))
140
141 AC_MSG_CHECKING([for CRTSCTS])
142 AC_TRY_COMPILE([
143 #ifdef HAVE_TERMIOS_H
144 #include <termios.h>
145 #endif], [CRTSCTS;],
146         AC_DEFINE(HAVE_CRTSCTS) AC_MSG_RESULT(yes),[
147         if test "$USE_MAINTAINER_MODE" = yes ;then
148                 AC_DEFINE(HAVE_CRTSCTS) AC_MSG_RESULT(faked for maintainer)
149                 # from "RedHat: glibc-devel-2.2-5/bits/termios.h"
150                 AC_DEFINE(CRTSCTS, 020000000000)
151         else
152                 AC_DEFINE(CRTSCTS, 0)   AC_MSG_RESULT(no)
153         fi
154         ])
155
156 AC_MSG_CHECKING([for _POSIX_VDISABLE])
157 AC_TRY_COMPILE([
158 #ifdef HAVE_UNISTD_H
159 #include <unistd.h>
160 #endif
161 #ifdef HAVE_TERMIOS_H
162 #include <termios.h>
163 #endif], [_POSIX_VDISABLE;],
164         AC_DEFINE(HAVE__POSIX_VDISABLE)    AC_MSG_RESULT(yes),[
165         AC_DEFINE(_POSIX_VDISABLE, ['\0']) AC_MSG_RESULT(no)
166         ])
167
168 AC_MSG_CHECKING([for FD_SETSIZE])
169 AC_TRY_COMPILE([
170 #ifdef HAVE_SYS_TIME_H
171 #include <sys/time.h>
172 #endif
173 #ifdef HAVE_SYS_TYPES_H
174 #include <sys/types.h>
175 #endif
176 #ifdef HAVE_UNISTD_H
177 #include <unistd.h>
178 #endif], [FD_SETSIZE;],
179         AC_DEFINE(HAVE_FD_SETSIZE) AC_MSG_RESULT(yes),
180                                    AC_MSG_RESULT(no))
181
182 AC_MSG_CHECKING([for unused attribute])
183 uns=true
184 for un in __unused__ unused;do
185   if $uns;then
186                 unx="__attribute__ (($un))"
187                 AC_TRY_COMPILE([
188 #ifdef HAVE_STDDEF_H
189 #include <stddef.h>
190 #endif],[char untest $unx;],
191                 AC_DEFINE_UNQUOTED(ATTR_UNUSED, $unx)
192                 AC_MSG_RESULT($un)
193                 uns=false)
194                 fi
195         done
196 if $uns;then AC_DEFINE(ATTR_UNUSED,) AC_MSG_RESULT(no);fi
197
198 AC_MSG_CHECKING([for printf style attribute])
199 AC_TRY_COMPILE([
200 #ifdef HAVE_STDDEF_H
201 #include <stddef.h>
202 #endif
203 void testf(char *fmt,...) __attribute__((format(printf,1,2)));
204 void testf(char *fmt,...) {}], [testf("%d",1);],
205         AC_DEFINE(HAVE_PRINTFORMAT) AC_MSG_RESULT(yes),
206                                     AC_MSG_RESULT(no)
207         )
208
209 AC_MSG_CHECKING([for offsetof macro])
210 AC_TRY_COMPILE([
211 #ifdef HAVE_STDDEF_H
212 #include <stddef.h>
213 #endif
214 struct x { int a; };], [return(offsetof(struct x,a));],
215         AC_DEFINE(HAVE_OFFSETOF) AC_MSG_RESULT(yes),
216                                  AC_MSG_RESULT(no)
217         )
218
219 AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF))
220 AC_CHECK_FUNC(vsnprintf, AC_DEFINE(HAVE_VSNPRINTF))
221
222 dnl FIXME: select(3) missing here but what to do anyway
223 AC_CHECK_FUNCS(siginterrupt strerror strchr strrchr memmove atexit strcasecmp poll)
224
225 AC_TYPE_SIGNAL
226 AC_TYPE_PID_T
227
228 dnl FIXME: mktime(3) missing here
229 AC_REPLACE_FUNCS(strdup usleep)
230
231 GCC_NEED_DECLARATION(gethostname,[
232 #ifdef HAVE_UNISTD_H
233 #include <unistd.h>
234 #endif])
235 GCC_NEED_DECLARATION(kill,[
236 #ifdef HAVE_SYS_TYPES_H
237 #include <sys/types.h>
238 #endif
239 #ifdef HAVE_SIGNAL_H
240 #include <signal.h>
241 #endif])
242 GCC_NEED_DECLARATION(snprintf,[
243 #ifdef HAVE_STDIO_H
244 #include <stdio.h>
245 #endif])
246 GCC_NEED_DECLARATION(vsnprintf,[
247 #ifdef HAVE_STDIO_H
248 #include <stdio.h>
249 #endif
250 #ifdef HAVE_STDARG_H
251 #include <stdarg.h>
252 #endif])
253 GCC_NEED_DECLARATION(strdup,[
254 #ifdef HAVE_STRING_H
255 #include <string.h>
256 #endif])
257 GCC_NEED_DECLARATION(usleep,[
258 #ifdef HAVE_UNISTD_H
259 #include <unistd.h>
260 #endif])
261 GCC_NEED_DECLARATION(strcasecmp,[
262 #ifdef HAVE_STRING_H
263 #include <string.h>
264 #endif])
265 GCC_NEED_DECLARATION(siginterrupt,[
266 #ifdef HAVE_SIGNAL_H
267 #include <signal.h>
268 #endif])
269 GCC_NEED_DECLARATION(popen,[
270 #ifdef HAVE_STDIO_H
271 #include <stdio.h>
272 #endif])
273 GCC_NEED_DECLARATION(pclose,[
274 #ifdef HAVE_STDIO_H
275 #include <stdio.h>
276 #endif])
277 GCC_NEED_DECLARATION(gettext,[
278 #ifdef HAVE_LIBINTL_H
279 #include <libintl.h>
280 #endif])
281
282 # Final output.
283
284 if test "$ACLOCAL" = "aclocal";then
285   ACLOCAL="$ACLOCAL -I ."
286 fi
287
288 AC_OUTPUT([Makefile
289 mdsms.spec
290 macros/Makefile
291 po/Makefile.in
292 intl/Makefile])
293
294 dnl FIXME: Why is "po/POTFILES" being substituted?
295 echo mdsms.c >po/POTFILES.in
296 make -C po Makefile
297
298 echo done.