Merge pull request #9 from lha/master
[heimdal.git] / cf / check-x.m4
blob5d8806c4b10b7b35490afd1b0ed3ad72bc4080d4
1 dnl 
2 dnl See if there is any X11 present
3 dnl
4 dnl $Id$
6 AC_DEFUN([KRB_CHECK_X],[
7 AC_PATH_XTRA
9 # try to figure out if we need any additional ld flags, like -R
10 # and yes, the autoconf X test is utterly broken
11 if test "$no_x" != yes; then
12         AC_CACHE_CHECK(for special X linker flags,krb_cv_sys_x_libs_rpath,[
13         ac_save_libs="$LIBS"
14         ac_save_cflags="$CFLAGS"
15         CFLAGS="$CFLAGS $X_CFLAGS"
16         krb_cv_sys_x_libs_rpath=""
17         krb_cv_sys_x_libs=""
18         for rflag in "" "-R" "-R " "-rpath "; do
19                 if test "$rflag" = ""; then
20                         foo="$X_LIBS"
21                 else
22                         foo=""
23                         for flag in $X_LIBS; do
24                         case $flag in
25                         -L*)
26                                 foo="$foo $flag `echo $flag | sed \"s/-L/$rflag/\"`"
27                                 ;;
28                         *)
29                                 foo="$foo $flag"
30                                 ;;
31                         esac
32                         done
33                 fi
34                 LIBS="$ac_save_libs $foo $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
35                 AC_RUN_IFELSE([
36                 #include <X11/Xlib.h>
37                 foo(void)
38                 {
39                 XOpenDisplay(NULL);
40                 }
41                 main(int argc, char **argv)
42                 {
43                 return 0;
44                 }
45                 ],krb_cv_sys_x_libs_rpath="$rflag"; krb_cv_sys_x_libs="$foo"; break,:,
46                 krb_cv_sys_x_libs_rpath="" ; krb_cv_sys_x_libs="" ; break)
47         done
48         LIBS="$ac_save_libs"
49         CFLAGS="$ac_save_cflags"
50         ])
51         X_LIBS="$krb_cv_sys_x_libs"