4 dnl Find Xpm libraries and headers.
5 dnl Put Xpm include directory in xpm_includes,
6 dnl put Xpm library directory in xpm_libraries,
7 dnl and add appropriate flags to X_CFLAGS and X_LIBS.
10 AC_DEFUN([AC_FIND_XPM],
12 AC_REQUIRE([AC_PATH_XTRA])
16 [ --without-xpm do not use the Xpm library])
17 dnl Treat --without-xpm like
18 dnl --without-xpm-includes --without-xpm-libraries.
19 if test "$with_xpm" = "no"
24 AC_ARG_WITH(xpm-includes,
25 [ --with-xpm-includes=DIR Xpm include files are in DIR],
26 xpm_includes="$withval")
27 AC_ARG_WITH(xpm-libraries,
28 [ --with-xpm-libraries=DIR
29 Xpm libraries are in DIR],
30 xpm_libraries="$withval")
31 AC_MSG_CHECKING(for Xpm)
34 # Search the include files. Note that XPM can come in <X11/xpm.h> (as
35 # in X11R6) or in <xpm.h> if installed locally.
37 if test "$xpm_includes" = ""; then
38 AC_CACHE_VAL(ice_cv_xpm_includes,
40 ice_xpm_save_LIBS="$LIBS"
41 ice_xpm_save_CFLAGS="$CFLAGS"
42 ice_xpm_save_CPPFLAGS="$CPPFLAGS"
43 ice_xpm_save_LDFLAGS="$LDFLAGS"
45 LIBS="$X_PRE_LIBS -lXpm -lXt -lX11 $X_EXTRA_LIBS $LIBS"
46 CFLAGS="$X_CFLAGS $CFLAGS"
47 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
48 LDFLAGS="$X_LIBS $LDFLAGS"
54 # X11/xpm.h is in the standard search path.
58 # X11/xpm.h is not in the standard search path.
59 # Locate it and put its directory in `xpm_includes'
61 # /usr/include/Motif* are used on HP-UX (Motif).
62 # /usr/include/X11* are used on HP-UX (X and Xaw).
63 # /usr/dt is used on Solaris (Motif).
64 # /usr/openwin is used on Solaris (X and Xaw).
65 # Other directories are just guesses.
66 for dir in "$x_includes" "${prefix}/include" /usr/include /usr/local/include \
67 /usr/include/Motif2.0 /usr/include/Motif1.2 /usr/include/Motif1.1 \
68 /usr/include/X11R6 /usr/include/X11R5 /usr/include/X11R4 \
69 /usr/dt/include /usr/openwin/include \
70 /usr/dt/*/include /opt/*/include /usr/include/Motif* \
71 /usr/*/include/X11R6 /usr/*/include/X11R5 /usr/*/include/X11R4 \
72 "${prefix}"/*/include /usr/*/include /usr/local/*/include \
73 "${prefix}"/include/* /usr/include/* /usr/local/include/*; do
74 if test -f "$dir/X11/xpm.h" || test -f "$dir/xpm.h"; then
75 ice_cv_xpm_includes="$dir"
79 if test "$ice_cv_xpm_includes" = "/usr/include"; then
84 LIBS="$ice_xpm_save_LIBS"
85 CFLAGS="$ice_xpm_save_CFLAGS"
86 CPPFLAGS="$ice_xpm_save_CPPFLAGS"
87 LDFLAGS="$ice_xpm_save_LDFLAGS"
89 xpm_includes="$ice_cv_xpm_includes"
93 # Now for the libraries.
95 if test "$xpm_libraries" = ""; then
96 AC_CACHE_VAL(ice_cv_xpm_libraries,
98 ice_xpm_save_LIBS="$LIBS"
99 ice_xpm_save_CFLAGS="$CFLAGS"
100 ice_xpm_save_CPPFLAGS="$CPPFLAGS"
101 ice_xpm_save_LDFLAGS="$LDFLAGS"
103 LIBS="$X_PRE_LIBS -lXpm -lXt -lX11 $X_EXTRA_LIBS $LIBS"
104 CFLAGS="$X_CFLAGS $CFLAGS"
105 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
106 LDFLAGS="$X_LIBS $LDFLAGS"
109 # We use XtToolkitInitialize() here since it takes no arguments
110 # and thus also works with a C++ compiler.
112 #include <X11/Intrinsic.h>
114 ],[XtToolkitInitialize();],
116 # libxpm.a is in the standard search path.
117 ice_cv_xpm_libraries=
120 # libXpm.a is not in the standard search path.
121 # Locate it and put its directory in `xpm_libraries'
124 # /usr/lib/Motif* are used on HP-UX (Motif).
125 # /usr/lib/X11* are used on HP-UX (X and Xpm).
126 # /usr/dt is used on Solaris (Motif).
127 # /usr/openwin is used on Solaris (X and Xpm).
128 # Other directories are just guesses.
129 for dir in "$x_libraries" "${prefix}/lib" /usr/lib /usr/local/lib \
130 /usr/lib/Motif2.0 /usr/lib/Motif1.2 /usr/lib/Motif1.1 \
131 /usr/lib/X11R6 /usr/lib/X11R5 /usr/lib/X11R4 /usr/lib/X11 \
132 /usr/dt/lib /usr/openwin/lib \
133 /usr/dt/*/lib /opt/*/lib /usr/lib/Motif* \
134 /usr/*/lib/X11R6 /usr/*/lib/X11R5 /usr/*/lib/X11R4 /usr/*/lib/X11 \
135 "${prefix}"/*/lib /usr/*/lib /usr/local/*/lib \
136 "${prefix}"/lib/* /usr/lib/* /usr/local/lib/*; do
137 if test -d "$dir" && test "`ls $dir/libXpm.* 2> /dev/null`" != ""; then
138 ice_cv_xpm_libraries="$dir"
144 LIBS="$ice_xpm_save_LIBS"
145 CFLAGS="$ice_xpm_save_CFLAGS"
146 CPPFLAGS="$ice_xpm_save_CPPFLAGS"
147 LDFLAGS="$ice_xpm_save_LDFLAGS"
150 xpm_libraries="$ice_cv_xpm_libraries"
153 # Add Xpm definitions to X flags
155 if test "$xpm_includes" != "" && test "$xpm_includes" != "$x_includes" && test "$xpm_includes" != "no"
157 X_CFLAGS="-I$xpm_includes $X_CFLAGS"
159 if test "$xpm_libraries" != "" && test "$xpm_libraries" != "$x_libraries" && test "$xpm_libraries" != "no"
162 *-R\ *) X_LIBS="-L$xpm_libraries -R $xpm_libraries $X_LIBS";;
163 *-R*) X_LIBS="-L$xpm_libraries -R$xpm_libraries $X_LIBS";;
164 *) X_LIBS="-L$xpm_libraries $X_LIBS";;
169 xpm_libraries_result="$xpm_libraries"
170 xpm_includes_result="$xpm_includes"
172 if test "$xpm_libraries_result" != "no" && test "$xpm_includes_result" != "no"
173 then AC_DEFINE(HAVE_XPM, 1, "Define if you have libxpm")
180 test "$xpm_libraries_result" = "" &&
181 xpm_libraries_result="in default path"
182 test "$xpm_includes_result" = "" &&
183 xpm_includes_result="in default path"
184 test "$xpm_libraries_result" = "no" &&
185 xpm_libraries_result="(none)"
186 test "$xpm_includes_result" = "no" &&
187 xpm_includes_result="(none)"
189 [libraries $xpm_libraries_result, headers $xpm_includes_result])