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