ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/ptytty.m4
Revision: 1.34
Committed: Thu Jan 19 11:06:10 2012 UTC (12 years, 4 months ago) by sf-exg
Branch: MAIN
Changes since 1.33: +13 -0 lines
Log Message:
Fix compilation on solaris.

File Contents

# User Rev Content
1 root 1.2 dnl this file is part of libptytty, do not make local modifications
2     dnl http://software.schmorp.de/pkg/libptytty
3    
4 sf-exg 1.24 AC_DEFUN([PT_FIND_FILE],
5 sf-exg 1.31 [AC_CACHE_CHECK(for a fallback location of $1, pt_cv_path_$1, [
6     if test "$cross_compiling" != yes; then
7     for file in $3; do
8     if test -f "$file"; then
9     pt_cv_path_$1=$file
10     break
11     fi
12     done
13     fi])
14 sf-exg 1.24 if test x$pt_cv_path_$1 != x; then
15 sf-exg 1.31 AC_DEFINE_UNQUOTED($2, "$pt_cv_path_$1", Define to a fallback location of $1)
16     elif test "$cross_compiling" = yes; then
17     AC_MSG_WARN(Define $2 in config.h manually)
18 sf-exg 1.24 fi])
19    
20 ayin 1.1 AC_DEFUN([PTY_CHECK],
21     [
22     AC_CHECK_HEADERS( \
23     pty.h \
24     util.h \
25     libutil.h \
26     sys/ioctl.h \
27     sys/stropts.h \
28 root 1.17 stropts.h \
29 ayin 1.1 )
30    
31     AC_CHECK_FUNCS( \
32     revoke \
33     _getpty \
34     getpt \
35     posix_openpt \
36     isastream \
37 root 1.7 setuid \
38     seteuid \
39     setreuid \
40     setresuid \
41 ayin 1.1 )
42    
43 sf-exg 1.29 AC_MSG_CHECKING(for UNIX98 ptys)
44     AC_LINK_IFELSE(
45     [AC_LANG_PROGRAM(
46     [[#include <stdlib.h>]],
47     [[grantpt(0);unlockpt(0);ptsname(0);]])],
48     [unix98_pty=yes
49     AC_DEFINE(UNIX98_PTY, 1, "")
50     AC_MSG_RESULT(yes)],
51     [AC_MSG_RESULT(no)])
52 ayin 1.1
53     if test -z "$unix98_pty"; then
54 sf-exg 1.21 AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, ""))
55 ayin 1.1 fi
56     ])
57    
58     AC_DEFUN([UTMP_CHECK],
59     [
60 ayin 1.5 support_utmp=yes
61     support_wtmp=yes
62     support_lastlog=yes
63    
64 ayin 1.4 AC_ARG_ENABLE(utmp,
65 ayin 1.11 [AS_HELP_STRING([--enable-utmp],[enable utmp (utmpx) support])],
66 ayin 1.4 [if test x$enableval = xyes -o x$enableval = xno; then
67     support_utmp=$enableval
68     fi])
69    
70     AC_ARG_ENABLE(wtmp,
71 ayin 1.11 [AS_HELP_STRING([--enable-wtmp],[enable wtmp (wtmpx) support (requires --enable-utmp)])],
72 ayin 1.4 [if test x$enableval = xyes -o x$enableval = xno; then
73     support_wtmp=$enableval
74     fi])
75    
76     AC_ARG_ENABLE(lastlog,
77 ayin 1.11 [AS_HELP_STRING([--enable-lastlog],[enable lastlog support (requires --enable-utmp)])],
78 ayin 1.4 [if test x$enableval = xyes -o x$enableval = xno; then
79     support_lastlog=$enableval
80     fi])
81    
82     if test x$support_utmp = xyes; then
83     AC_DEFINE(UTMP_SUPPORT, 1, Define if you want to have utmp/utmpx support)
84     fi
85     if test x$support_wtmp = xyes; then
86     AC_DEFINE(WTMP_SUPPORT, 1, Define if you want to have wtmp support when utmp/utmpx is enabled)
87     fi
88     if test x$support_lastlog = xyes; then
89     AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled)
90     fi
91    
92 ayin 1.1 AC_CHECK_FUNCS( \
93     updwtmp \
94     updwtmpx \
95 ayin 1.12 updlastlogx \
96 ayin 1.1 )
97    
98 ayin 1.15 AC_CHECK_HEADERS(lastlog.h)
99 ayin 1.1
100 sf-exg 1.34 case $host in
101     *-*-solaris*)
102     AC_DEFINE(__EXTENSIONS__, 1, Enable declarations in utmp.h on Solaris when the XPG4v2 namespace is active)
103     ;;
104     esac
105    
106 ayin 1.1 dnl# --------------------------------------------------------------------------
107     dnl# DO ALL UTMP AND WTMP CHECKING
108     dnl# --------------------------------------------------------------------------
109     dnl# check for host field in utmp structure
110    
111     dnl# --------------------------------------------
112 ayin 1.15 AC_CHECK_HEADERS(utmp.h,
113 sf-exg 1.26 AC_CHECK_TYPES([struct utmp], [], [], [
114     #include <sys/types.h>
115     #include <utmp.h>
116     ])
117 ayin 1.1
118 sf-exg 1.26 AC_CHECK_MEMBER([struct utmp.ut_host],
119     [AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)], [], [
120     #include <sys/types.h>
121     #include <utmp.h>
122     ])
123 ayin 1.1
124 sf-exg 1.26 AC_CHECK_MEMBER([struct utmp.ut_pid],
125     [AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)], [], [
126     #include <sys/types.h>
127     #include <utmp.h>
128     ])
129 ayin 1.15 ) dnl# AC_CHECK_HEADERS(utmp.h
130 ayin 1.1
131     dnl# --------------------------------------------
132    
133 ayin 1.15 AC_CHECK_HEADERS(utmpx.h,
134 sf-exg 1.26 AC_CHECK_TYPES([struct utmpx], [], [], [
135     #include <sys/types.h>
136     #include <utmpx.h>
137     ])
138 ayin 1.1
139 sf-exg 1.26 AC_CHECK_MEMBER([struct utmpx.ut_host],
140     [AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)], [], [
141     #include <sys/types.h>
142     #include <utmpx.h>
143     ])
144 ayin 1.15 ) dnl# AC_CHECK_HEADERS(utmpx.h
145 ayin 1.1
146     dnl# --------------------------------------------------------------------------
147     dnl# check for struct lastlog
148 sf-exg 1.26 AC_CHECK_TYPES([struct lastlog], [], [], [
149     #include <sys/types.h>
150 ayin 1.1 #include <utmp.h>
151     #ifdef HAVE_LASTLOG_H
152     #include <lastlog.h>
153     #endif
154 sf-exg 1.26 ])
155 ayin 1.1
156     dnl# check for struct lastlogx
157 sf-exg 1.26 AC_CHECK_TYPES([struct lastlogx], [], [], [
158     #include <sys/types.h>
159 ayin 1.1 #include <utmpx.h>
160     #ifdef HAVE_LASTLOG_H
161     #include <lastlog.h>
162     #endif
163 sf-exg 1.26 ])
164 ayin 1.1
165     dnl# --------------------------------------------------------------------------
166     dnl# FIND FILES
167     dnl# --------------------------------------------------------------------------
168    
169     dnl# find utmp
170 sf-exg 1.31 PT_FIND_FILE([utmp], [PT_UTMP_FILE],
171     ["/var/run/utmp" "/var/adm/utmp" "/etc/utmp" "/usr/etc/utmp" "/usr/adm/utmp"])
172 ayin 1.1
173     dnl# --------------------------------------------------------------------------
174    
175     dnl# find wtmp
176 sf-exg 1.31 PT_FIND_FILE([wtmp], [PT_WTMP_FILE],
177     ["/var/log/wtmp" "/var/adm/wtmp" "/etc/wtmp" "/usr/etc/wtmp" "/usr/adm/wtmp"])
178 ayin 1.1 dnl# --------------------------------------------------------------------------
179    
180     dnl# find wtmpx
181 sf-exg 1.31 PT_FIND_FILE([wtmpx], [PT_WTMPX_FILE],
182     ["/var/log/wtmpx" "/var/adm/wtmpx"])
183 ayin 1.1 dnl# --------------------------------------------------------------------------
184    
185     dnl# find lastlog
186 sf-exg 1.31 PT_FIND_FILE([lastlog], [PT_LASTLOG_FILE],
187 sf-exg 1.33 ["/var/log/lastlog" "/var/adm/lastlog"])
188 ayin 1.1 dnl# --------------------------------------------------------------------------
189    
190     dnl# find lastlogx
191 sf-exg 1.31 PT_FIND_FILE([lastlogx], [PT_LASTLOGX_FILE],
192     ["/var/log/lastlogx" "/var/adm/lastlogx"])
193 ayin 1.1 ])
194    
195     AC_DEFUN([SCM_RIGHTS_CHECK],
196     [
197 sf-exg 1.34 case $host in
198     *-*-solaris*)
199     AC_DEFINE(_XOPEN_SOURCE, 500, Enable declarations of msg_control and msg_controllen on Solaris)
200     AC_SEARCH_LIBS(sendmsg, socket)
201     ;;
202     esac
203    
204 sf-exg 1.18 AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds,
205 ayin 1.16 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
206 root 1.6 #include <cstddef> // broken bsds (is that redundant?) need this
207 ayin 1.1 #include <sys/types.h>
208     #include <sys/socket.h>
209     #include <sys/uio.h>
210 ayin 1.16 ]], [[
211 ayin 1.1 {
212     msghdr msg;
213     iovec iov;
214     char buf [100];
215     char data = 0;
216    
217     iov.iov_base = &data;
218     iov.iov_len = 1;
219    
220     msg.msg_iov = &iov;
221     msg.msg_iovlen = 1;
222     msg.msg_control = buf;
223     msg.msg_controllen = sizeof buf;
224    
225     cmsghdr *cmsg = CMSG_FIRSTHDR (&msg);
226     cmsg->cmsg_level = SOL_SOCKET;
227     cmsg->cmsg_type = SCM_RIGHTS;
228     cmsg->cmsg_len = 100;
229    
230     *(int *)CMSG_DATA (cmsg) = 5;
231    
232     return sendmsg (3, &msg, 0);
233     }
234 sf-exg 1.18 ]])],[pt_cv_can_pass_fds=yes],[pt_cv_can_pass_fds=no])])
235     if test x$pt_cv_can_pass_fds = xyes; then
236 ayin 1.1 AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing)
237     else
238     AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability])
239     fi
240     ])
241 ayin 1.3
242     AC_DEFUN([TTY_GROUP_CHECK],
243     [
244 sf-exg 1.18 AC_CACHE_CHECK([for tty group], pt_cv_tty_group,
245 ayin 1.16 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
246 ayin 1.3 #include <sys/types.h>
247     #include <sys/stat.h>
248     #include <unistd.h>
249     #include <grp.h>
250    
251 sf-exg 1.22 int main()
252 ayin 1.3 {
253     struct stat st;
254     struct group *gr;
255     char *tty;
256     gr = getgrnam("tty");
257     tty = ttyname(0);
258     if (gr != 0
259     && tty != 0
260     && (stat(tty, &st)) == 0
261     && st.st_gid == gr->gr_gid)
262     return 0;
263     else
264     return 1;
265 sf-exg 1.18 }]])],[pt_cv_tty_group=yes],[pt_cv_tty_group=no],[pt_cv_tty_group=no])])
266     if test x$pt_cv_tty_group = xyes; then
267 ayin 1.3 AC_DEFINE(TTY_GID_SUPPORT, 1, "")
268     fi])
269