1# Try to configure the XAW client (gui-xaw)
2
3# FC_XAW_CLIENT
4# Test for X and XAW libraries needed for gui-xaw
5
6AC_DEFUN([FC_XAW_CLIENT],
7[
8  AC_REQUIRE([AC_PATH_XTRA])
9  if test "x$gui_xaw" = "xyes" || test "x$client" = "xall" ||
10     test "x$client" = "xauto" ; then
11    dnl Checks for X:
12    AC_PATH_XTRA
13
14    dnl Determine the Xfuncproto control definitions:
15    FC_CHECK_X_PROTO_DEFINE(FUNCPROTO)
16    if test -n "$fc_x_proto_value"; then
17      AC_DEFINE_UNQUOTED([FUNCPROTO], [$fc_x_proto_value], [Xfuncproto])
18    fi
19    FC_CHECK_X_PROTO_DEFINE(NARROWPROTO)
20    if test -n "$fc_x_proto_value"; then
21      AC_DEFINE_UNQUOTED([NARROWPROTO], [$fc_x_proto_value], [Narrowproto])
22    fi
23
24    PKG_PROG_PKG_CONFIG
25
26    dnl Check for libpng
27    PKG_CHECK_MODULES([PNG], [libpng],
28    [
29      X_LIBS="$X_LIBS $PNG_LIBS"
30      X_CFLAGS="$X_CFLAGS $PNG_CFLAGS"
31    ],
32    [
33      AC_CHECK_LIB([png12], [png_read_image], [X_LIBS="$X_LIBS -lpng12 -lm"],
34      [
35        AC_CHECK_LIB([png], [png_read_image], [X_LIBS="$X_LIBS -lpng -lm"],
36        [
37          FC_NO_CLIENT([xaw], [Could not find PNG library.])
38          no_png=yes
39        ])
40      ])
41      AC_CHECK_HEADER([png.h],,
42      [
43        FC_NO_CLIENT([xaw], [libpng found but not png.h.
44You may need to install a libpng "development" package.])
45        no_png=yes
46      ])
47    ])
48
49    dnl Try to get additional Xpm paths:
50    FC_XPM_PATHS
51
52    if test "$xpm_incdir" != "no"; then
53      X_CFLAGS="$X_CFLAGS -I$xpm_incdir"
54    fi
55    if test "$xpm_libdir" != "no"; then
56      X_LIBS="$X_LIBS -L$xpm_libdir"
57      dnl Try using R values set in AC_PATH_XTRA:
58      if test "$ac_R_nospace" = "yes"; then
59        X_LIBS="$X_LIBS -R$xpm_libdir"
60      elif test "$ac_R_space" = "yes"; then
61        X_LIBS="$X_LIBS -R $xpm_libdir"
62      fi
63      dnl Some sites may put xpm.h in a directory whose parent isn't "X11"
64      if test "x$xpm_h_no_x11" = "xyes"; then
65        AC_DEFINE([XPM_H_NO_X11], [1], [XPM support])
66      fi
67    fi
68
69    dnl Checks for X libs:
70    fc_save_X_LIBS="$X_LIBS"
71    X_LIBS="$X_LIBS $X_PRE_LIBS"
72    FC_CHECK_X_LIB(X11, XOpenDisplay, , haveX11=no)
73    if test "x$haveX11" != "xno"; then
74      FC_CHECK_X_LIB(Xext, XShapeCombineMask)
75
76      dnl Insert X_PRE_LIBS (eg -lSM -lICE) into X_EXTRA_LIBS here:
77      X_EXTRA_LIBS="$X_PRE_LIBS $X_EXTRA_LIBS"
78      X_LIBS="$fc_save_X_LIBS"
79
80      FC_CHECK_X_LIB(Xt, main)
81      FC_CHECK_X_LIB(Xmu, main)
82      FC_CHECK_X_LIB(Xpm, XpmReadFileToPixmap, , haveXpm=no)
83      if test "x$haveXpm" != "xno"; then
84	dnl Xaw or Xaw3d:
85	if test -n "$WITH_XAW3D"; then
86	  FC_CHECK_X_LIB(Xaw3d, main, , AC_MSG_ERROR(did not find Xaw3d library))
87        else
88	  FC_CHECK_X_LIB(Xaw, main, , AC_MSG_ERROR(did not find Xaw library))
89	fi
90
91	gui_xaw_cflags="$X_CFLAGS"
92	gui_xaw_libs="$X_LIBS $X_EXTRA_LIBS"
93
94	found_client=yes
95      fi
96    fi
97
98    if test "x$found_client" = "xyes" && test "x$no_png" != "xyes"; then
99      gui_xaw=yes
100      if test "x$client" = "xauto" ; then
101        client=yes
102      fi
103    elif test "x$gui_xaw" = "xyes"; then
104      if test "x$haveXpm" = "xno"; then
105	AC_MSG_ERROR(specified client 'xaw' not configurable -- need Xpm library and development headers; perhaps try/adjust --with-xpm-lib)
106      else
107	AC_MSG_ERROR(specified client 'xaw' not configurable -- need X11 libraries and development headers; perhaps try/adjust --x-libraries)
108      fi
109    fi
110  fi
111])
112