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