ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/ptytty.m4
(Generate patch)

Comparing libptytty/ptytty.m4 (file contents):
Revision 1.20 by sf-exg, Sun Jul 11 16:04:54 2010 UTC vs.
Revision 1.30 by sf-exg, Wed Nov 23 19:29:27 2011 UTC

1dnl this file is part of libptytty, do not make local modifications 1dnl this file is part of libptytty, do not make local modifications
2dnl http://software.schmorp.de/pkg/libptytty 2dnl http://software.schmorp.de/pkg/libptytty
3
4AC_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#include <sys/types.h>
10#ifdef HAVE_UTMPX_H
11#include <utmpx.h>
12#endif
13#ifdef HAVE_UTMP_H
14#include <utmp.h>
15#endif
16#ifdef HAVE_LASTLOG_H
17#include <lastlog.h>
18#endif
19int main()
20{
21 const char **path, *list[] = { $4, NULL };
22 FILE *f = fopen("conftestval", "w");
23 if (!f) return 1;
24#ifdef $2
25 fprintf(f, "%s\n", $2);
26#elif defined($3)
27 fprintf(f, "%s\n", $3);
28#else
29 for (path = list; *path; path++) {
30 struct stat st;
31 if (stat(*path, &st) == 0) {
32 fprintf(f, "%s\n", *path);
33 break;
34 }
35 }
36#endif
37 return fclose(f) != 0;
38}]])],[pt_cv_path_$1=`cat conftestval`],[pt_cv_path_$1=],
39[AC_MSG_WARN(Define $2 in config.h manually)])])
40if test x$pt_cv_path_$1 != x; then
41 AC_DEFINE_UNQUOTED($2, "$pt_cv_path_$1", Define location of $1)
42fi])
3 43
4AC_DEFUN([PTY_CHECK], 44AC_DEFUN([PTY_CHECK],
5[ 45[
6AC_CHECK_HEADERS( \ 46AC_CHECK_HEADERS( \
7 pty.h \ 47 pty.h \
22 seteuid \ 62 seteuid \
23 setreuid \ 63 setreuid \
24 setresuid \ 64 setresuid \
25) 65)
26 66
27have_clone=no
28
29AC_MSG_CHECKING(for /dev/ptc)
30if test -e /dev/ptc; then
31 AC_MSG_RESULT(yes)
32 AC_DEFINE(CLONE_DEVICE, "/dev/ptc", [clone device filename])
33 have_clone=yes
34else
35 AC_MSG_RESULT(no)
36fi
37
38case $host in
39 *-*-cygwin*)
40 have_clone=yes
41 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
42 ;;
43 *)
44 AC_MSG_CHECKING(for /dev/ptmx)
45 if test -e /dev/ptmx; then
46 AC_MSG_RESULT(yes)
47 AC_DEFINE(HAVE_DEV_PTMX, 1, [Define to 1 if you have /dev/ptmx])
48 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
49 have_clone=yes
50 else
51 AC_MSG_RESULT(no)
52 fi
53 ;;
54esac
55
56if test x$ac_cv_func_getpt = xyes -o x$ac_cv_func_posix_openpt = xyes -o x$have_clone = xyes; then
57 AC_MSG_CHECKING(for UNIX98 ptys) 67AC_MSG_CHECKING(for UNIX98 ptys)
58 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]], 68AC_LINK_IFELSE(
69 [AC_LANG_PROGRAM(
70 [[#include <stdlib.h>]],
59 [[grantpt(0);unlockpt(0);ptsname(0);]])], 71 [[grantpt(0);unlockpt(0);ptsname(0);]])],
60 [unix98_pty=yes 72 [unix98_pty=yes
61 AC_DEFINE(UNIX98_PTY, 1, "") 73 AC_DEFINE(UNIX98_PTY, 1, "")
62 AC_MSG_RESULT(yes)], 74 AC_MSG_RESULT(yes)],
63 [AC_MSG_RESULT(no)]) 75 [AC_MSG_RESULT(no)])
64fi
65 76
66if test -z "$unix98_pty"; then 77if test -z "$unix98_pty"; then
67 AC_CHECK_FUNCS(openpty, [], [AC_CHECK_LIB(util, openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"])]) 78 AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, ""))
68fi 79fi
69]) 80])
70 81
71AC_DEFUN([UTMP_CHECK], 82AC_DEFUN([UTMP_CHECK],
72[ 83[
115dnl# -------------------------------------------------------------------------- 126dnl# --------------------------------------------------------------------------
116dnl# check for host field in utmp structure 127dnl# check for host field in utmp structure
117 128
118dnl# -------------------------------------------- 129dnl# --------------------------------------------
119AC_CHECK_HEADERS(utmp.h, 130AC_CHECK_HEADERS(utmp.h,
120[AC_CACHE_CHECK([for struct utmp], pt_cv_struct_utmp, 131AC_CHECK_TYPES([struct utmp], [], [], [
121[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 132#include <sys/types.h>
122#include <utmp.h>]], [[struct utmp ut;]])],[pt_cv_struct_utmp=yes],[pt_cv_struct_utmp=no])]) 133#include <utmp.h>
123if test x$pt_cv_struct_utmp = xyes; then 134])
124 AC_DEFINE(HAVE_STRUCT_UTMP, 1, Define if utmp.h has struct utmp)
125fi
126]
127 135
128AC_CACHE_CHECK(for ut_host in utmp struct, pt_cv_struct_utmp_host, 136AC_CHECK_MEMBER([struct utmp.ut_host],
129[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
130#include <utmp.h>]], [[struct utmp ut; ut.ut_host;]])],[pt_cv_struct_utmp_host=yes],[pt_cv_struct_utmp_host=no])])
131if test x$pt_cv_struct_utmp_host = xyes; then
132 AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host) 137[AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)], [], [
133fi 138#include <sys/types.h>
139#include <utmp.h>
140])
134 141
135AC_CACHE_CHECK(for ut_pid in utmp struct, pt_cv_struct_utmp_pid, 142AC_CHECK_MEMBER([struct utmp.ut_pid],
136[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
137#include <utmp.h>]], [[struct utmp ut; ut.ut_pid;]])],[pt_cv_struct_utmp_pid=yes],[pt_cv_struct_utmp_pid=no])])
138if test x$pt_cv_struct_utmp_pid = xyes; then
139 AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid) 143[AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)], [], [
140fi 144#include <sys/types.h>
145#include <utmp.h>
146])
141) dnl# AC_CHECK_HEADERS(utmp.h 147) dnl# AC_CHECK_HEADERS(utmp.h
142 148
143dnl# -------------------------------------------- 149dnl# --------------------------------------------
144 150
145AC_CHECK_HEADERS(utmpx.h, 151AC_CHECK_HEADERS(utmpx.h,
146[AC_CACHE_CHECK([for struct utmpx], pt_cv_struct_utmpx, 152AC_CHECK_TYPES([struct utmpx], [], [], [
147[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 153#include <sys/types.h>
148#include <utmpx.h>]], [[struct utmpx ut;]])],[pt_cv_struct_utmpx=yes],[pt_cv_struct_utmpx=no])]) 154#include <utmpx.h>
149if test x$pt_cv_struct_utmpx = xyes; then 155])
150 AC_DEFINE(HAVE_STRUCT_UTMPX, 1, Define if utmpx.h has struct utmpx)
151fi
152]
153 156
154AC_CACHE_CHECK(for host in utmpx struct, pt_cv_struct_utmpx_host, 157AC_CHECK_MEMBER([struct utmpx.ut_host],
155[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
156#include <utmpx.h>]], [[struct utmpx utx; utx.ut_host;]])],[pt_cv_struct_utmpx_host=yes],[pt_cv_struct_utmpx_host=no])])
157if test x$pt_cv_struct_utmpx_host = xyes; then
158 AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host) 158[AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)], [], [
159fi 159#include <sys/types.h>
160#include <utmpx.h>
161])
160 162
161AC_CACHE_CHECK(for session in utmpx struct, pt_cv_struct_utmpx_session, 163AC_CHECK_MEMBER([struct utmpx.ut_session],
162[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
163#include <utmpx.h>]], [[struct utmpx utx; utx.ut_session;]])],[pt_cv_struct_utmpx_session=yes],[pt_cv_struct_utmpx_session=no])])
164if test x$pt_cv_struct_utmpx_session = xyes; then
165 AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session) 164[AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session)], [], [
166fi 165#include <sys/types.h>
166#include <utmpx.h>
167])
167) dnl# AC_CHECK_HEADERS(utmpx.h 168) dnl# AC_CHECK_HEADERS(utmpx.h
168 169
169dnl# -------------------------------------------------------------------------- 170dnl# --------------------------------------------------------------------------
170dnl# check for struct lastlog 171dnl# check for struct lastlog
171AC_CACHE_CHECK(for struct lastlog, pt_cv_struct_lastlog, 172AC_CHECK_TYPES([struct lastlog], [], [], [
172[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 173#include <sys/types.h>
173#include <utmp.h> 174#include <utmp.h>
174#ifdef HAVE_LASTLOG_H 175#ifdef HAVE_LASTLOG_H
175#include <lastlog.h> 176#include <lastlog.h>
176#endif 177#endif
177]], [[struct lastlog ll;]])],[pt_cv_struct_lastlog=yes],[pt_cv_struct_lastlog=no])]) 178])
178if test x$pt_cv_struct_lastlog = xyes; then
179 AC_DEFINE(HAVE_STRUCT_LASTLOG, 1, Define if utmp.h or lastlog.h has struct lastlog)
180fi
181 179
182dnl# check for struct lastlogx 180dnl# check for struct lastlogx
183AC_CACHE_CHECK(for struct lastlogx, pt_cv_struct_lastlogx, 181AC_CHECK_TYPES([struct lastlogx], [], [], [
184[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 182#include <sys/types.h>
185#include <utmpx.h> 183#include <utmpx.h>
186#ifdef HAVE_LASTLOG_H 184#ifdef HAVE_LASTLOG_H
187#include <lastlog.h> 185#include <lastlog.h>
188#endif 186#endif
189]], [[struct lastlogx ll;]])],[pt_cv_struct_lastlogx=yes],[pt_cv_struct_lastlogx=no])]) 187])
190if test x$pt_cv_struct_lastlogx = xyes; then
191 AC_DEFINE(HAVE_STRUCT_LASTLOGX, 1, Define if utmpx.h or lastlog.h has struct lastlogx)
192fi
193 188
194dnl# -------------------------------------------------------------------------- 189dnl# --------------------------------------------------------------------------
195dnl# FIND FILES 190dnl# FIND FILES
196dnl# -------------------------------------------------------------------------- 191dnl# --------------------------------------------------------------------------
197 192
198dnl# find utmp 193dnl# find utmp
199AC_CACHE_CHECK(where utmp is located, pt_cv_path_utmp, 194PT_FIND_FILE([utmp], [UTMP_FILE], [_PATH_UTMP],
200[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
201#include <stdlib.h>
202#include <sys/types.h>
203#include <utmp.h>
204#include <errno.h>
205main()
206{
207 char **u, *utmplist[] = {
208 "/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp", NULL }; 195["/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp"])
209 FILE *a, *f=fopen("conftestval", "w");
210 if (!f) exit(1);
211#ifdef UTMP_FILE
212 fprintf(f, "%s\n", UTMP_FILE);
213 exit(0);
214#endif
215#ifdef _PATH_UTMP
216 fprintf(f, "%s\n", _PATH_UTMP);
217 exit(0);
218#endif
219 for (u = utmplist; *u; u++) {
220 if ((a = fopen(*u, "r")) != NULL || errno == EACCES) {
221 fprintf(f, "%s\n", *u);
222 exit(0);
223 }
224 }
225 exit(0);
226}]])],[pt_cv_path_utmp=`cat conftestval`],[pt_cv_path_utmp=],[dnl
227 AC_MSG_WARN(Define UTMP_FILE in config.h manually)])])
228if test x$pt_cv_path_utmp != x; then
229 AC_DEFINE_UNQUOTED(UTMP_FILE, "$pt_cv_path_utmp", Define location of utmp)
230fi
231 196
232dnl# -------------------------------------------------------------------------- 197dnl# --------------------------------------------------------------------------
233 198
234dnl# find wtmp 199dnl# find wtmp
235AC_CACHE_CHECK(where wtmp is located, pt_cv_path_wtmp, 200PT_FIND_FILE([wtmp], [WTMP_FILE], [_PATH_WTMP],
236[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
237#include <stdlib.h>
238#include <sys/types.h>
239#ifdef HAVE_UTMP_H
240#include <utmp.h>
241#endif
242#include <errno.h>
243main()
244{
245 char **w, *wtmplist[] = {
246 "/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp", NULL }; 201["/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp"])
247 FILE *a, *f=fopen("conftestval", "w");
248 if (!f) exit(1);
249#ifdef WTMP_FILE
250 fprintf(f, "%s\n", WTMP_FILE);
251 exit(0);
252#endif
253#ifdef _PATH_WTMP
254 fprintf(f, "%s\n", _PATH_WTMP);
255 exit(0);
256#endif
257 for (w = wtmplist; *w; w++) {
258 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
259 fprintf(f, "%s\n", *w);
260 exit(0);
261 }
262 }
263 exit(0);
264}]])],[pt_cv_path_wtmp=`cat conftestval`],[pt_cv_path_wtmp=],[dnl
265 AC_MSG_WARN(Define WTMP_FILE in config.h manually)])])
266if test x$pt_cv_path_wtmp != x; then
267 AC_DEFINE_UNQUOTED(WTMP_FILE, "$pt_cv_path_wtmp", Define location of wtmp)
268fi
269dnl# -------------------------------------------------------------------------- 202dnl# --------------------------------------------------------------------------
270 203
271dnl# find wtmpx 204dnl# find wtmpx
272AC_CACHE_CHECK(where wtmpx is located, pt_cv_path_wtmpx, 205PT_FIND_FILE([wtmpx], [WTMPX_FILE], [_PATH_WTMPX],
273[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
274#include <stdlib.h>
275#ifdef HAVE_UTMPX_H
276#include <utmpx.h>
277#endif
278#include <errno.h>
279main()
280{
281 char **w, *wtmplist[] = {
282 "/var/log/wtmpx", "/var/adm/wtmpx", NULL }; 206["/var/log/wtmpx", "/var/adm/wtmpx"])
283 FILE *a, *f=fopen("conftestval", "w");
284 if (!f) exit(1);
285#ifdef WTMPX_FILE
286 fprintf(f, "%s\n", WTMPX_FILE);
287 exit(0);
288#endif
289#ifdef _PATH_WTMPX
290 fprintf(f, "%s\n", _PATH_WTMPX);
291 exit(0);
292#endif
293 for (w = wtmplist; *w; w++) {
294 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
295 fprintf(f, "%s\n", *w);
296 exit(0);
297 }
298 }
299 exit(0);
300}]])],[pt_cv_path_wtmpx=`cat conftestval`],[pt_cv_path_wtmpx=],[dnl
301 AC_MSG_WARN(Define WTMPX_FILE in config.h manually)])])
302if test x$pt_cv_path_wtmpx != x; then
303 AC_DEFINE_UNQUOTED(WTMPX_FILE, "$pt_cv_path_wtmpx", Define location of wtmpx)
304fi
305dnl# -------------------------------------------------------------------------- 207dnl# --------------------------------------------------------------------------
306 208
307dnl# find lastlog 209dnl# find lastlog
308AC_CACHE_CHECK(where lastlog is located, pt_cv_path_lastlog, 210PT_FIND_FILE([lastlog], [LASTLOG_FILE], [_PATH_LASTLOG],
309[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> 211["/var/log/lastlog"])
310#include <stdlib.h>
311#include <sys/types.h>
312#ifdef HAVE_UTMPX_H
313#include <utmpx.h>
314#elif defined(HAVE_UTMP_H)
315#include <utmp.h>
316#endif
317#ifdef HAVE_LASTLOG_H
318#include <lastlog.h>
319#endif
320#include <errno.h>
321main()
322{
323 char **w, *lastloglist[] = { "/var/log/lastlog", NULL };
324 FILE *a, *f=fopen("conftestval", "w");
325 if (!f) exit(1);
326#ifdef LASTLOG_FILE
327 fprintf(f, "%s\n", LASTLOG_FILE);
328 exit(0);
329#endif
330#ifdef _PATH_LASTLOG
331 fprintf(f, "%s\n", _PATH_LASTLOG);
332 exit(0);
333#endif
334 for (w = lastloglist; *w; w++) {
335 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
336 fprintf(f, "%s\n", *w);
337 exit(0);
338 }
339 }
340 exit(0);
341}]])],[pt_cv_path_lastlog=`cat conftestval`],[pt_cv_path_lastlog=],[dnl
342 AC_MSG_WARN(Define LASTLOG_FILE in config.h manually)])])
343if test x$pt_cv_path_lastlog != x; then
344 AC_DEFINE_UNQUOTED(LASTLOG_FILE, "$pt_cv_path_lastlog", Define location of lastlog)
345fi
346dnl# -------------------------------------------------------------------------- 212dnl# --------------------------------------------------------------------------
347 213
348dnl# find lastlogx 214dnl# find lastlogx
349AC_CACHE_CHECK(where lastlogx is located, pt_cv_path_lastlogx, 215PT_FIND_FILE([lastlogx], [LASTLOGX_FILE], [_PATH_LASTLOGX],
350[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> 216["/var/log/lastlogx", "/var/adm/lastlogx"])
351#include <stdlib.h>
352#ifdef HAVE_UTMPX_H
353#include <utmpx.h>
354#endif
355#include <errno.h>
356main()
357{
358 char **w, *wtmplist[] = { "/var/log/lastlogx", "/var/adm/lastlogx", NULL };
359 FILE *a, *f=fopen("conftestval", "w");
360 if (!f) exit(1);
361#ifdef LASTLOGX_FILE
362 fprintf(f, "%s\n", LASTLOGX_FILE);
363 exit(0);
364#endif
365#ifdef _PATH_LASTLOGX
366 fprintf(f, "%s\n", _PATH_LASTLOGX);
367 exit(0);
368#endif
369 for (w = wtmplist; *w; w++) {
370 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
371 fprintf(f, "%s\n", *w);
372 exit(0);
373 }
374 }
375 exit(0);
376}]])],[pt_cv_path_lastlogx=`cat conftestval`],[pt_cv_path_lastlogx=],[dnl
377 AC_MSG_WARN(Define LASTLOGX_FILE in config.h manually)])])
378if test x$pt_cv_path_lastlogx != x; then
379 AC_DEFINE_UNQUOTED(LASTLOGX_FILE, "$pt_cv_path_lastlogx", Define location of lastlogx)
380fi
381]) 217])
382 218
383AC_DEFUN([SCM_RIGHTS_CHECK], 219AC_DEFUN([SCM_RIGHTS_CHECK],
384[ 220[
385AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds, 221AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds,
427#include <sys/types.h> 263#include <sys/types.h>
428#include <sys/stat.h> 264#include <sys/stat.h>
429#include <unistd.h> 265#include <unistd.h>
430#include <grp.h> 266#include <grp.h>
431 267
432main() 268int main()
433{ 269{
434 struct stat st; 270 struct stat st;
435 struct group *gr; 271 struct group *gr;
436 char *tty; 272 char *tty;
437 gr = getgrnam("tty"); 273 gr = getgrnam("tty");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines