1 dnl> test to find the hard-to-find libXpm
2 dnl> mostly copied from AC_PATH_X & AC_PATH_DIRECT, but explictly set
4 AC_DEFUN([VT_FIND_LIBXPM],
8 # Initialize some more variables set by options.
9 # The variables have the same names as the options, with
10 # dashes changed to underlines.
12 # If we find XPM, set shell vars xpm_includes and xpm_libraries to the
13 # paths, otherwise set no_xpm=yes.
14 # Uses ac_ vars as temps to allow command line to override cache and checks.
15 AC_MSG_CHECKING(for libXpm)
17 AC_ARG_WITH(xpm_includes,
18 [ --with-xpm-includes=DIR use XPM includes in DIR],
19 xpm_includes="$withval", xpm_includes=NO)
20 AC_ARG_WITH(xpm_library,
21 [ --with-xpm-library=DIR use XPM library in DIR],
22 xpm_libraries="$withval", xpm_libraries=NO)
24 # --without-xpm overrides everything else, but does not touch the cache.
26 [ --with-xpm use XPM])
27 if test "$with_xpm" = no; then
30 AC_CACHE_VAL(ac_cv_have_xpm, [
32 if test -n "$xpm_includes"; then
33 vt_xpm_includes=$xpm_includes
37 if test -n "$xpm_libraries"; then
38 vt_xpm_libraries=$xpm_libraries
45 if test "$vt_xpm_includes" = NO -o "$vt_xpm_libraries" = NO; then
46 ac_cv_have_xpm="have_xpm=no"
48 ac_cv_have_xpm="have_xpm=yes \
49 vt_xpm_includes=$vt_xpm_includes vt_xpm_libraries=$vt_xpm_libraries \
50 vt_xpm_include_X11=$vt_xpm_include_X11"
52 eval "$ac_cv_have_xpm"
55 if test "$have_xpm" != yes; then
56 AC_MSG_RESULT($have_xpm)
59 if test "$xpm_includes" != NO; then
60 if test "$xpm_includes" = "$vt_xpm_includes"; then
61 if test -r "$xpm_includes/X11/xpm.h"; then
62 vt_xpm_include_X11=yes
66 if test -z "$xpm_includes"; then
67 AC_TRY_CPP([#include <X11/xpm.h>],
68 vt_xpm_include_X11=yes)
70 if test -r "$xpm_includes/X11/xpm.h"; then
71 vt_xpm_include_X11=yes
75 vt_xpm_includes=$xpm_includes
77 if test "x$xpm_libraries" != xNO; then
78 vt_xpm_libraries=$xpm_libraries
80 # Update the cache value to reflect the command line values.
81 ac_cv_have_xpm="have_xpm=yes \
82 vt_xpm_includes=$vt_xpm_includes vt_xpm_libraries=$vt_xpm_libraries \
83 vt_xpm_include_X11=$vt_xpm_include_X11"
84 eval "$ac_cv_have_xpm"
85 AC_MSG_RESULT([-I$vt_xpm_includes, -L$vt_xpm_libraries])
86 if test -n "$vt_xpm_includes"; then
87 XPM_CPPFLAGS="-DHAVE_LIBXPM"
89 if test -n "$vt_xpm_includes"; then
90 XPM_CFLAGS="-I$vt_xpm_includes"
93 if test -n "$vt_xpm_libraries"; then
94 XPM_LIBS="-L$vt_xpm_libraries $XPM_LIBS"
96 if test "x$vt_xpm_include_X11" = xyes; then
97 AC_DEFINE(XPM_INC_X11, 1, Define if you include <X11/xpm.h> on a normal include path (be careful))
101 AC_SUBST(XPM_CPPFLAGS)
106 dnl Internal subroutine of VT_FIND_LIBXPM
107 dnl Set vt_xpm_include and vt_xpm_libr
108 # -------------- find xpm.h and Xpm.a/Xpm.so/Xpm.sl
109 AC_DEFUN([VT_XPM_DIRECT],
110 [if test "$vt_xpm_includes" = NO; then
111 # Guess where to find xpm.h
113 ac_save_CPPFLAGS="$CPPFLAGS"
114 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
116 # First, try using that file with no special directory specified.
117 AC_TRY_CPP([#include <X11/xpm.h>],
118 [# We can compile using X headers with no special include directory.
120 vt_xpm_include_X11=yes],
121 [CPPFLAGS="$ac_save_CPPFLAGS"
122 # Look for the header file in a standard set of common directories.
134 /usr/local/X11/include \
135 /usr/local/X11R6/include \
136 /usr/local/X11R5/include \
137 /usr/local/X11R4/include \
139 /usr/local/include/X11 \
140 /usr/local/include/X11R6 \
141 /usr/local/include/X11R5 \
142 /usr/local/include/X11R4 \
146 /usr/XFree86/include/X11 \
150 /usr/unsupported/include \
151 /usr/athena/include \
152 /usr/local/x11r5/include \
153 /usr/lpp/Xamples/include \
155 /usr/openwin/include \
156 /usr/openwin/share/include \
159 if test -r "$ac_dir/X11/xpm.h"; then
160 vt_xpm_includes="$ac_dir"
161 vt_xpm_include_X11=yes
164 if test -r "$ac_dir/xpm.h"; then
165 vt_xpm_includes=$ac_dir
172 if test "$vt_xpm_libraries" = NO; then
173 # Check for the libraries.
175 # See if we find them without any special options.
176 # Don't add to $LIBS permanently.
178 LIBS="$LIBS $X_LIBS -lXpm -lX11"
179 AC_TRY_LINK(, [XpmReadFileToPixmap()],
180 [LIBS="$ac_save_LIBS"
181 # We can link libXpm with no special library path.
183 [LIBS="$ac_save_LIBS"
184 # First see if replacing the include by lib works.
186 `echo "$vt_xpm_includes" | sed 's,include/X11,lib,;s,include,lib,'` \
198 /usr/local/X11R6/lib \
199 /usr/local/X11R5/lib \
200 /usr/local/X11R4/lib \
203 /usr/local/lib/X11R6 \
204 /usr/local/lib/X11R5 \
205 /usr/local/lib/X11R4 \
209 /usr/XFree86/lib/X11 \
213 /usr/unsupported/lib \
215 /usr/local/x11r5/lib \
216 /usr/lpp/Xamples/lib \
219 /usr/openwin/share/lib \
222 dnl XXX Shouldn't this really use AC_TRY_LINK to be portable & robust??
223 for ac_extension in a so sl; do
224 if test -r $ac_dir/libXpm.$ac_extension; then
225 vt_xpm_libraries=$ac_dir
233 AC_DEFUN([PTY_CHECK],
253 AC_MSG_CHECKING(for /dev/ptym/clone)
254 if test -e /dev/ptym/clone; then
256 AC_DEFINE(HAVE_DEV_CLONE, 1, [Define to 1 if you have /dev/ptym/clone])
257 AC_DEFINE(CLONE_DEVICE, "/dev/ptym/clone", [clone device filename])
263 AC_MSG_CHECKING(for /dev/ptc)
264 if test -e /dev/ptc; then
266 AC_DEFINE(HAVE_DEV_PTC, 1, [Define to 1 if you have /dev/ptc])
267 AC_DEFINE(CLONE_DEVICE, "/dev/ptc", [clone device filename])
276 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
279 AC_MSG_CHECKING(for /dev/ptmx)
280 if test -e /dev/ptmx; then
282 AC_DEFINE(HAVE_DEV_PTMX, 1, [Define to 1 if you have /dev/ptmx])
283 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
291 if test x$ac_cv_func_getpt = xyes -o x$ac_cv_func_posix_openpt = xyes -o x$have_clone = xyes; then
292 AC_MSG_CHECKING(for UNIX98 ptys)
293 AC_TRY_LINK([#include <stdlib.h>],
294 [grantpt(0);unlockpt(0);ptsname(0);],
296 AC_DEFINE(UNIX98_PTY, 1, "")
301 if test -z "$unix98_pty"; then
302 AC_CHECK_FUNCS(openpty, [], [AC_CHECK_LIB(util, openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"])])
306 AC_DEFUN([UTMP_CHECK],
320 dnl# --------------------------------------------------------------------------
321 dnl# DO ALL UTMP AND WTMP CHECKING
322 dnl# --------------------------------------------------------------------------
323 dnl# check for host field in utmp structure
325 dnl# --------------------------------------------
326 AC_CHECK_HEADER(utmp.h,
327 [AC_CACHE_CHECK([for struct utmp], rxvt_cv_struct_utmp,
328 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
329 #include <utmp.h>]], [[struct utmp ut;]])],[rxvt_cv_struct_utmp=yes],[rxvt_cv_struct_utmp=no])])
330 if test x$rxvt_cv_struct_utmp = xyes; then
331 AC_DEFINE(HAVE_STRUCT_UTMP, 1, Define if utmp.h has struct utmp)
335 AC_CACHE_CHECK(for ut_host in utmp struct, rxvt_cv_struct_utmp_host,
336 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
337 #include <utmp.h>]], [[struct utmp ut; ut.ut_host;]])],[rxvt_cv_struct_utmp_host=yes],[rxvt_cv_struct_utmp_host=no])])
338 if test x$rxvt_cv_struct_utmp_host = xyes; then
339 AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)
342 AC_CACHE_CHECK(for ut_pid in utmp struct, rxvt_cv_struct_utmp_pid,
343 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
344 #include <utmp.h>]], [[struct utmp ut; ut.ut_pid;]])],[rxvt_cv_struct_utmp_pid=yes],[rxvt_cv_struct_utmp_pid=no])])
345 if test x$rxvt_cv_struct_utmp_pid = xyes; then
346 AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)
348 ) dnl# AC_CHECK_HEADER(utmp.h
350 dnl# --------------------------------------------
352 AC_CHECK_HEADER(utmpx.h,
353 [AC_CACHE_CHECK([for struct utmpx], rxvt_cv_struct_utmpx,
354 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
355 #include <utmpx.h>]], [[struct utmpx ut;]])],[rxvt_cv_struct_utmpx=yes],[rxvt_cv_struct_utmpx=no])])
356 if test x$rxvt_cv_struct_utmpx = xyes; then
357 AC_DEFINE(HAVE_STRUCT_UTMPX, 1, Define if utmpx.h has struct utmpx)
361 AC_CACHE_CHECK(for host in utmpx struct, rxvt_cv_struct_utmpx_host,
362 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
363 #include <utmpx.h>]], [[struct utmpx utx; utx.ut_host;]])],[rxvt_cv_struct_utmpx_host=yes],[rxvt_cv_struct_utmpx_host=no])])
364 if test x$rxvt_cv_struct_utmpx_host = xyes; then
365 AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)
368 AC_CACHE_CHECK(for session in utmpx struct, rxvt_cv_struct_utmpx_session,
369 [AC_TRY_COMPILE([#include <sys/types.h>
371 [struct utmpx utx; utx.ut_session;],
372 rxvt_cv_struct_utmpx_session=yes, rxvt_cv_struct_utmpx_session=no)])
373 if test x$rxvt_cv_struct_utmpx_session = xyes; then
374 AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session)
376 ) dnl# AC_CHECK_HEADER(utmpx.h
378 dnl# --------------------------------------------------------------------------
379 dnl# check for struct lastlog
380 AC_CACHE_CHECK(for struct lastlog, rxvt_cv_struct_lastlog,
381 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
383 #ifdef HAVE_LASTLOG_H
386 ]], [[struct lastlog ll;]])],[rxvt_cv_struct_lastlog=yes],[rxvt_cv_struct_lastlog=no])])
387 if test x$rxvt_cv_struct_lastlog = xyes; then
388 AC_DEFINE(HAVE_STRUCT_LASTLOG, 1, Define if utmp.h or lastlog.h has struct lastlog)
391 dnl# check for struct lastlogx
392 AC_CACHE_CHECK(for struct lastlogx, rxvt_cv_struct_lastlogx,
393 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
395 #ifdef HAVE_LASTLOG_H
398 ]], [[struct lastlogx ll;]])],[rxvt_cv_struct_lastlogx=yes],[rxvt_cv_struct_lastlogx=no])])
399 if test x$rxvt_cv_struct_lastlogx = xyes; then
400 AC_DEFINE(HAVE_STRUCT_LASTLOGX, 1, Define if utmpx.h or lastlog.h has struct lastlogx)
403 dnl# --------------------------------------------------------------------------
405 dnl# --------------------------------------------------------------------------
408 AC_CACHE_CHECK(where utmp is located, rxvt_cv_path_utmp,
409 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
410 #include <sys/types.h>
415 char **u, *utmplist[] = {
416 "/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp", NULL };
417 FILE *a, *f=fopen("conftestval", "w");
420 fprintf(f, "%s\n", UTMP_FILE);
424 fprintf(f, "%s\n", _PATH_UTMP);
427 for (u = utmplist; *u; u++) {
428 if ((a = fopen(*u, "r")) != NULL || errno == EACCES) {
429 fprintf(f, "%s\n", *u);
434 }]])],[rxvt_cv_path_utmp=`cat conftestval`],[rxvt_cv_path_utmp=],[dnl
435 AC_MSG_WARN(Define RXVT_UTMP_FILE in config.h manually)])])
436 if test x$rxvt_cv_path_utmp != x; then
437 AC_DEFINE_UNQUOTED(RXVT_UTMP_FILE, "$rxvt_cv_path_utmp", Define location of utmp)
440 dnl# --------------------------------------------------------------------------
442 dnl# find utmpx - if a utmp file exists at the same location and is more than
443 dnl# a day newer, then dump the utmpx. People leave lots of junk around.
444 AC_CACHE_CHECK(where utmpx is located, rxvt_cv_path_utmpx,
445 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
446 #include <sys/types.h>
449 #include <sys/stat.h>
455 char **u, *p, *utmplist[] = {
462 "/var/adm/utmpx", "/etc/utmpx", NULL };
463 FILE *a, *f=fopen("conftestval", "w");
464 struct stat statu, statux;
466 for (u = utmplist; *u; u++) {
467 if ((a = fopen(*u, "r")) != NULL || errno == EACCES) {
468 if (stat(*u, &statux) < 0)
471 p[strlen(p) - 1] = '\0';
472 if (stat(p, &statu) >= 0
473 && (statu.st_mtime - statux.st_mtime > 86400))
475 fprintf(f, "%s\n", *u);
480 }]])],[rxvt_cv_path_utmpx=`cat conftestval`],[rxvt_cv_path_utmpx=],[dnl
481 AC_MSG_WARN(Define RXVT_UTMPX_FILE in config.h manually)])])
482 if test x$rxvt_cv_path_utmpx != x; then
483 AC_DEFINE_UNQUOTED(RXVT_UTMPX_FILE, "$rxvt_cv_path_utmpx", Define location of utmpx)
486 dnl# --------------------------------------------------------------------------
489 AC_CACHE_CHECK(where wtmp is located, rxvt_cv_path_wtmp,
490 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
491 #include <sys/types.h>
498 char **w, *wtmplist[] = {
499 "/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp", NULL };
500 FILE *a, *f=fopen("conftestval", "w");
503 fprintf(f, "%s\n", WTMP_FILE);
507 fprintf(f, "%s\n", _PATH_WTMP);
510 for (w = wtmplist; *w; w++) {
511 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
512 fprintf(f, "%s\n", *w);
517 }]])],[rxvt_cv_path_wtmp=`cat conftestval`],[rxvt_cv_path_wtmp=],[dnl
518 AC_MSG_WARN(Define RXVT_WTMP_FILE in config.h manually)])])
519 if test x$rxvt_cv_path_wtmp != x; then
520 AC_DEFINE_UNQUOTED(RXVT_WTMP_FILE, "$rxvt_cv_path_wtmp", Define location of wtmp)
522 dnl# --------------------------------------------------------------------------
525 AC_CACHE_CHECK(where wtmpx is located, rxvt_cv_path_wtmpx,
526 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
533 char **w, *wtmplist[] = {
534 "/var/log/wtmpx", "/var/adm/wtmpx", NULL };
535 FILE *a, *f=fopen("conftestval", "w");
538 fprintf(f, "%s\n", WTMPX_FILE);
542 fprintf(f, "%s\n", _PATH_WTMPX);
545 for (w = wtmplist; *w; w++) {
546 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
547 fprintf(f, "%s\n", *w);
552 }]])],[rxvt_cv_path_wtmpx=`cat conftestval`],[rxvt_cv_path_wtmpx=],[dnl
553 AC_MSG_WARN(Define RXVT_WTMPX_FILE in config.h manually)])])
554 if test x$rxvt_cv_path_wtmpx != x; then
555 AC_DEFINE_UNQUOTED(RXVT_WTMPX_FILE, "$rxvt_cv_path_wtmpx", Define location of wtmpx)
557 dnl# --------------------------------------------------------------------------
560 AC_CACHE_CHECK(where lastlog is located, rxvt_cv_path_lastlog,
561 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
562 #include <sys/types.h>
565 #elif defined(HAVE_UTMP_H)
568 #ifdef HAVE_LASTLOG_H
574 char **w, *lastloglist[] = { "/var/log/lastlog", NULL };
575 FILE *a, *f=fopen("conftestval", "w");
578 fprintf(f, "%s\n", LASTLOG_FILE);
582 fprintf(f, "%s\n", _PATH_LASTLOG);
585 for (w = lastloglist; *w; w++) {
586 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
587 fprintf(f, "%s\n", *w);
592 }]])],[rxvt_cv_path_lastlog=`cat conftestval`],[rxvt_cv_path_lastlog=],[dnl
593 AC_MSG_WARN(Define RXVT_LASTLOG_FILE in config.h manually)])])
594 if test x$rxvt_cv_path_lastlog != x; then
595 AC_DEFINE_UNQUOTED(RXVT_LASTLOG_FILE, "$rxvt_cv_path_lastlog", Define location of lastlog)
596 if test -d "$rxvt_cv_path_lastlog"; then
597 AC_DEFINE(LASTLOG_IS_DIR, 1, Define if lastlog is provided via a directory)
600 dnl# --------------------------------------------------------------------------
603 AC_CACHE_CHECK(where lastlogx is located, rxvt_cv_path_lastlogx,
604 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
611 char **w, *wtmplist[] = { "/var/log/lastlogx", "/var/adm/lastlogx", NULL };
612 FILE *a, *f=fopen("conftestval", "w");
615 fprintf(f, "%s\n", LASTLOGX_FILE);
618 #ifdef _PATH_LASTLOGX
619 fprintf(f, "%s\n", _PATH_LASTLOGX);
622 for (w = wtmplist; *w; w++) {
623 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
624 fprintf(f, "%s\n", *w);
629 }]])],[rxvt_cv_path_lastlogx=`cat conftestval`],[rxvt_cv_path_lastlogx=],[dnl
630 AC_MSG_WARN(Define RXVT_LASTLOGX_FILE in config.h manually)])])
631 if test x$rxvt_cv_path_lastlogx != x; then
632 AC_DEFINE_UNQUOTED(RXVT_LASTLOGX_FILE, "$rxvt_cv_path_lastlogx", Define location of lastlogx)