Reflected mdsms.c:1.21->1.22 updates
[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 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         LIBOBJS="$LIBOBJS getopt1.o getopt.o"
107            AC_MSG_RESULT(yes)
108 else AC_MSG_RESULT(no)
109 fi
110
111 AC_CHECK_HEADERS(assert.h ctype.h errno.h fcntl.h limits.h signal.h stdarg.h)
112 AC_CHECK_HEADERS(stdio.h stdlib.h string.h sys/poll.h sys/stat.h sys/time.h)
113 AC_CHECK_HEADERS(sys/types.h sys/wait.h termios.h time.h unistd.h)
114
115 AC_CHECK_FUNC(MAX, AC_DEFINE(HAVE_MAX) ,
116         AC_CHECK_FUNC(max, AC_DEFINE(MAX, max) AC_DEFINE(HAVE_MAX))
117         )
118
119 AC_CHECK_FUNC(MIN, AC_DEFINE(HAVE_MIN) ,
120         AC_CHECK_FUNC(min, AC_DEFINE(MIN, min) AC_DEFINE(HAVE_MIN))
121         )
122
123 AC_MSG_CHECKING([for LINE_MAX])
124 AC_TRY_COMPILE([
125 #ifdef HAVE_LIMITS_H
126 #include <limits.h>
127 #endif], [LINE_MAX;],
128         AC_DEFINE(HAVE_LINE_MAX)  AC_MSG_RESULT(yes),
129         AC_DEFINE(LINE_MAX, 4096) AC_MSG_RESULT(no))
130
131 AC_MSG_CHECKING([for CBAUD])
132 AC_TRY_COMPILE([
133 #ifdef HAVE_TERMIOS_H
134 #include <termios.h>
135 #endif], [CBAUD;],
136         AC_DEFINE(HAVE_CBAUD) AC_MSG_RESULT(yes),
137         AC_DEFINE(CBAUD, 0)   AC_MSG_RESULT(no))
138
139 AC_MSG_CHECKING([for CBAUDEX])
140 AC_TRY_COMPILE([
141 #ifdef HAVE_TERMIOS_H
142 #include <termios.h>
143 #endif], [CBAUDEX;],
144         AC_DEFINE(HAVE_CBAUDEX) AC_MSG_RESULT(yes),
145         AC_DEFINE(CBAUDEX, 0)   AC_MSG_RESULT(no))
146
147 AC_MSG_CHECKING([for CRTSCTS])
148 AC_TRY_COMPILE([
149 #ifdef HAVE_TERMIOS_H
150 #include <termios.h>
151 #endif], [CRTSCTS;],
152         AC_DEFINE(HAVE_CRTSCTS) AC_MSG_RESULT(yes),[
153         if test "$USE_MAINTAINER_MODE" = yes ;then
154                 AC_DEFINE(HAVE_CRTSCTS) AC_MSG_RESULT(faked for maintainer)
155                 # from "RedHat: glibc-devel-2.2-5/bits/termios.h"
156                 AC_DEFINE(CRTSCTS, 020000000000)
157         else
158                 AC_DEFINE(CRTSCTS, 0)   AC_MSG_RESULT(no)
159         fi
160         ])
161
162 AC_MSG_CHECKING([for FD_SETSIZE])
163 AC_TRY_COMPILE([
164 #ifdef HAVE_SYS_TIME_H
165 #include <sys/time.h>
166 #endif
167 #ifdef HAVE_SYS_TYPES_H
168 #include <sys/types.h>
169 #endif
170 #ifdef HAVE_UNISTD_H
171 #include <unistd.h>
172 #endif], [FD_SETSIZE;],
173         AC_DEFINE(HAVE_FD_SETSIZE) AC_MSG_RESULT(yes),
174                                    AC_MSG_RESULT(no))
175
176 AC_MSG_CHECKING([for unused attribute])
177 uns=true
178 for un in __unused__ unused;do
179   if $uns;then
180                 unx="__attribute__ (($un))"
181                 AC_TRY_COMPILE([
182 #ifdef HAVE_STDDEF_H
183 #include <stddef.h>
184 #endif],[char untest $unx;],
185                 AC_DEFINE_UNQUOTED(ATTR_UNUSED, $unx)
186                 AC_MSG_RESULT($un)
187                 uns=false)
188                 fi
189         done
190 if $uns;then AC_DEFINE(ATTR_UNUSED,) AC_MSG_RESULT(no);fi
191
192 AC_MSG_CHECKING([for printf style attribute])
193 AC_TRY_COMPILE([
194 #ifdef HAVE_STDDEF_H
195 #include <stddef.h>
196 #endif
197 void testf(char *fmt,...) __attribute__((format(printf,1,2)));
198 void testf(char *fmt,...) {}], [testf("%d",1);],
199         AC_DEFINE(HAVE_PRINTFORMAT) AC_MSG_RESULT(yes),
200                                     AC_MSG_RESULT(no)
201         )
202
203 AC_MSG_CHECKING([for offsetof macro])
204 AC_TRY_COMPILE([
205 #ifdef HAVE_STDDEF_H
206 #include <stddef.h>
207 #endif
208 struct x { int a; };], [return(offsetof(struct x,a));],
209         AC_DEFINE(HAVE_OFFSETOF) AC_MSG_RESULT(yes),
210                                  AC_MSG_RESULT(no)
211         )
212
213 AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF))
214 AC_CHECK_FUNC(vsnprintf, AC_DEFINE(HAVE_VSNPRINTF))
215
216 dnl FIXME: select(3) missing here but what to do anyway
217 AC_CHECK_FUNCS(siginterrupt strerror strchr strrchr memmove atexit strcasecmp poll)
218
219 AC_TYPE_SIGNAL
220 AC_TYPE_PID_T
221
222 dnl FIXME: mktime(3) missing here
223 AC_REPLACE_FUNCS(strdup usleep)
224
225 GCC_NEED_DECLARATION(gethostname,[
226 #ifdef HAVE_UNISTD_H
227 #include <unistd.h>
228 #endif])
229 GCC_NEED_DECLARATION(kill,[
230 #ifdef HAVE_SYS_TYPES_H
231 #include <sys/types.h>
232 #endif
233 #ifdef HAVE_SIGNAL_H
234 #include <signal.h>
235 #endif])
236 GCC_NEED_DECLARATION(snprintf,[
237 #ifdef HAVE_STDIO_H
238 #include <stdio.h>
239 #endif])
240 GCC_NEED_DECLARATION(vsnprintf,[
241 #ifdef HAVE_STDIO_H
242 #include <stdio.h>
243 #endif
244 #ifdef HAVE_STDARG_H
245 #include <stdarg.h>
246 #endif])
247 GCC_NEED_DECLARATION(strdup,[
248 #ifdef HAVE_STRING_H
249 #include <string.h>
250 #endif])
251 GCC_NEED_DECLARATION(usleep,[
252 #ifdef HAVE_UNISTD_H
253 #include <unistd.h>
254 #endif])
255 GCC_NEED_DECLARATION(strcasecmp,[
256 #ifdef HAVE_STRING_H
257 #include <string.h>
258 #endif])
259 GCC_NEED_DECLARATION(siginterrupt,[
260 #ifdef HAVE_SIGNAL_H
261 #include <signal.h>
262 #endif])
263 GCC_NEED_DECLARATION(popen,[
264 #ifdef HAVE_STDIO_H
265 #include <stdio.h>
266 #endif])
267 GCC_NEED_DECLARATION(pclose,[
268 #ifdef HAVE_STDIO_H
269 #include <stdio.h>
270 #endif])
271
272 # Final output.
273
274 if test "$ACLOCAL" = "aclocal";then
275   ACLOCAL="$ACLOCAL -I ."
276 fi
277
278 AC_SUBST(LIBOBJS)
279
280 AC_OUTPUT([Makefile
281 mdsms.spec
282 po/Makefile.in
283 intl/Makefile],[sed -e "/POTFILES =/r po/POTFILES" -e "s/ ChangeLog / /" po/Makefile.in > po/Makefile])