First alpha release.
[mdsms.git] / configure.in
1 # $Id$
2 #
3 # $Log$
4 # Revision 1.1.1.1  1999/05/26 13:06:26  short
5 # First alpha release.
6 #
7
8 dnl Process this file with autoconf to produce a configure script.
9 AC_INIT(mdsms.c)
10 AM_INIT_AUTOMAKE(mdsms, 1.0)
11 AM_CONFIG_HEADER(config.h)
12 AM_MAINTAINER_MODE
13
14 dnl Configuration switches.
15
16 AC_MSG_CHECKING([whether debugging is requested])
17 AC_ARG_ENABLE(debug,
18 [  --enable-debug          enable debugging output to stderr],
19     enable_debug=$enableval, enable_debug=no)
20 AC_MSG_RESULT($enable_debug)
21
22 AC_MSG_CHECKING([whether included getopt is requested])
23 AC_ARG_WITH(included-getopt,
24 [  --with-included-getopt  use included getopt(3)],
25      with_getopt=$withval, with_getopt=no)
26 AC_MSG_RESULT($with_getopt)
27
28 AC_MSG_CHECKING([for user-specified lock directory])
29 AC_ARG_WITH(lock-directory,
30 [  --with-lock-directory   override default search for modem lock directory],
31      with_lock_directory=$withval, with_lock_directory=)
32 AC_MSG_RESULT($with_lock_directory)
33
34 dnl Checks for programs.
35 AC_PROG_CC
36 if test "$USE_MAINTAINER_MODE" = yes;then
37   if test "$GCC" = yes;then
38                 CFLAGS="-Wall -ansi -pedantic -ggdb"
39                 LDFLAGS="$LDFLAGS -lefence"
40                 fi
41 else
42         LDFLAGS="-s"
43   AC_DEFINE(NDEBUG)
44         fi
45
46 AC_PROG_CPP
47
48 dnl Checks for pathnames.
49
50 AC_MSG_CHECKING([for modem lock directory])
51 dirx=""
52 if test "$with_lock_directory" = no;then
53   AC_MSG_RESULT([user disabled])
54 else
55   if test yes = "$with_lock_directory" \
56            -o  -z   "$with_lock_directory";then
57     for dira in /usr /var         ;do
58                 for dirb in /spool ""         ;do
59                 for dirc in /uucp /locks /lock;do
60                   dir="${dira}${dirb}${dirc}"
61                   if test -d "$dir";then dirx="$dir";fi
62                         done;done;done
63     if test -z "$dirx";then
64             AC_MSG_RESULT([none found, disabled])
65     else
66                   AC_MSG_RESULT([$dirx])
67     fi
68   else
69     dirx="$with_lock_directory"
70                 if test -d "$dirx";then AC_MSG_RESULT([$dirx])
71                 else AC_MSG_RESULT([warning - directory doesn't exist: $dirx])
72                 fi
73         fi
74 fi
75 if test -z "$dirx";then AC_DEFINE(DEF_LOCKFILE,[""])
76 else AC_DEFINE_UNQUOTED(DEF_LOCKFILE,"${dirx}/LCK..%s")
77 fi
78
79 dnl Checks for libraries.
80
81 dnl Checks for header files.
82 AC_HEADER_STDC
83
84 dnl Checks for typedefs, structures, and compiler characteristics.
85
86 AC_C_CONST
87 AC_C_INLINE
88
89 dnl Checks for library functions.
90
91 if test "$with_getopt" = no;then
92         AC_CHECK_FUNCS(getopt_long)
93         fi
94
95 if test "$enable_debug" = yes;then
96         AC_DEFINE(DEBUG)
97         fi
98
99 AC_MSG_CHECKING(whether to use included getopt)
100 if test "$with_getopt" = yes -o "$ac_cv_func_getopt_long" != yes ;then
101         LIBOBJS="$LIBOBJS getopt1.o getopt.o"
102            AC_MSG_RESULT(yes)
103 else AC_MSG_RESULT(no)
104 fi
105
106 AC_CHECK_FUNC(MAX, AC_DEFINE(HAVE_MAX) ,
107         AC_CHECK_FUNC(max, AC_DEFINE(MAX, max) AC_DEFINE(HAVE_MAX))
108         )
109
110 AC_CHECK_FUNC(MIN, AC_DEFINE(HAVE_MIN) ,
111         AC_CHECK_FUNC(min, AC_DEFINE(MIN, min) AC_DEFINE(HAVE_MIN))
112         )
113
114 AC_MSG_CHECKING([for LINE_MAX])
115 AC_TRY_COMPILE([#include <limits.h>], [LINE_MAX;],
116         AC_DEFINE(HAVE_LINE_MAX)  AC_MSG_RESULT(yes),
117         AC_DEFINE(LINE_MAX, 4096) AC_MSG_RESULT(no))
118
119 AC_MSG_CHECKING([for CBAUD])
120 AC_TRY_COMPILE([#include <termios.h>], [CBAUD;],
121         AC_DEFINE(HAVE_CBAUD) AC_MSG_RESULT(yes),
122         AC_DEFINE(CBAUD, 0)   AC_MSG_RESULT(no))
123
124 AC_MSG_CHECKING([for CBAUDEX])
125 AC_TRY_COMPILE([#include <termios.h>], [CBAUDEX;],
126         AC_DEFINE(HAVE_CBAUDEX) AC_MSG_RESULT(yes),
127         AC_DEFINE(CBAUDEX, 0)   AC_MSG_RESULT(no))
128
129 AC_MSG_CHECKING([for unused attribute])
130 uns=true
131 for un in __unused__ unused;do
132   if $uns;then
133                 unx="__attribute__ (($un))"
134                 AC_TRY_COMPILE([#include <stddef.h>],[char untest $unx;],
135                 AC_DEFINE_UNQUOTED(ATTR_UNUSED, $unx)
136                 AC_MSG_RESULT($un)
137                 uns=false)
138                 fi
139         done
140 if $uns;then AC_DEFINE(ATTR_UNUSED,) AC_MSG_RESULT(no);fi
141
142 AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF))
143 AC_CHECK_FUNC(vsnprintf, AC_DEFINE(HAVE_VSNPRINTF))
144
145 AC_TYPE_SIGNAL
146 AC_TYPE_PID_T
147
148 AC_REPLACE_FUNCS(strdup)
149 dnl AC_MSG_CHECKING([for strdup])
150 dnl AC_TRY_COMPILE([#include <string.h>], [strdup("");],
151 dnl     AC_DEFINE(HAVE_STRDUP)  AC_MSG_RESULT(yes),
152 dnl     LIBOBJS="$LIBOBJS strdup.o" AC_MSG_RESULT(no))
153
154 AC_MSG_CHECKING([for working %m in printf])
155 AC_TRY_RUN([int main() { char s[100];
156         sprintf(s,"%m");
157         return(!(strcmp(s,"m") && strcmp(s,"%m")));
158         }],AC_DEFINE(PRINTF_WORKS_PM) AC_MSG_RESULT(yes),AC_MSG_RESULT(no),AC_MSG_RESULT(avoiding))
159
160 # Final output.
161
162 AC_SUBST(LIBOBJS)
163
164 AC_OUTPUT(Makefile)