ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/ptytty.m4
Revision: 1.27
Committed: Wed Jul 6 10:04:02 2011 UTC (12 years, 11 months ago) by sf-exg
Branch: MAIN
Changes since 1.26: +1 -1 lines
Log Message:
Fix write-strings warning in test program.

File Contents

# Content
1 dnl this file is part of libptytty, do not make local modifications
2 dnl http://software.schmorp.de/pkg/libptytty
3
4 AC_DEFUN([PT_FIND_FILE],
5 [AC_CACHE_CHECK(where $1 is located, pt_cv_path_$1,
6 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
7 #include <stdlib.h>
8 #include <sys/stat.h>
9 $5
10 int main()
11 {
12 const char **path, *list[] = { $4, NULL };
13 FILE *f = fopen("conftestval", "w");
14 if (!f) return 1;
15 #ifdef $2
16 fprintf(f, "%s\n", $2);
17 #elif defined($3)
18 fprintf(f, "%s\n", $3);
19 #else
20 for (path = list; *path; path++) {
21 struct stat st;
22 if (stat(*path, &st) == 0) {
23 fprintf(f, "%s\n", *path);
24 break;
25 }
26 }
27 #endif
28 return fclose(f) != 0;
29 }]])],[pt_cv_path_$1=`cat conftestval`],[pt_cv_path_$1=],
30 [AC_MSG_WARN(Define $2 in config.h manually)])])
31 if test x$pt_cv_path_$1 != x; then
32 AC_DEFINE_UNQUOTED($2, "$pt_cv_path_$1", Define location of $1)
33 fi])
34
35 AC_DEFUN([PTY_CHECK],
36 [
37 AC_CHECK_HEADERS( \
38 pty.h \
39 util.h \
40 libutil.h \
41 sys/ioctl.h \
42 sys/stropts.h \
43 stropts.h \
44 )
45
46 AC_CHECK_FUNCS( \
47 revoke \
48 _getpty \
49 getpt \
50 posix_openpt \
51 isastream \
52 setuid \
53 seteuid \
54 setreuid \
55 setresuid \
56 )
57
58 have_clone=no
59
60 AC_MSG_CHECKING(for /dev/ptc)
61 if test -e /dev/ptc; then
62 AC_MSG_RESULT(yes)
63 AC_DEFINE(CLONE_DEVICE, "/dev/ptc", [clone device filename])
64 have_clone=yes
65 else
66 AC_MSG_RESULT(no)
67 fi
68
69 case $host in
70 *-*-cygwin*)
71 have_clone=yes
72 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
73 ;;
74 *)
75 AC_MSG_CHECKING(for /dev/ptmx)
76 if test -e /dev/ptmx; then
77 AC_MSG_RESULT(yes)
78 AC_DEFINE(HAVE_DEV_PTMX, 1, [Define to 1 if you have /dev/ptmx])
79 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
80 have_clone=yes
81 else
82 AC_MSG_RESULT(no)
83 fi
84 ;;
85 esac
86
87 if test x$ac_cv_func_getpt = xyes -o x$ac_cv_func_posix_openpt = xyes -o x$have_clone = xyes; then
88 AC_MSG_CHECKING(for UNIX98 ptys)
89 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
90 [[grantpt(0);unlockpt(0);ptsname(0);]])],
91 [unix98_pty=yes
92 AC_DEFINE(UNIX98_PTY, 1, "")
93 AC_MSG_RESULT(yes)],
94 [AC_MSG_RESULT(no)])
95 fi
96
97 if test -z "$unix98_pty"; then
98 AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, ""))
99 fi
100 ])
101
102 AC_DEFUN([UTMP_CHECK],
103 [
104 support_utmp=yes
105 support_wtmp=yes
106 support_lastlog=yes
107
108 AC_ARG_ENABLE(utmp,
109 [AS_HELP_STRING([--enable-utmp],[enable utmp (utmpx) support])],
110 [if test x$enableval = xyes -o x$enableval = xno; then
111 support_utmp=$enableval
112 fi])
113
114 AC_ARG_ENABLE(wtmp,
115 [AS_HELP_STRING([--enable-wtmp],[enable wtmp (wtmpx) support (requires --enable-utmp)])],
116 [if test x$enableval = xyes -o x$enableval = xno; then
117 support_wtmp=$enableval
118 fi])
119
120 AC_ARG_ENABLE(lastlog,
121 [AS_HELP_STRING([--enable-lastlog],[enable lastlog support (requires --enable-utmp)])],
122 [if test x$enableval = xyes -o x$enableval = xno; then
123 support_lastlog=$enableval
124 fi])
125
126 if test x$support_utmp = xyes; then
127 AC_DEFINE(UTMP_SUPPORT, 1, Define if you want to have utmp/utmpx support)
128 fi
129 if test x$support_wtmp = xyes; then
130 AC_DEFINE(WTMP_SUPPORT, 1, Define if you want to have wtmp support when utmp/utmpx is enabled)
131 fi
132 if test x$support_lastlog = xyes; then
133 AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled)
134 fi
135
136 AC_CHECK_FUNCS( \
137 updwtmp \
138 updwtmpx \
139 updlastlogx \
140 )
141
142 AC_CHECK_HEADERS(lastlog.h)
143
144 dnl# --------------------------------------------------------------------------
145 dnl# DO ALL UTMP AND WTMP CHECKING
146 dnl# --------------------------------------------------------------------------
147 dnl# check for host field in utmp structure
148
149 dnl# --------------------------------------------
150 AC_CHECK_HEADERS(utmp.h,
151 AC_CHECK_TYPES([struct utmp], [], [], [
152 #include <sys/types.h>
153 #include <utmp.h>
154 ])
155
156 AC_CHECK_MEMBER([struct utmp.ut_host],
157 [AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)], [], [
158 #include <sys/types.h>
159 #include <utmp.h>
160 ])
161
162 AC_CHECK_MEMBER([struct utmp.ut_pid],
163 [AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)], [], [
164 #include <sys/types.h>
165 #include <utmp.h>
166 ])
167 ) dnl# AC_CHECK_HEADERS(utmp.h
168
169 dnl# --------------------------------------------
170
171 AC_CHECK_HEADERS(utmpx.h,
172 AC_CHECK_TYPES([struct utmpx], [], [], [
173 #include <sys/types.h>
174 #include <utmpx.h>
175 ])
176
177 AC_CHECK_MEMBER([struct utmpx.ut_host],
178 [AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)], [], [
179 #include <sys/types.h>
180 #include <utmpx.h>
181 ])
182
183 AC_CHECK_MEMBER([struct utmpx.ut_session],
184 [AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session)], [], [
185 #include <sys/types.h>
186 #include <utmpx.h>
187 ])
188 ) dnl# AC_CHECK_HEADERS(utmpx.h
189
190 dnl# --------------------------------------------------------------------------
191 dnl# check for struct lastlog
192 AC_CHECK_TYPES([struct lastlog], [], [], [
193 #include <sys/types.h>
194 #include <utmp.h>
195 #ifdef HAVE_LASTLOG_H
196 #include <lastlog.h>
197 #endif
198 ])
199
200 dnl# check for struct lastlogx
201 AC_CHECK_TYPES([struct lastlogx], [], [], [
202 #include <sys/types.h>
203 #include <utmpx.h>
204 #ifdef HAVE_LASTLOG_H
205 #include <lastlog.h>
206 #endif
207 ])
208
209 dnl# --------------------------------------------------------------------------
210 dnl# FIND FILES
211 dnl# --------------------------------------------------------------------------
212
213 dnl# find utmp
214 PT_FIND_FILE([utmp], [UTMP_FILE], [_PATH_UTMP],
215 ["/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp"],[
216 #include <sys/types.h>
217 #include <utmp.h>
218 ])
219
220 dnl# --------------------------------------------------------------------------
221
222 dnl# find wtmp
223 PT_FIND_FILE([wtmp], [WTMP_FILE], [_PATH_WTMP],
224 ["/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp"],[
225 #include <sys/types.h>
226 #ifdef HAVE_UTMP_H
227 #include <utmp.h>
228 #endif
229 ])
230 dnl# --------------------------------------------------------------------------
231
232 dnl# find wtmpx
233 PT_FIND_FILE([wtmpx], [WTMPX_FILE], [_PATH_WTMPX],
234 ["/var/log/wtmpx", "/var/adm/wtmpx"],[
235 #ifdef HAVE_UTMPX_H
236 #include <utmpx.h>
237 #endif
238 ])
239 dnl# --------------------------------------------------------------------------
240
241 dnl# find lastlog
242 PT_FIND_FILE([lastlog], [LASTLOG_FILE], [_PATH_LASTLOG],
243 ["/var/log/lastlog"],[
244 #include <sys/types.h>
245 #ifdef HAVE_UTMP_H
246 #include <utmp.h>
247 #endif
248 #ifdef HAVE_LASTLOG_H
249 #include <lastlog.h>
250 #endif
251 ])
252 dnl# --------------------------------------------------------------------------
253
254 dnl# find lastlogx
255 PT_FIND_FILE([lastlogx], [LASTLOGX_FILE], [_PATH_LASTLOGX],
256 ["/var/log/lastlogx", "/var/adm/lastlogx"],[
257 #ifdef HAVE_UTMPX_H
258 #include <utmpx.h>
259 #endif
260 ])
261 ])
262
263 AC_DEFUN([SCM_RIGHTS_CHECK],
264 [
265 AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds,
266 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
267 #include <cstddef> // broken bsds (is that redundant?) need this
268 #include <sys/types.h>
269 #include <sys/socket.h>
270 #include <sys/uio.h>
271 ]], [[
272 {
273 msghdr msg;
274 iovec iov;
275 char buf [100];
276 char data = 0;
277
278 iov.iov_base = &data;
279 iov.iov_len = 1;
280
281 msg.msg_iov = &iov;
282 msg.msg_iovlen = 1;
283 msg.msg_control = buf;
284 msg.msg_controllen = sizeof buf;
285
286 cmsghdr *cmsg = CMSG_FIRSTHDR (&msg);
287 cmsg->cmsg_level = SOL_SOCKET;
288 cmsg->cmsg_type = SCM_RIGHTS;
289 cmsg->cmsg_len = 100;
290
291 *(int *)CMSG_DATA (cmsg) = 5;
292
293 return sendmsg (3, &msg, 0);
294 }
295 ]])],[pt_cv_can_pass_fds=yes],[pt_cv_can_pass_fds=no])])
296 if test x$pt_cv_can_pass_fds = xyes; then
297 AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing)
298 else
299 AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability])
300 fi
301 ])
302
303 AC_DEFUN([TTY_GROUP_CHECK],
304 [
305 AC_CACHE_CHECK([for tty group], pt_cv_tty_group,
306 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
307 #include <sys/types.h>
308 #include <sys/stat.h>
309 #include <unistd.h>
310 #include <grp.h>
311
312 int main()
313 {
314 struct stat st;
315 struct group *gr;
316 char *tty;
317 gr = getgrnam("tty");
318 tty = ttyname(0);
319 if (gr != 0
320 && tty != 0
321 && (stat(tty, &st)) == 0
322 && st.st_gid == gr->gr_gid)
323 return 0;
324 else
325 return 1;
326 }]])],[pt_cv_tty_group=yes],[pt_cv_tty_group=no],[pt_cv_tty_group=no])])
327 if test x$pt_cv_tty_group = xyes; then
328 AC_DEFINE(TTY_GID_SUPPORT, 1, "")
329 fi])
330