1 | dnl this file is part of libptytty, do not make local modifications |
1 | dnl this file is part of libptytty, do not make local modifications |
2 | dnl http://software.schmorp.de/pkg/libptytty |
2 | dnl http://software.schmorp.de/pkg/libptytty |
3 | |
3 | |
4 | AC_DEFUN([PT_FIND_FILE], |
4 | AC_DEFUN([PT_FIND_FILE], |
5 | [AC_CACHE_CHECK(where $1 is located, pt_cv_path_$1, |
5 | [AC_CACHE_CHECK(for a fallback location of $1, pt_cv_path_$1, [ |
6 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> |
6 | if test "$cross_compiling" != yes; then |
7 | #include <stdlib.h> |
7 | for file in $3; do |
8 | #include <sys/stat.h> |
8 | if test -f "$file"; then |
9 | $5 |
9 | pt_cv_path_$1=$file |
10 | int main() |
|
|
11 | { |
|
|
12 | 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; |
10 | break |
25 | } |
11 | fi |
26 | } |
12 | done |
27 | #endif |
13 | fi]) |
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 |
14 | if test x$pt_cv_path_$1 != x; then |
32 | AC_DEFINE_UNQUOTED($2, "$pt_cv_path_$1", Define location of $1) |
15 | 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) |
33 | fi]) |
18 | fi]) |
34 | |
19 | |
35 | AC_DEFUN([PTY_CHECK], |
20 | AC_DEFUN([PTY_CHECK], |
36 | [ |
21 | [ |
37 | AC_CHECK_HEADERS( \ |
22 | AC_CHECK_HEADERS( \ |
… | |
… | |
53 | seteuid \ |
38 | seteuid \ |
54 | setreuid \ |
39 | setreuid \ |
55 | setresuid \ |
40 | setresuid \ |
56 | ) |
41 | ) |
57 | |
42 | |
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) |
43 | AC_MSG_CHECKING(for UNIX98 ptys) |
89 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]], |
44 | AC_LINK_IFELSE( |
|
|
45 | [AC_LANG_PROGRAM( |
|
|
46 | [[#include <stdlib.h>]], |
90 | [[grantpt(0);unlockpt(0);ptsname(0);]])], |
47 | [[grantpt(0);unlockpt(0);ptsname(0);]])], |
91 | [unix98_pty=yes |
48 | [unix98_pty=yes |
92 | AC_DEFINE(UNIX98_PTY, 1, "") |
49 | AC_DEFINE(UNIX98_PTY, 1, "") |
93 | AC_MSG_RESULT(yes)], |
50 | AC_MSG_RESULT(yes)], |
94 | [AC_MSG_RESULT(no)]) |
51 | [AC_MSG_RESULT(no)]) |
95 | fi |
|
|
96 | |
52 | |
97 | if test -z "$unix98_pty"; then |
53 | if test -z "$unix98_pty"; then |
98 | AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, "")) |
54 | AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, "")) |
99 | fi |
55 | fi |
100 | ]) |
56 | ]) |
… | |
… | |
139 | updlastlogx \ |
95 | updlastlogx \ |
140 | ) |
96 | ) |
141 | |
97 | |
142 | AC_CHECK_HEADERS(lastlog.h) |
98 | AC_CHECK_HEADERS(lastlog.h) |
143 | |
99 | |
|
|
100 | 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 | |
144 | dnl# -------------------------------------------------------------------------- |
106 | dnl# -------------------------------------------------------------------------- |
145 | dnl# DO ALL UTMP AND WTMP CHECKING |
107 | dnl# DO ALL UTMP AND WTMP CHECKING |
146 | dnl# -------------------------------------------------------------------------- |
108 | dnl# -------------------------------------------------------------------------- |
147 | dnl# check for host field in utmp structure |
109 | dnl# check for host field in utmp structure |
148 | |
110 | |
149 | dnl# -------------------------------------------- |
111 | dnl# -------------------------------------------- |
150 | AC_CHECK_HEADERS(utmp.h, |
112 | AC_CHECK_HEADERS(utmp.h, |
151 | [AC_CACHE_CHECK([for struct utmp], pt_cv_struct_utmp, |
113 | AC_CHECK_TYPES([struct utmp], [], [], [ |
152 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
114 | #include <sys/types.h> |
153 | #include <utmp.h>]], [[struct utmp ut;]])],[pt_cv_struct_utmp=yes],[pt_cv_struct_utmp=no])]) |
115 | #include <utmp.h> |
154 | if test x$pt_cv_struct_utmp = xyes; then |
116 | ]) |
155 | AC_DEFINE(HAVE_STRUCT_UTMP, 1, Define if utmp.h has struct utmp) |
|
|
156 | fi |
|
|
157 | ] |
|
|
158 | |
117 | |
159 | AC_CACHE_CHECK(for ut_host in utmp struct, pt_cv_struct_utmp_host, |
118 | AC_CHECK_MEMBER([struct utmp.ut_host], |
160 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
|
|
161 | #include <utmp.h>]], [[struct utmp ut; ut.ut_host;]])],[pt_cv_struct_utmp_host=yes],[pt_cv_struct_utmp_host=no])]) |
|
|
162 | if test x$pt_cv_struct_utmp_host = xyes; then |
|
|
163 | AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host) |
119 | [AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)], [], [ |
164 | fi |
120 | #include <sys/types.h> |
|
|
121 | #include <utmp.h> |
|
|
122 | ]) |
165 | |
123 | |
166 | AC_CACHE_CHECK(for ut_pid in utmp struct, pt_cv_struct_utmp_pid, |
124 | AC_CHECK_MEMBER([struct utmp.ut_pid], |
167 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
|
|
168 | #include <utmp.h>]], [[struct utmp ut; ut.ut_pid;]])],[pt_cv_struct_utmp_pid=yes],[pt_cv_struct_utmp_pid=no])]) |
|
|
169 | if test x$pt_cv_struct_utmp_pid = xyes; then |
|
|
170 | AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid) |
125 | [AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)], [], [ |
171 | fi |
126 | #include <sys/types.h> |
|
|
127 | #include <utmp.h> |
|
|
128 | ]) |
172 | ) dnl# AC_CHECK_HEADERS(utmp.h |
129 | ) dnl# AC_CHECK_HEADERS(utmp.h |
173 | |
130 | |
174 | dnl# -------------------------------------------- |
131 | dnl# -------------------------------------------- |
175 | |
132 | |
176 | AC_CHECK_HEADERS(utmpx.h, |
133 | AC_CHECK_HEADERS(utmpx.h, |
177 | [AC_CACHE_CHECK([for struct utmpx], pt_cv_struct_utmpx, |
134 | AC_CHECK_TYPES([struct utmpx], [], [], [ |
178 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
135 | #include <sys/types.h> |
179 | #include <utmpx.h>]], [[struct utmpx ut;]])],[pt_cv_struct_utmpx=yes],[pt_cv_struct_utmpx=no])]) |
136 | #include <utmpx.h> |
180 | if test x$pt_cv_struct_utmpx = xyes; then |
137 | ]) |
181 | AC_DEFINE(HAVE_STRUCT_UTMPX, 1, Define if utmpx.h has struct utmpx) |
|
|
182 | fi |
|
|
183 | ] |
|
|
184 | |
138 | |
185 | AC_CACHE_CHECK(for host in utmpx struct, pt_cv_struct_utmpx_host, |
139 | AC_CHECK_MEMBER([struct utmpx.ut_host], |
186 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
|
|
187 | #include <utmpx.h>]], [[struct utmpx utx; utx.ut_host;]])],[pt_cv_struct_utmpx_host=yes],[pt_cv_struct_utmpx_host=no])]) |
|
|
188 | if test x$pt_cv_struct_utmpx_host = xyes; then |
|
|
189 | AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host) |
140 | [AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)], [], [ |
190 | fi |
141 | #include <sys/types.h> |
191 | |
142 | #include <utmpx.h> |
192 | AC_CACHE_CHECK(for session in utmpx struct, pt_cv_struct_utmpx_session, |
143 | ]) |
193 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
|
|
194 | #include <utmpx.h>]], [[struct utmpx utx; utx.ut_session;]])],[pt_cv_struct_utmpx_session=yes],[pt_cv_struct_utmpx_session=no])]) |
|
|
195 | if test x$pt_cv_struct_utmpx_session = xyes; then |
|
|
196 | AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session) |
|
|
197 | fi |
|
|
198 | ) dnl# AC_CHECK_HEADERS(utmpx.h |
144 | ) dnl# AC_CHECK_HEADERS(utmpx.h |
199 | |
145 | |
200 | dnl# -------------------------------------------------------------------------- |
146 | dnl# -------------------------------------------------------------------------- |
201 | dnl# check for struct lastlog |
147 | dnl# check for struct lastlog |
202 | AC_CACHE_CHECK(for struct lastlog, pt_cv_struct_lastlog, |
148 | AC_CHECK_TYPES([struct lastlog], [], [], [ |
203 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
149 | #include <sys/types.h> |
204 | #include <utmp.h> |
150 | #include <utmp.h> |
205 | #ifdef HAVE_LASTLOG_H |
151 | #ifdef HAVE_LASTLOG_H |
206 | #include <lastlog.h> |
152 | #include <lastlog.h> |
207 | #endif |
153 | #endif |
208 | ]], [[struct lastlog ll;]])],[pt_cv_struct_lastlog=yes],[pt_cv_struct_lastlog=no])]) |
154 | ]) |
209 | if test x$pt_cv_struct_lastlog = xyes; then |
|
|
210 | AC_DEFINE(HAVE_STRUCT_LASTLOG, 1, Define if utmp.h or lastlog.h has struct lastlog) |
|
|
211 | fi |
|
|
212 | |
155 | |
213 | dnl# check for struct lastlogx |
156 | dnl# check for struct lastlogx |
214 | AC_CACHE_CHECK(for struct lastlogx, pt_cv_struct_lastlogx, |
157 | AC_CHECK_TYPES([struct lastlogx], [], [], [ |
215 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> |
158 | #include <sys/types.h> |
216 | #include <utmpx.h> |
159 | #include <utmpx.h> |
217 | #ifdef HAVE_LASTLOG_H |
160 | #ifdef HAVE_LASTLOG_H |
218 | #include <lastlog.h> |
161 | #include <lastlog.h> |
219 | #endif |
162 | #endif |
220 | ]], [[struct lastlogx ll;]])],[pt_cv_struct_lastlogx=yes],[pt_cv_struct_lastlogx=no])]) |
163 | ]) |
221 | if test x$pt_cv_struct_lastlogx = xyes; then |
|
|
222 | AC_DEFINE(HAVE_STRUCT_LASTLOGX, 1, Define if utmpx.h or lastlog.h has struct lastlogx) |
|
|
223 | fi |
|
|
224 | |
164 | |
225 | dnl# -------------------------------------------------------------------------- |
165 | dnl# -------------------------------------------------------------------------- |
226 | dnl# FIND FILES |
166 | dnl# FIND FILES |
227 | dnl# -------------------------------------------------------------------------- |
167 | dnl# -------------------------------------------------------------------------- |
228 | |
168 | |
229 | dnl# find utmp |
169 | dnl# find utmp |
230 | PT_FIND_FILE([utmp], [UTMP_FILE], [_PATH_UTMP], |
170 | PT_FIND_FILE([utmp], [PT_UTMP_FILE], |
231 | ["/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp"],[ |
171 | ["/var/run/utmp" "/var/adm/utmp" "/etc/utmp" "/usr/etc/utmp" "/usr/adm/utmp"]) |
232 | #include <sys/types.h> |
|
|
233 | #include <utmp.h> |
|
|
234 | ]) |
|
|
235 | |
172 | |
236 | dnl# -------------------------------------------------------------------------- |
173 | dnl# -------------------------------------------------------------------------- |
237 | |
174 | |
238 | dnl# find wtmp |
175 | dnl# find wtmp |
239 | PT_FIND_FILE([wtmp], [WTMP_FILE], [_PATH_WTMP], |
176 | PT_FIND_FILE([wtmp], [PT_WTMP_FILE], |
240 | ["/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp"],[ |
177 | ["/var/log/wtmp" "/var/adm/wtmp" "/etc/wtmp" "/usr/etc/wtmp" "/usr/adm/wtmp"]) |
241 | #include <sys/types.h> |
|
|
242 | #ifdef HAVE_UTMP_H |
|
|
243 | #include <utmp.h> |
|
|
244 | #endif |
|
|
245 | ]) |
|
|
246 | dnl# -------------------------------------------------------------------------- |
178 | dnl# -------------------------------------------------------------------------- |
247 | |
179 | |
248 | dnl# find wtmpx |
180 | dnl# find wtmpx |
249 | PT_FIND_FILE([wtmpx], [WTMPX_FILE], [_PATH_WTMPX], |
181 | PT_FIND_FILE([wtmpx], [PT_WTMPX_FILE], |
250 | ["/var/log/wtmpx", "/var/adm/wtmpx"],[ |
182 | ["/var/log/wtmpx" "/var/adm/wtmpx"]) |
251 | #ifdef HAVE_UTMPX_H |
|
|
252 | #include <utmpx.h> |
|
|
253 | #endif |
|
|
254 | ]) |
|
|
255 | dnl# -------------------------------------------------------------------------- |
183 | dnl# -------------------------------------------------------------------------- |
256 | |
184 | |
257 | dnl# find lastlog |
185 | dnl# find lastlog |
258 | PT_FIND_FILE([lastlog], [LASTLOG_FILE], [_PATH_LASTLOG], |
186 | PT_FIND_FILE([lastlog], [PT_LASTLOG_FILE], |
259 | ["/var/log/lastlog"],[ |
187 | ["/var/log/lastlog" "/var/adm/lastlog"]) |
260 | #include <sys/types.h> |
|
|
261 | #ifdef HAVE_UTMP_H |
|
|
262 | #include <utmp.h> |
|
|
263 | #endif |
|
|
264 | #ifdef HAVE_LASTLOG_H |
|
|
265 | #include <lastlog.h> |
|
|
266 | #endif |
|
|
267 | ]) |
|
|
268 | dnl# -------------------------------------------------------------------------- |
188 | dnl# -------------------------------------------------------------------------- |
269 | |
189 | |
270 | dnl# find lastlogx |
190 | dnl# find lastlogx |
271 | PT_FIND_FILE([lastlogx], [LASTLOGX_FILE], [_PATH_LASTLOGX], |
191 | PT_FIND_FILE([lastlogx], [PT_LASTLOGX_FILE], |
272 | ["/var/log/lastlogx", "/var/adm/lastlogx"],[ |
192 | ["/var/log/lastlogx" "/var/adm/lastlogx"]) |
273 | #ifdef HAVE_UTMPX_H |
|
|
274 | #include <utmpx.h> |
|
|
275 | #endif |
|
|
276 | ]) |
|
|
277 | ]) |
193 | ]) |
278 | |
194 | |
279 | AC_DEFUN([SCM_RIGHTS_CHECK], |
195 | AC_DEFUN([SCM_RIGHTS_CHECK], |
280 | [ |
196 | [ |
|
|
197 | 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 | |
281 | AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds, |
204 | AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds, |
282 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
205 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
283 | #include <cstddef> // broken bsds (is that redundant?) need this |
206 | #include <cstddef> // broken bsds (is that redundant?) need this |
284 | #include <sys/types.h> |
207 | #include <sys/types.h> |
285 | #include <sys/socket.h> |
208 | #include <sys/socket.h> |