| 1 |
# Autoconf macros for xdvik. |
| 2 |
# Copyright (C) 2001 - 2009 Marcin Dalecki <[email protected]> |
| 3 |
# Copyright (C) 2009 Peter Breitenlohner <[email protected]> |
| 4 |
# |
| 5 |
# This file is free software; the copyright holders |
| 6 |
# give unlimited permission to copy and/or distribute it, |
| 7 |
# with or without modifications, as long as this notice is preserved. |
| 8 |
|
| 9 |
# XDVI_FIND_XPM |
| 10 |
# ------------- |
| 11 |
# Put Xpm include directory in xpm_includes, |
| 12 |
# put Xpm library directory in xpm_libraries, |
| 13 |
# define x_xpm_libs, |
| 14 |
# and add appropriate flags to X_CFLAGS and X_LIBS. |
| 15 |
AC_DEFUN([XDVI_FIND_XPM], |
| 16 |
[AC_REQUIRE([AC_PATH_XTRA]) |
| 17 |
AC_ARG_WITH([xpm], |
| 18 |
AS_HELP_STRING([--without-xpm], |
| 19 |
[Do not use the Xpm library (will disable the toolbar)]))[]dnl |
| 20 |
AC_ARG_WITH([xpm-includes], |
| 21 |
AS_HELP_STRING([--with-xpm-include=DIR], |
| 22 |
[Specify the location of Xpm include files]), |
| 23 |
[xpm_includes=$withval], [xpm_includes=])[]dnl |
| 24 |
AC_ARG_WITH([xpm-libraries], |
| 25 |
AS_HELP_STRING([--with-xpm-libdir=DIR], |
| 26 |
[Specify the location of Xpm libraries]), |
| 27 |
[xpm_libraries=$withval], [xpm_libraries=])[]dnl |
| 28 |
dnl Treat --without-xpm like |
| 29 |
dnl --without-xpm-includes --without-xpm-libraries. |
| 30 |
if test "x$with_xpm" = xno; then |
| 31 |
xpm_includes=no |
| 32 |
xpm_libraries=no |
| 33 |
fi |
| 34 |
AC_MSG_CHECKING([for Xpm]) |
| 35 |
# |
| 36 |
# Check the headers. |
| 37 |
# |
| 38 |
if test "x$xpm_includes" = x; then |
| 39 |
_XDVI_FIND_XPM_INCLUDES |
| 40 |
fi |
| 41 |
if test "x$xpm_includes" = xdefault; then |
| 42 |
AC_DEFINE([HAVE_X11_XPM_H], 1, [Define if you have the <X11/xpm.h> header file.]) |
| 43 |
elif test -f "$xpm_includes/X11/xpm.h"; then |
| 44 |
AC_DEFINE([HAVE_X11_XPM_H], 1) |
| 45 |
elif test -f "$xpm_includes/xpm.h"; then |
| 46 |
AC_DEFINE([HAVE_XPM_H], 1, |
| 47 |
[Define if you have the <xpm.h> header file (not in X11, e.g. Solaris 5.8).]) |
| 48 |
fi |
| 49 |
# |
| 50 |
# Add Xpm definition to X_CFLAGS (and remember previous value) |
| 51 |
# |
| 52 |
xdvi_xpm_save_X_CFLAGS=$X_CFLAGS |
| 53 |
if test "x$xpm_includes" != xdefault \ |
| 54 |
&& test "x$xpm_includes" != "x$x_includes" && test "x$xpm_includes" != xno |
| 55 |
then |
| 56 |
X_CFLAGS="-I$xpm_includes $X_CFLAGS" |
| 57 |
fi |
| 58 |
# |
| 59 |
# Check the libraries. |
| 60 |
# |
| 61 |
if test "x$xpm_libraries" = x; then |
| 62 |
_XDVI_FIND_XPM_LIBRARIES |
| 63 |
fi |
| 64 |
# |
| 65 |
# Report the results of headers and libraries. |
| 66 |
# |
| 67 |
xdvi_use_xpm=yes |
| 68 |
# |
| 69 |
# |
| 70 |
xpm_libraries_result=$xpm_libraries |
| 71 |
if test "x$xpm_libraries_result" = xdefault; then |
| 72 |
xpm_libraries_result="in default path" |
| 73 |
elif test "x$xpm_libraries_result" = xno; then |
| 74 |
xpm_libraries_result="(none)" |
| 75 |
xdvi_use_xpm=no |
| 76 |
fi |
| 77 |
# |
| 78 |
xpm_includes_result=$xpm_includes |
| 79 |
if test "x$xpm_includes_result" = xdefault; then |
| 80 |
xpm_includes_result="in default path" |
| 81 |
elif test "x$xpm_includes_result" = xno; then |
| 82 |
xpm_includes_result="(none)" |
| 83 |
xdvi_use_xpm=no |
| 84 |
fi |
| 85 |
# |
| 86 |
AC_MSG_RESULT([libraries $xpm_libraries_result, headers $xpm_includes_result]) |
| 87 |
# |
| 88 |
if test "x$xdvi_use_xpm" = xyes; then |
| 89 |
# |
| 90 |
# Add Xpm definition to X_LIBS |
| 91 |
# |
| 92 |
if test "x$xpm_libraries" != xdefault \ |
| 93 |
&& test "x$xpm_libraries" != "x$x_libraries" && test "x$xpm_libraries" != xno |
| 94 |
then |
| 95 |
case "$X_LIBS" in |
| 96 |
*-R\ *) X_LIBS="-L$xpm_libraries -R $xpm_libraries $X_LIBS";; |
| 97 |
*-R*) X_LIBS="-L$xpm_libraries -R$xpm_libraries $X_LIBS";; |
| 98 |
*) X_LIBS="-L$xpm_libraries $X_LIBS";; |
| 99 |
esac |
| 100 |
fi |
| 101 |
# |
| 102 |
AC_DEFINE([USE_XPM], 1, [Define if you want to use the Xpm library]) |
| 103 |
x_xpm_libs="-lXpm" |
| 104 |
else |
| 105 |
# Restore previous X_CFLAGS |
| 106 |
X_CFLAGS=$xdvi_xpm_save_X_CFLAGS |
| 107 |
AC_DEFINE([USE_XPM], 0) |
| 108 |
x_xpm_libs= |
| 109 |
fi |
| 110 |
AC_SUBST([x_xpm_libs]) |
| 111 |
]) # XDVI_FIND_XPM |
| 112 |
|
| 113 |
# _XDVI_FIND_XPM_INCLUDES |
| 114 |
# ----------------------- |
| 115 |
# Search the Xpm include files. |
| 116 |
# They can either be in <X11/xpm.h> (as in X11R6), which is dealt with |
| 117 |
# by AC_CHECK_HEADERS([X11/xpm.h]), |
| 118 |
# or in <xpm.h> if installed locally; this is what this test is for. |
| 119 |
m4_define([_XDVI_FIND_XPM_INCLUDES], |
| 120 |
[AC_CACHE_VAL([xdvi_cv_xpm_includes], |
| 121 |
[xdvi_xpm_save_CFLAGS=$CFLAGS |
| 122 |
xdvi_xpm_save_CPPFLAGS=$CPPFLAGS |
| 123 |
# |
| 124 |
CFLAGS="$X_CFLAGS $CFLAGS" |
| 125 |
CPPFLAGS="$X_CFLAGS $CPPFLAGS" |
| 126 |
# |
| 127 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/xpm.h>]], |
| 128 |
[[int a;]])], |
| 129 |
[# X11/xpm.h is in the standard search path. |
| 130 |
xdvi_cv_xpm_includes=default], |
| 131 |
[# X11/xpm.h is not in the standard search path. |
| 132 |
xdvi_cv_xpm_includes=no |
| 133 |
# Locate it and put its directory in `xpm_includes' |
| 134 |
# |
| 135 |
# /usr/include/Motif* are used on HP-UX (Motif). |
| 136 |
# /usr/include/X11* are used on HP-UX (X and Xaw). |
| 137 |
# /usr/dt is used on Solaris (Motif). |
| 138 |
# /usr/openwin is used on Solaris (X and Xaw). |
| 139 |
# Other directories are just guesses. |
| 140 |
for dir in "$x_includes" "${prefix}/include" /usr/include /usr/local/include \ |
| 141 |
/usr/X11/include /usr/X11R5/include /usr/X11R6/include \ |
| 142 |
/usr/include/Motif2.0 /usr/include/Motif1.2 /usr/include/Motif1.1 \ |
| 143 |
/usr/include/X11R6 /usr/include/X11R5 /usr/include/X11R4 \ |
| 144 |
/usr/dt/include /usr/openwin/include \ |
| 145 |
/usr/dt/*/include /opt/*/include /usr/include/Motif* \ |
| 146 |
"${prefix}"/*/include /usr/*/include /usr/local/*/include \ |
| 147 |
"${prefix}"/include/* /usr/include/* /usr/local/include/* |
| 148 |
do |
| 149 |
if test -f "$dir/X11/xpm.h"; then |
| 150 |
xdvi_cv_xpm_includes=$dir |
| 151 |
break |
| 152 |
elif test -f "$dir/xpm.h"; then |
| 153 |
xdvi_cv_xpm_includes=$dir |
| 154 |
break |
| 155 |
fi |
| 156 |
done]) |
| 157 |
# |
| 158 |
CFLAGS=$xdvi_xpm_save_CFLAGS |
| 159 |
CPPFLAGS=$xdvi_xpm_save_CPPFLAGS]) |
| 160 |
# |
| 161 |
xpm_includes=$xdvi_cv_xpm_includes |
| 162 |
]) # _XDVI_FIND_XPM_INCLUDES |
| 163 |
|
| 164 |
# _XDVI_FIND_XPM_LIBRARIES |
| 165 |
# ------------------------ |
| 166 |
# Search the Xpm library. |
| 167 |
m4_define([_XDVI_FIND_XPM_LIBRARIES], |
| 168 |
[AC_CACHE_VAL([xdvi_cv_xpm_libraries], |
| 169 |
[xdvi_xpm_save_LIBS=$LIBS |
| 170 |
xdvi_xpm_save_CFLAGS=$CFLAGS |
| 171 |
xdvi_xpm_save_CPPFLAGS=$CPPFLAGS |
| 172 |
xdvi_xpm_save_LDFLAGS=$LDFLAGS |
| 173 |
# |
| 174 |
LIBS="$X_PRE_LIBS -lXpm -lXt -lX11 $X_EXTRA_LIBS $LIBS" |
| 175 |
CFLAGS="$X_CFLAGS $CFLAGS" |
| 176 |
CPPFLAGS="$X_CFLAGS $CPPFLAGS" |
| 177 |
LDFLAGS="$X_LIBS $LDFLAGS" |
| 178 |
# |
| 179 |
# We use XtToolkitInitialize() here since it takes no arguments |
| 180 |
# and thus also works with a C++ compiler. |
| 181 |
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Intrinsic.h> |
| 182 |
#include <X11/xpm.h>]], |
| 183 |
[[XtToolkitInitialize();]])], |
| 184 |
[# libxpm.a is in the standard search path. |
| 185 |
xdvi_cv_xpm_libraries=default], |
| 186 |
[# libXpm.a is not in the standard search path. |
| 187 |
xdvi_cv_xpm_libraries=no |
| 188 |
# Locate it and put its directory in `xpm_libraries' |
| 189 |
# |
| 190 |
# /usr/lib/Motif* are used on HP-UX (Motif). |
| 191 |
# /usr/lib/X11* are used on HP-UX (X and Xpm). |
| 192 |
# /usr/dt is used on Solaris (Motif). |
| 193 |
# /usr/openwin is used on Solaris (X and Xpm). |
| 194 |
# Other directories are just guesses. |
| 195 |
for dir in "$x_libraries" "${prefix}/lib" /usr/lib /usr/local/lib \ |
| 196 |
/usr/lib/Motif2.0 /usr/lib/Motif1.2 /usr/lib/Motif1.1 \ |
| 197 |
/usr/lib/X11R6 /usr/lib/X11R5 /usr/lib/X11R4 /usr/lib/X11 \ |
| 198 |
/usr/dt/lib /usr/openwin/lib \ |
| 199 |
/usr/dt/*/lib /opt/*/lib /usr/lib/Motif* \ |
| 200 |
"${prefix}"/*/lib /usr/*/lib /usr/local/*/lib \ |
| 201 |
"${prefix}"/lib/* /usr/lib/* /usr/local/lib/* |
| 202 |
do |
| 203 |
if test -d "$dir" && test "`ls $dir/libXpm.* 2> /dev/null`" != ""; then |
| 204 |
xdvi_cv_xpm_libraries=$dir |
| 205 |
break |
| 206 |
fi |
| 207 |
done]) |
| 208 |
# |
| 209 |
LIBS=$xdvi_xpm_save_LIBS |
| 210 |
CFLAGS=$xdvi_xpm_save_CFLAGS |
| 211 |
CPPFLAGS=$xdvi_xpm_save_CPPFLAGS |
| 212 |
LDFLAGS=$xdvi_xpm_save_LDFLAGS]) |
| 213 |
# |
| 214 |
xpm_libraries="$xdvi_cv_xpm_libraries"]) # _XDVI_FIND_XPM_LIBRARIES |