ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/ptytty.m4
Revision: 1.28
Committed: Thu Nov 10 16:30:16 2011 UTC (12 years, 6 months ago) by sf-exg
Branch: MAIN
Changes since 1.27: +0 -31 lines
Log Message:
Get rid of runtime configure tests to find the multiplexer device.

We now assume that if the system provides the unix98 pty api but not
posix_openpt then it provides either the ptmx or ptc (aix) device.

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 AC_MSG_CHECKING(for UNIX98 ptys)
59 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
60 [[grantpt(0);unlockpt(0);ptsname(0);]])],
61 [unix98_pty=yes
62 AC_DEFINE(UNIX98_PTY, 1, "")
63 AC_MSG_RESULT(yes)],
64 [AC_MSG_RESULT(no)])
65
66 if test -z "$unix98_pty"; then
67 AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, ""))
68 fi
69 ])
70
71 AC_DEFUN([UTMP_CHECK],
72 [
73 support_utmp=yes
74 support_wtmp=yes
75 support_lastlog=yes
76
77 AC_ARG_ENABLE(utmp,
78 [AS_HELP_STRING([--enable-utmp],[enable utmp (utmpx) support])],
79 [if test x$enableval = xyes -o x$enableval = xno; then
80 support_utmp=$enableval
81 fi])
82
83 AC_ARG_ENABLE(wtmp,
84 [AS_HELP_STRING([--enable-wtmp],[enable wtmp (wtmpx) support (requires --enable-utmp)])],
85 [if test x$enableval = xyes -o x$enableval = xno; then
86 support_wtmp=$enableval
87 fi])
88
89 AC_ARG_ENABLE(lastlog,
90 [AS_HELP_STRING([--enable-lastlog],[enable lastlog support (requires --enable-utmp)])],
91 [if test x$enableval = xyes -o x$enableval = xno; then
92 support_lastlog=$enableval
93 fi])
94
95 if test x$support_utmp = xyes; then
96 AC_DEFINE(UTMP_SUPPORT, 1, Define if you want to have utmp/utmpx support)
97 fi
98 if test x$support_wtmp = xyes; then
99 AC_DEFINE(WTMP_SUPPORT, 1, Define if you want to have wtmp support when utmp/utmpx is enabled)
100 fi
101 if test x$support_lastlog = xyes; then
102 AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled)
103 fi
104
105 AC_CHECK_FUNCS( \
106 updwtmp \
107 updwtmpx \
108 updlastlogx \
109 )
110
111 AC_CHECK_HEADERS(lastlog.h)
112
113 dnl# --------------------------------------------------------------------------
114 dnl# DO ALL UTMP AND WTMP CHECKING
115 dnl# --------------------------------------------------------------------------
116 dnl# check for host field in utmp structure
117
118 dnl# --------------------------------------------
119 AC_CHECK_HEADERS(utmp.h,
120 AC_CHECK_TYPES([struct utmp], [], [], [
121 #include <sys/types.h>
122 #include <utmp.h>
123 ])
124
125 AC_CHECK_MEMBER([struct utmp.ut_host],
126 [AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)], [], [
127 #include <sys/types.h>
128 #include <utmp.h>
129 ])
130
131 AC_CHECK_MEMBER([struct utmp.ut_pid],
132 [AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)], [], [
133 #include <sys/types.h>
134 #include <utmp.h>
135 ])
136 ) dnl# AC_CHECK_HEADERS(utmp.h
137
138 dnl# --------------------------------------------
139
140 AC_CHECK_HEADERS(utmpx.h,
141 AC_CHECK_TYPES([struct utmpx], [], [], [
142 #include <sys/types.h>
143 #include <utmpx.h>
144 ])
145
146 AC_CHECK_MEMBER([struct utmpx.ut_host],
147 [AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)], [], [
148 #include <sys/types.h>
149 #include <utmpx.h>
150 ])
151
152 AC_CHECK_MEMBER([struct utmpx.ut_session],
153 [AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session)], [], [
154 #include <sys/types.h>
155 #include <utmpx.h>
156 ])
157 ) dnl# AC_CHECK_HEADERS(utmpx.h
158
159 dnl# --------------------------------------------------------------------------
160 dnl# check for struct lastlog
161 AC_CHECK_TYPES([struct lastlog], [], [], [
162 #include <sys/types.h>
163 #include <utmp.h>
164 #ifdef HAVE_LASTLOG_H
165 #include <lastlog.h>
166 #endif
167 ])
168
169 dnl# check for struct lastlogx
170 AC_CHECK_TYPES([struct lastlogx], [], [], [
171 #include <sys/types.h>
172 #include <utmpx.h>
173 #ifdef HAVE_LASTLOG_H
174 #include <lastlog.h>
175 #endif
176 ])
177
178 dnl# --------------------------------------------------------------------------
179 dnl# FIND FILES
180 dnl# --------------------------------------------------------------------------
181
182 dnl# find utmp
183 PT_FIND_FILE([utmp], [UTMP_FILE], [_PATH_UTMP],
184 ["/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp"],[
185 #include <sys/types.h>
186 #include <utmp.h>
187 ])
188
189 dnl# --------------------------------------------------------------------------
190
191 dnl# find wtmp
192 PT_FIND_FILE([wtmp], [WTMP_FILE], [_PATH_WTMP],
193 ["/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp"],[
194 #include <sys/types.h>
195 #ifdef HAVE_UTMP_H
196 #include <utmp.h>
197 #endif
198 ])
199 dnl# --------------------------------------------------------------------------
200
201 dnl# find wtmpx
202 PT_FIND_FILE([wtmpx], [WTMPX_FILE], [_PATH_WTMPX],
203 ["/var/log/wtmpx", "/var/adm/wtmpx"],[
204 #ifdef HAVE_UTMPX_H
205 #include <utmpx.h>
206 #endif
207 ])
208 dnl# --------------------------------------------------------------------------
209
210 dnl# find lastlog
211 PT_FIND_FILE([lastlog], [LASTLOG_FILE], [_PATH_LASTLOG],
212 ["/var/log/lastlog"],[
213 #include <sys/types.h>
214 #ifdef HAVE_UTMP_H
215 #include <utmp.h>
216 #endif
217 #ifdef HAVE_LASTLOG_H
218 #include <lastlog.h>
219 #endif
220 ])
221 dnl# --------------------------------------------------------------------------
222
223 dnl# find lastlogx
224 PT_FIND_FILE([lastlogx], [LASTLOGX_FILE], [_PATH_LASTLOGX],
225 ["/var/log/lastlogx", "/var/adm/lastlogx"],[
226 #ifdef HAVE_UTMPX_H
227 #include <utmpx.h>
228 #endif
229 ])
230 ])
231
232 AC_DEFUN([SCM_RIGHTS_CHECK],
233 [
234 AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds,
235 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
236 #include <cstddef> // broken bsds (is that redundant?) need this
237 #include <sys/types.h>
238 #include <sys/socket.h>
239 #include <sys/uio.h>
240 ]], [[
241 {
242 msghdr msg;
243 iovec iov;
244 char buf [100];
245 char data = 0;
246
247 iov.iov_base = &data;
248 iov.iov_len = 1;
249
250 msg.msg_iov = &iov;
251 msg.msg_iovlen = 1;
252 msg.msg_control = buf;
253 msg.msg_controllen = sizeof buf;
254
255 cmsghdr *cmsg = CMSG_FIRSTHDR (&msg);
256 cmsg->cmsg_level = SOL_SOCKET;
257 cmsg->cmsg_type = SCM_RIGHTS;
258 cmsg->cmsg_len = 100;
259
260 *(int *)CMSG_DATA (cmsg) = 5;
261
262 return sendmsg (3, &msg, 0);
263 }
264 ]])],[pt_cv_can_pass_fds=yes],[pt_cv_can_pass_fds=no])])
265 if test x$pt_cv_can_pass_fds = xyes; then
266 AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing)
267 else
268 AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability])
269 fi
270 ])
271
272 AC_DEFUN([TTY_GROUP_CHECK],
273 [
274 AC_CACHE_CHECK([for tty group], pt_cv_tty_group,
275 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
276 #include <sys/types.h>
277 #include <sys/stat.h>
278 #include <unistd.h>
279 #include <grp.h>
280
281 int main()
282 {
283 struct stat st;
284 struct group *gr;
285 char *tty;
286 gr = getgrnam("tty");
287 tty = ttyname(0);
288 if (gr != 0
289 && tty != 0
290 && (stat(tty, &st)) == 0
291 && st.st_gid == gr->gr_gid)
292 return 0;
293 else
294 return 1;
295 }]])],[pt_cv_tty_group=yes],[pt_cv_tty_group=no],[pt_cv_tty_group=no])])
296 if test x$pt_cv_tty_group = xyes; then
297 AC_DEFINE(TTY_GID_SUPPORT, 1, "")
298 fi])
299