Crossplatformity: MIN and MAX functiona are _always_ redefined, no #ifdefs
[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.1)
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_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 CRTSCTS])
140 AC_TRY_COMPILE([
141 #ifdef HAVE_TERMIOS_H
142 #include <termios.h>
143 #endif], [CRTSCTS;],
144         AC_DEFINE(HAVE_CRTSCTS) AC_MSG_RESULT(yes),[
145         if test "$USE_MAINTAINER_MODE" = yes ;then
146                 AC_DEFINE(HAVE_CRTSCTS) AC_MSG_RESULT(faked for maintainer)
147                 # from "RedHat: glibc-devel-2.2-5/bits/termios.h"
148                 AC_DEFINE(CRTSCTS, 020000000000)
149         else
150                 AC_DEFINE(CRTSCTS, 0)   AC_MSG_RESULT(no)
151         fi
152         ])
153
154 AC_MSG_CHECKING([for FD_SETSIZE])
155 AC_TRY_COMPILE([
156 #ifdef HAVE_SYS_TIME_H
157 #include <sys/time.h>
158 #endif
159 #ifdef HAVE_SYS_TYPES_H
160 #include <sys/types.h>
161 #endif
162 #ifdef HAVE_UNISTD_H
163 #include <unistd.h>
164 #endif], [FD_SETSIZE;],
165         AC_DEFINE(HAVE_FD_SETSIZE) AC_MSG_RESULT(yes),
166                                    AC_MSG_RESULT(no))
167
168 AC_MSG_CHECKING([for unused attribute])
169 uns=true
170 for un in __unused__ unused;do
171   if $uns;then
172                 unx="__attribute__ (($un))"
173                 AC_TRY_COMPILE([
174 #ifdef HAVE_STDDEF_H
175 #include <stddef.h>
176 #endif],[char untest $unx;],
177                 AC_DEFINE_UNQUOTED(ATTR_UNUSED, $unx)
178                 AC_MSG_RESULT($un)
179                 uns=false)
180                 fi
181         done
182 if $uns;then AC_DEFINE(ATTR_UNUSED,) AC_MSG_RESULT(no);fi
183
184 AC_MSG_CHECKING([for printf style attribute])
185 AC_TRY_COMPILE([
186 #ifdef HAVE_STDDEF_H
187 #include <stddef.h>
188 #endif
189 void testf(char *fmt,...) __attribute__((format(printf,1,2)));
190 void testf(char *fmt,...) {}], [testf("%d",1);],
191         AC_DEFINE(HAVE_PRINTFORMAT) AC_MSG_RESULT(yes),
192                                     AC_MSG_RESULT(no)
193         )
194
195 AC_MSG_CHECKING([for offsetof macro])
196 AC_TRY_COMPILE([
197 #ifdef HAVE_STDDEF_H
198 #include <stddef.h>
199 #endif
200 struct x { int a; };], [return(offsetof(struct x,a));],
201         AC_DEFINE(HAVE_OFFSETOF) AC_MSG_RESULT(yes),
202                                  AC_MSG_RESULT(no)
203         )
204
205 AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF))
206 AC_CHECK_FUNC(vsnprintf, AC_DEFINE(HAVE_VSNPRINTF))
207
208 dnl FIXME: select(3) missing here but what to do anyway
209 AC_CHECK_FUNCS(siginterrupt strerror strchr strrchr memmove atexit strcasecmp poll)
210
211 AC_TYPE_SIGNAL
212 AC_TYPE_PID_T
213
214 dnl FIXME: mktime(3) missing here
215 AC_REPLACE_FUNCS(strdup usleep)
216
217 GCC_NEED_DECLARATION(gethostname,[
218 #ifdef HAVE_UNISTD_H
219 #include <unistd.h>
220 #endif])
221 GCC_NEED_DECLARATION(kill,[
222 #ifdef HAVE_SYS_TYPES_H
223 #include <sys/types.h>
224 #endif
225 #ifdef HAVE_SIGNAL_H
226 #include <signal.h>
227 #endif])
228 GCC_NEED_DECLARATION(snprintf,[
229 #ifdef HAVE_STDIO_H
230 #include <stdio.h>
231 #endif])
232 GCC_NEED_DECLARATION(vsnprintf,[
233 #ifdef HAVE_STDIO_H
234 #include <stdio.h>
235 #endif
236 #ifdef HAVE_STDARG_H
237 #include <stdarg.h>
238 #endif])
239 GCC_NEED_DECLARATION(strdup,[
240 #ifdef HAVE_STRING_H
241 #include <string.h>
242 #endif])
243 GCC_NEED_DECLARATION(usleep,[
244 #ifdef HAVE_UNISTD_H
245 #include <unistd.h>
246 #endif])
247 GCC_NEED_DECLARATION(strcasecmp,[
248 #ifdef HAVE_STRING_H
249 #include <string.h>
250 #endif])
251 GCC_NEED_DECLARATION(siginterrupt,[
252 #ifdef HAVE_SIGNAL_H
253 #include <signal.h>
254 #endif])
255 GCC_NEED_DECLARATION(popen,[
256 #ifdef HAVE_STDIO_H
257 #include <stdio.h>
258 #endif])
259 GCC_NEED_DECLARATION(pclose,[
260 #ifdef HAVE_STDIO_H
261 #include <stdio.h>
262 #endif])
263
264 # Final output.
265
266 if test "$ACLOCAL" = "aclocal";then
267   ACLOCAL="$ACLOCAL -I ."
268 fi
269
270 AC_SUBST(LIBOBJS)
271
272 AC_OUTPUT([Makefile
273 mdsms.spec
274 po/Makefile.in
275 intl/Makefile],[sed -e "/POTFILES =/r po/POTFILES" -e "s/ ChangeLog / /" po/Makefile.in > po/Makefile])