1 dnl> $Id: xpm.m4,v 1.2 2003-11-24 17:31:27 pcg Exp $
2 dnl> test to find the hard-to-find libXpm
3 dnl> mostly copied from AC_PATH_X & AC_PATH_DIRECT, but explictly set
5 AC_DEFUN(VT_FIND_LIBXPM,
9 # Initialize some more variables set by options.
10 # The variables have the same names as the options, with
11 # dashes changed to underlines.
13 # If we find XPM, set shell vars xpm_includes and xpm_libraries to the
14 # paths, otherwise set no_xpm=yes.
15 # Uses ac_ vars as temps to allow command line to override cache and checks.
16 AC_MSG_CHECKING(for libXpm)
18 AC_ARG_WITH(xpm_includes,
19 [ --with-xpm-includes=DIR use XPM includes in DIR],
20 xpm_includes="$withval", xpm_includes=NO)
21 AC_ARG_WITH(xpm_library,
22 [ --with-xpm-library=DIR use XPM library in DIR],
23 xpm_libraries="$withval", xpm_libraries=NO)
25 # --without-xpm overrides everything else, but does not touch the cache.
27 [ --with-xpm use XPM])
28 if test "$with_xpm" = no; then
31 AC_CACHE_VAL(ac_cv_have_xpm, [
33 if test -n "$xpm_includes"; then
34 vt_xpm_includes=$xpm_includes
38 if test -n "$xpm_libraries"; then
39 vt_xpm_libraries=$xpm_libraries
46 if test "$vt_xpm_includes" = NO -o "$vt_xpm_libraries" = NO; then
47 ac_cv_have_xpm="have_xpm=no"
49 ac_cv_have_xpm="have_xpm=yes \
50 vt_xpm_includes=$vt_xpm_includes vt_xpm_libraries=$vt_xpm_libraries \
51 vt_xpm_include_X11=$vt_xpm_include_X11"
53 eval "$ac_cv_have_xpm"
56 if test "$have_xpm" != yes; then
57 AC_MSG_RESULT($have_xpm)
60 if test "$xpm_includes" != NO; then
61 if test "$xpm_includes" = "$vt_xpm_includes"; then
62 if test -r "$xpm_includes/X11/xpm.h"; then
63 vt_xpm_include_X11=yes
67 if test -z "$xpm_includes"; then
68 AC_TRY_CPP([#include <X11/xpm.h>],
69 vt_xpm_include_X11=yes)
71 if test -r "$xpm_includes/X11/xpm.h"; then
72 vt_xpm_include_X11=yes
76 vt_xpm_includes=$xpm_includes
78 if test "x$xpm_libraries" != xNO; then
79 vt_xpm_libraries=$xpm_libraries
81 # Update the cache value to reflect the command line values.
82 ac_cv_have_xpm="have_xpm=yes \
83 vt_xpm_includes=$vt_xpm_includes vt_xpm_libraries=$vt_xpm_libraries \
84 vt_xpm_include_X11=$vt_xpm_include_X11"
85 eval "$ac_cv_have_xpm"
86 AC_MSG_RESULT([-I$vt_xpm_includes, -L$vt_xpm_libraries])
87 if test -n "$vt_xpm_includes"; then
88 XPM_CPPFLAGS="-DHAVE_LIBXPM"
90 if test -n "$vt_xpm_includes"; then
91 XPM_CFLAGS="-I$vt_xpm_includes"
94 if test -n "$vt_xpm_libraries"; then
95 XPM_LIBS="-L$vt_xpm_libraries $XPM_LIBS"
97 if test "x$vt_xpm_include_X11" = xyes; then
98 AC_DEFINE(XPM_INC_X11, 1, Define if you include <X11/xpm.h> on a normal include path (be careful))
102 AC_SUBST(XPM_CPPFLAGS)
107 dnl Internal subroutine of VT_FIND_LIBXPM
108 dnl Set vt_xpm_include and vt_xpm_libr
109 # -------------- find xpm.h and Xpm.a/Xpm.so/Xpm.sl
110 AC_DEFUN(VT_XPM_DIRECT,
111 [if test "$vt_xpm_includes" = NO; then
112 # Guess where to find xpm.h
114 ac_save_CPPFLAGS="$CPPFLAGS"
115 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
117 # First, try using that file with no special directory specified.
118 AC_TRY_CPP([#include <X11/xpm.h>],
119 [# We can compile using X headers with no special include directory.
121 vt_xpm_include_X11=yes],
122 [CPPFLAGS="$ac_save_CPPFLAGS"
123 # Look for the header file in a standard set of common directories.
135 /usr/local/X11/include \
136 /usr/local/X11R6/include \
137 /usr/local/X11R5/include \
138 /usr/local/X11R4/include \
140 /usr/local/include/X11 \
141 /usr/local/include/X11R6 \
142 /usr/local/include/X11R5 \
143 /usr/local/include/X11R4 \
147 /usr/XFree86/include/X11 \
151 /usr/unsupported/include \
152 /usr/athena/include \
153 /usr/local/x11r5/include \
154 /usr/lpp/Xamples/include \
156 /usr/openwin/include \
157 /usr/openwin/share/include \
160 if test -r "$ac_dir/X11/xpm.h"; then
161 vt_xpm_includes="$ac_dir"
162 vt_xpm_include_X11=yes
165 if test -r "$ac_dir/xpm.h"; then
166 vt_xpm_includes=$ac_dir
173 if test "$vt_xpm_libraries" = NO; then
174 # Check for the libraries.
176 # See if we find them without any special options.
177 # Don't add to $LIBS permanently.
179 LIBS="$LIBS $X_LIBS -lXpm -lX11"
180 AC_TRY_LINK(, [XpmReadFileToPixmap()],
181 [LIBS="$ac_save_LIBS"
182 # We can link libXpm with no special library path.
184 [LIBS="$ac_save_LIBS"
185 # First see if replacing the include by lib works.
187 `echo "$vt_xpm_includes" | sed 's,include/X11,lib,;s,include,lib,'` \
199 /usr/local/X11R6/lib \
200 /usr/local/X11R5/lib \
201 /usr/local/X11R4/lib \
204 /usr/local/lib/X11R6 \
205 /usr/local/lib/X11R5 \
206 /usr/local/lib/X11R4 \
210 /usr/XFree86/lib/X11 \
214 /usr/unsupported/lib \
216 /usr/local/x11r5/lib \
217 /usr/lpp/Xamples/lib \
220 /usr/openwin/share/lib \
223 dnl XXX Shouldn't this really use AC_TRY_LINK to be portable & robust??
224 for ac_extension in a so sl; do
225 if test -r $ac_dir/libXpm.$ac_extension; then
226 vt_xpm_libraries=$ac_dir