Initial untested implementation of --ring-send.
[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.0)
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 dnl Checks for programs.
30 AC_PROG_CC
31 if test "$USE_MAINTAINER_MODE" = yes;then
32   if test "$GCC" = yes;then
33                 CFLAGS="-Wall -ansi -pedantic -ggdb"
34                 LDFLAGS="$LDFLAGS -lefence"
35                 fi
36 else
37         LDFLAGS="-s"
38   AC_DEFINE(NDEBUG)
39         fi
40
41 AC_PROG_CPP
42
43 dnl Checks for pathnames.
44
45 AC_MSG_CHECKING([for modem lock directory])
46 dirx=""
47 if test "$with_lock_directory" = no;then
48   AC_MSG_RESULT([user disabled])
49 else
50   if test yes = "$with_lock_directory" \
51            -o  -z   "$with_lock_directory";then
52     for dira in /usr /var         ;do
53                 for dirb in /spool ""         ;do
54                 for dirc in /uucp /locks /lock;do
55                   dir="${dira}${dirb}${dirc}"
56                   if test -d "$dir";then dirx="$dir";fi
57                         done;done;done
58     if test -z "$dirx";then
59             AC_MSG_RESULT([none found, disabled])
60     else
61                   AC_MSG_RESULT([$dirx])
62     fi
63   else
64     dirx="$with_lock_directory"
65                 if test -d "$dirx";then AC_MSG_RESULT([$dirx])
66                 else AC_MSG_RESULT([warning - directory doesn't exist: $dirx])
67                 fi
68         fi
69 fi
70 if test -z "$dirx";then AC_DEFINE(DEF_LOCKFILE,[""])
71 else AC_DEFINE_UNQUOTED(DEF_LOCKFILE,"${dirx}/LCK..%s")
72 fi
73
74 dnl Checks for libraries.
75
76 dnl Checks for header files.
77 AC_HEADER_STDC
78
79 dnl Checks for typedefs, structures, and compiler characteristics.
80
81 AC_C_CONST
82 AC_C_INLINE
83
84 dnl Checks for library functions.
85
86 if test "$with_getopt" = no;then
87         AC_CHECK_FUNCS(getopt_long)
88         fi
89
90 if test "$enable_debug" = yes;then
91         AC_DEFINE(DEBUG)
92         fi
93
94 AC_MSG_CHECKING(whether to use included getopt)
95 if test "$with_getopt" = yes -o "$ac_cv_func_getopt_long" != yes ;then
96         LIBOBJS="$LIBOBJS getopt1.o getopt.o"
97            AC_MSG_RESULT(yes)
98 else AC_MSG_RESULT(no)
99 fi
100
101 AC_CHECK_HEADERS(assert.h ctype.h errno.h fcntl.h limits.h signal.h stdarg.h)
102 AC_CHECK_HEADERS(stdio.h stdlib.h string.h sys/poll.h sys/stat.h sys/time.h)
103 AC_CHECK_HEADERS(sys/types.h termios.h time.h unistd.h)
104
105 AC_CHECK_FUNC(MAX, AC_DEFINE(HAVE_MAX) ,
106         AC_CHECK_FUNC(max, AC_DEFINE(MAX, max) AC_DEFINE(HAVE_MAX))
107         )
108
109 AC_CHECK_FUNC(MIN, AC_DEFINE(HAVE_MIN) ,
110         AC_CHECK_FUNC(min, AC_DEFINE(MIN, min) AC_DEFINE(HAVE_MIN))
111         )
112
113 AC_MSG_CHECKING([for LINE_MAX])
114 AC_TRY_COMPILE([
115 #ifdef HAVE_LIMITS_H
116 #include <limits.h>
117 #endif], [LINE_MAX;],
118         AC_DEFINE(HAVE_LINE_MAX)  AC_MSG_RESULT(yes),
119         AC_DEFINE(LINE_MAX, 4096) AC_MSG_RESULT(no))
120
121 AC_MSG_CHECKING([for CBAUD])
122 AC_TRY_COMPILE([
123 #ifdef HAVE_TERMIOS_H
124 #include <termios.h>
125 #endif], [CBAUD;],
126         AC_DEFINE(HAVE_CBAUD) AC_MSG_RESULT(yes),
127         AC_DEFINE(CBAUD, 0)   AC_MSG_RESULT(no))
128
129 AC_MSG_CHECKING([for CBAUDEX])
130 AC_TRY_COMPILE([
131 #ifdef HAVE_TERMIOS_H
132 #include <termios.h>
133 #endif], [CBAUDEX;],
134         AC_DEFINE(HAVE_CBAUDEX) AC_MSG_RESULT(yes),
135         AC_DEFINE(CBAUDEX, 0)   AC_MSG_RESULT(no))
136
137 AC_MSG_CHECKING([for FD_SETSIZE])
138 AC_TRY_COMPILE([
139 #ifdef HAVE_SYS_TIME_H
140 #include <sys/time.h>
141 #endif
142 #ifdef HAVE_SYS_TYPES_H
143 #include <sys/types.h>
144 #endif
145 #ifdef HAVE_UNISTD_H
146 #include <unistd.h>
147 #endif], [FD_SETSIZE;],
148         AC_DEFINE(HAVE_FD_SETSIZE) AC_MSG_RESULT(yes),
149                                    AC_MSG_RESULT(no))
150
151 AC_MSG_CHECKING([for unused attribute])
152 uns=true
153 for un in __unused__ unused;do
154   if $uns;then
155                 unx="__attribute__ (($un))"
156                 AC_TRY_COMPILE([
157 #ifdef HAVE_STDDEF_H
158 #include <stddef.h>
159 #endif],[char untest $unx;],
160                 AC_DEFINE_UNQUOTED(ATTR_UNUSED, $unx)
161                 AC_MSG_RESULT($un)
162                 uns=false)
163                 fi
164         done
165 if $uns;then AC_DEFINE(ATTR_UNUSED,) AC_MSG_RESULT(no);fi
166
167 AC_MSG_CHECKING([for printf style attribute])
168 AC_TRY_COMPILE([
169 #ifdef HAVE_STDDEF_H
170 #include <stddef.h>
171 #endif
172 void testf(char *fmt,...) __attribute__((format(printf,1,2)));
173 void testf(char *fmt,...) {}], [testf("%d",1);],
174         AC_DEFINE(HAVE_PRINTFORMAT) AC_MSG_RESULT(yes),
175                                     AC_MSG_RESULT(no)
176         )
177
178 AC_MSG_CHECKING([for offsetof macro])
179 AC_TRY_COMPILE([
180 #ifdef HAVE_STDDEF_H
181 #include <stddef.h>
182 #endif
183 struct x { int a; };], [return(offsetof(struct x,a));],
184         AC_DEFINE(HAVE_OFFSETOF) AC_MSG_RESULT(yes),
185                                  AC_MSG_RESULT(no)
186         )
187
188 AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF))
189 AC_CHECK_FUNC(vsnprintf, AC_DEFINE(HAVE_VSNPRINTF))
190
191 dnl FIXME: select(3) missing here but what to do anyway
192 AC_CHECK_FUNCS(siginterrupt strerror strchr strrchr memmove atexit strcasecmp poll)
193
194 AC_TYPE_SIGNAL
195 AC_TYPE_PID_T
196
197 dnl FIXME: mktime(3) missing here
198 AC_REPLACE_FUNCS(strdup usleep)
199
200 GCC_NEED_DECLARATION(gethostname,[
201 #ifdef HAVE_UNISTD_H
202 #include <unistd.h>
203 #endif])
204 GCC_NEED_DECLARATION(kill,[
205 #ifdef HAVE_SYS_TYPES_H
206 #include <sys/types.h>
207 #endif
208 #ifdef HAVE_SIGNAL_H
209 #include <signal.h>
210 #endif])
211 GCC_NEED_DECLARATION(snprintf,[
212 #ifdef HAVE_STDIO_H
213 #include <stdio.h>
214 #endif])
215 GCC_NEED_DECLARATION(vsnprintf,[
216 #ifdef HAVE_STDIO_H
217 #include <stdio.h>
218 #endif
219 #ifdef HAVE_STDARG_H
220 #include <stdarg.h>
221 #endif])
222 GCC_NEED_DECLARATION(strdup,[
223 #ifdef HAVE_STRING_H
224 #include <string.h>
225 #endif])
226 GCC_NEED_DECLARATION(usleep,[
227 #ifdef HAVE_UNISTD_H
228 #include <unistd.h>
229 #endif])
230 GCC_NEED_DECLARATION(strcasecmp,[
231 #ifdef HAVE_STRING_H
232 #include <string.h>
233 #endif])
234 GCC_NEED_DECLARATION(siginterrupt,[
235 #ifdef HAVE_SIGNAL_H
236 #include <signal.h>
237 #endif])
238 GCC_NEED_DECLARATION(popen,[
239 #ifdef HAVE_STDIO_H
240 #include <stdio.h>
241 #endif])
242 GCC_NEED_DECLARATION(pclose,[
243 #ifdef HAVE_STDIO_H
244 #include <stdio.h>
245 #endif])
246
247 # Final output.
248
249 if test "$ACLOCAL" = "aclocal";then
250   ACLOCAL="$ACLOCAL -I ."
251 fi
252
253 AC_SUBST(LIBOBJS)
254
255 AC_OUTPUT(Makefile)