ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/autoconf/xpm.m4
Revision: 1.1
Committed: Mon Nov 24 17:28:08 2003 UTC (20 years, 7 months ago) by pcg
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 pcg 1.1 dnl> $Id: xpm.m4,v 1.1 2003/11/18 14:22:15 root 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
4    
5     AC_DEFUN(VT_FIND_LIBXPM,
6     [
7     AC_REQUIRE_CPP()
8    
9     # Initialize some more variables set by options.
10     # The variables have the same names as the options, with
11     # dashes changed to underlines.
12    
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)
17    
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)
24    
25     # --without-xpm overrides everything else, but does not touch the cache.
26     AC_ARG_WITH(xpm,
27     [ --with-xpm use XPM])
28     if test "$with_xpm" = no; then
29     have_xpm=disabled
30     else
31     AC_CACHE_VAL(ac_cv_have_xpm, [
32     vt_xpm_include_X11=no
33     if test -n "$xpm_includes"; then
34     vt_xpm_includes=$xpm_includes
35     else
36     vt_xpm_includes=NO
37     fi
38     if test -n "$xpm_libraries"; then
39     vt_xpm_libraries=$xpm_libraries
40     else
41     vt_xpm_libraries=NO
42     fi
43    
44     VT_XPM_DIRECT
45    
46     if test "$vt_xpm_includes" = NO -o "$vt_xpm_libraries" = NO; then
47     ac_cv_have_xpm="have_xpm=no"
48     else
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"
52     fi])dnl
53     eval "$ac_cv_have_xpm"
54     fi
55    
56     if test "$have_xpm" != yes; then
57     AC_MSG_RESULT($have_xpm)
58     no_xpm=yes
59     else
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
64     fi
65     else
66     vt_xpm_include_X11=no
67     if test -z "$xpm_includes"; then
68     AC_TRY_CPP([#include <X11/xpm.h>],
69     vt_xpm_include_X11=yes)
70     else
71     if test -r "$xpm_includes/X11/xpm.h"; then
72     vt_xpm_include_X11=yes
73     fi
74     fi
75     fi
76     vt_xpm_includes=$xpm_includes
77     fi
78     if test "x$xpm_libraries" != xNO; then
79     vt_xpm_libraries=$xpm_libraries
80     fi
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"
89     fi
90     if test -n "$vt_xpm_includes"; then
91     XPM_CFLAGS="-I$vt_xpm_includes"
92     fi
93     XPM_LIBS="-lXpm"
94     if test -n "$vt_xpm_libraries"; then
95     XPM_LIBS="-L$vt_xpm_libraries $XPM_LIBS"
96     fi
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))
99     fi
100     fi
101    
102     AC_SUBST(XPM_CPPFLAGS)
103     AC_SUBST(XPM_CFLAGS)
104     AC_SUBST(XPM_LIBS)
105     ])
106    
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
113    
114     ac_save_CPPFLAGS="$CPPFLAGS"
115     CPPFLAGS="$CPPFLAGS $X_CFLAGS"
116    
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.
120     vt_xpm_includes=
121     vt_xpm_include_X11=yes],
122     [CPPFLAGS="$ac_save_CPPFLAGS"
123     # Look for the header file in a standard set of common directories.
124     for ac_dir in \
125     /usr/X11/include \
126     /usr/X11R6/include \
127     /usr/X11R5/include \
128     /usr/X11R4/include \
129     \
130     /usr/include/X11 \
131     /usr/include/X11R6 \
132     /usr/include/X11R5 \
133     /usr/include/X11R4 \
134     \
135     /usr/local/X11/include \
136     /usr/local/X11R6/include \
137     /usr/local/X11R5/include \
138     /usr/local/X11R4/include \
139     \
140     /usr/local/include/X11 \
141     /usr/local/include/X11R6 \
142     /usr/local/include/X11R5 \
143     /usr/local/include/X11R4 \
144     \
145     /usr/X386/include \
146     /usr/x386/include \
147     /usr/XFree86/include/X11 \
148     \
149     /usr/include \
150     /usr/local/include \
151     /usr/unsupported/include \
152     /usr/athena/include \
153     /usr/local/x11r5/include \
154     /usr/lpp/Xamples/include \
155     \
156     /usr/openwin/include \
157     /usr/openwin/share/include \
158     ; \
159     do
160     if test -r "$ac_dir/X11/xpm.h"; then
161     vt_xpm_includes="$ac_dir"
162     vt_xpm_include_X11=yes
163     break
164     else
165     if test -r "$ac_dir/xpm.h"; then
166     vt_xpm_includes=$ac_dir
167     break
168     fi
169     fi
170     done])
171     fi
172    
173     if test "$vt_xpm_libraries" = NO; then
174     # Check for the libraries.
175    
176     # See if we find them without any special options.
177     # Don't add to $LIBS permanently.
178     ac_save_LIBS="$LIBS"
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.
183     vt_xpm_libraries=],
184     [LIBS="$ac_save_LIBS"
185     # First see if replacing the include by lib works.
186     for ac_dir in \
187     `echo "$vt_xpm_includes" | sed 's,include/X11,lib,;s,include,lib,'` \
188     /usr/X11/lib \
189     /usr/X11R6/lib \
190     /usr/X11R5/lib \
191     /usr/X11R4/lib \
192     \
193     /usr/lib/X11 \
194     /usr/lib/X11R6 \
195     /usr/lib/X11R5 \
196     /usr/lib/X11R4 \
197     \
198     /usr/local/X11/lib \
199     /usr/local/X11R6/lib \
200     /usr/local/X11R5/lib \
201     /usr/local/X11R4/lib \
202     \
203     /usr/local/lib/X11 \
204     /usr/local/lib/X11R6 \
205     /usr/local/lib/X11R5 \
206     /usr/local/lib/X11R4 \
207     \
208     /usr/X386/lib \
209     /usr/x386/lib \
210     /usr/XFree86/lib/X11 \
211     \
212     /usr/lib \
213     /usr/local/lib \
214     /usr/unsupported/lib \
215     /usr/athena/lib \
216     /usr/local/x11r5/lib \
217     /usr/lpp/Xamples/lib \
218     \
219     /usr/openwin/lib \
220     /usr/openwin/share/lib \
221     ; \
222     do
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
227     break 2
228     fi
229     done
230     done])
231     fi
232     ])