Debian Codegraph @

texk/xdvik/m4/xdvi-find-motif.m4

raw
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_MOTIF
10 # ---------------
11 # Check for Motif libraries and headers.
12 # Put Motif include directory in motif_include,
13 # put Motif library directory in motif_libdir,
14 # and add appropriate flags to X_CFLAGS and X_LIBS.
15 # If default_toolkit is not `none', use Xaw as toolkit if Motif isn't found.
16 AC_DEFUN([XDVI_FIND_MOTIF],
17 [AC_REQUIRE([AC_PATH_XTRA])
18 AC_ARG_WITH([motif-include],
19 AS_HELP_STRING([--with-motif-include=DIR],
20 [Specify the location of Motif include files]),
21 [motif_include=$withval], [motif_include=])[]dnl
22 AC_ARG_WITH([motif-libdir],
23 AS_HELP_STRING([--with-motif-libdir=DIR],
24 [Specify the location of Motif libraries]),
25 [motif_libdir=$withval], [motif_libdir=])[]dnl
26 AC_MSG_CHECKING([for Motif])
27 #
28 # Search the include files.
29 #
30 if test "x$motif_include" = x; then
31 _XDVI_FIND_MOTIF_INCLUDES
32 fi
33 #
34 # Add Motif definition to X_CFLAGS (and remember previous value)
35 #
36 xdvi_motif_save_X_CFLAGS=$X_CFLAGS
37 if test "x$motif_include" != xdefault \
38 && test "x$motif_include" != "x$x_includes" && test "x$motif_include" != xno
39 then
40 X_CFLAGS="-I$motif_include $X_CFLAGS"
41 fi
42 #
43 # Now for the libraries.
44 #
45 if test "x$motif_libdir" = x; then
46 _XDVI_FIND_MOTIF_LIBRARIES
47 fi
48 #
49 # Report the results of headers and libraries.
50 #
51 xdvi_have_motif=yes
52 #
53 motif_libdir_result=$motif_libdir
54 if test "x$motif_libdir_result" = xdefault; then
55 motif_libdir_result="in default path"
56 elif test "x$motif_libdir_result" = xno; then
57 motif_libdir_result="(none)"
58 xdvi_have_motif=no
59 fi
60 #
61 motif_include_result=$motif_include
62 if test "x$motif_include_result" = xdefault; then
63 motif_include_result="in default path"
64 elif test "x$motif_include_result" = xno; then
65 motif_include_result="(none)"
66 xdvi_have_motif=no
67 fi
68 #
69 AC_MSG_RESULT([libraries $motif_libdir_result, headers $motif_include_result])
70 #
71 if test "x$xdvi_have_motif" = xyes; then
72 #
73 # Add Motif definition to X_LIBS
74 #
75 if test "x$motif_libdir" != xdefault \
76 && test "x$motif_libdir" != "x$x_libraries" && test "x$motif_libdir" != no
77 then
78 case "$X_LIBS" in
79 *-R\ *) X_LIBS="-L$motif_libdir -R $motif_libdir $X_LIBS";;
80 *-R*) X_LIBS="-L$motif_libdir -R$motif_libdir $X_LIBS";;
81 *) X_LIBS="-L$motif_libdir $X_LIBS";;
82 esac
83 fi
84 #
85 prog_extension="motif"
86 AC_DEFINE([MOTIF], 1, [Define to use the Motif toolkit.])
87 x_tool_libs="-lXm"
88 if test "x$x_xp_lib" != x; then
89 # check if libXm requires libXp
90 _XDVI_CHECK_MOTIF_XP
91 fi
92 # now warn if we're using LessTif (see LESSTIF-BUGS for why ...)
93 _XDVI_CHECK_LESSTIF
94 # Check whether to compile for Motif with Xaw Panner.
95 _XDVI_CHECK_PANNER
96 elif test "x$default_toolkit" = xnone; then
97 AC_MSG_ERROR([No Motif.])
98 else
99 # Restore previous X_CFLAGS
100 X_CFLAGS=$xdvi_motif_save_X_CFLAGS
101 AC_MSG_NOTICE([No Motif, using Xaw.])
102 with_xdvi_x_toolkit="xaw"
103 fi
104
105 ]) # XDVI_FIND_MOTIF
106
107 # _XDVI_FIND_MOTIF_INCLUDES
108 # -------------------------
109 # Search the Xm include files.
110 m4_define([_XDVI_FIND_MOTIF_INCLUDES],
111 [AC_CACHE_VAL([xdvi_cv_motif_include],
112 [xdvi_motif_save_CFLAGS=$CFLAGS
113 xdvi_motif_save_CPPFLAGS=$CPPFLAGS
114 #
115 CFLAGS="$X_CFLAGS $CFLAGS"
116 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
117 #
118 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <Xm/Xm.h>]],
119 [[int a;]])],
120 [# Xm/Xm.h is in the standard search path.
121 xdvi_cv_motif_include=default],
122 [# Xm/Xm.h is not in the standard search path.
123 xdvi_cv_motif_include=no
124 # Locate it and put its directory in `motif_include'
125 #
126 # /usr/include/Motif* are used on HP-UX (Motif).
127 # /usr/include/X11* are used on HP-UX (X and Athena).
128 # /usr/dt is used on Solaris (Motif).
129 # /usr/openwin is used on Solaris (X and Athena).
130 # Other directories are just guesses.
131 for dir in "$x_includes" "${prefix}/include" /usr/include /usr/local/include \
132 /usr/include/Motif2.0 /usr/include/Motif1.2 /usr/include/Motif1.1 \
133 /usr/include/X11R6 /usr/include/X11R5 /usr/include/X11R4 \
134 /usr/dt/include /usr/openwin/include \
135 /usr/dt/*/include /opt/*/include /usr/include/Motif* \
136 "${prefix}"/*/include /usr/*/include /usr/local/*/include \
137 "${prefix}"/include/* /usr/include/* /usr/local/include/*; do
138 if test -f "$dir/Xm/Xm.h"; then
139 xdvi_cv_motif_include=$dir
140 break
141 fi
142 done])
143 #
144 CFLAGS=$xdvi_motif_save_CFLAGS
145 CPPFLAGS=$xdvi_motif_save_CPPFLAGS])
146 motif_include=$xdvi_cv_motif_include
147 ]) # _XDVI_FIND_MOTIF_INCLUDES
148
149 # _XDVI_FIND_MOTIF_LIBRARIES
150 # --------------------------
151 # Search the Xm library.
152 m4_define([_XDVI_FIND_MOTIF_LIBRARIES],
153 [AC_CACHE_VAL([xdvi_cv_motif_libdir],
154 [xdvi_motif_save_LIBS=$LIBS
155 xdvi_motif_save_CFLAGS=$CFLAGS
156 xdvi_motif_save_CPPFLAGS=$CPPFLAGS
157 xdvi_motif_save_LDFLAGS=$LDFLAGS
158 #
159 LIBS="$X_PRE_LIBS -lXm $x_xp_lib -lXt -lX11 $X_EXTRA_LIBS $LIBS"
160 CFLAGS="$X_CFLAGS $CFLAGS"
161 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
162 LDFLAGS="$X_LIBS $LDFLAGS"
163 #
164 # We use XtToolkitInitialize() here since it takes no arguments
165 # and thus also works with a C++ compiler.
166 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Intrinsic.h>
167 #include <Xm/Xm.h>]],
168 [[XtToolkitInitialize();]])],
169 [# libXm.a is in the standard search path.
170 xdvi_cv_motif_libdir=default],
171 [# libXm.a is not in the standard search path.
172 xdvi_cv_motif_libdir=no
173 # Locate it and put its directory in `motif_libdir'
174 #
175 # /usr/lib/Motif* are used on HP-UX (Motif).
176 # /usr/lib/X11* are used on HP-UX (X and Athena).
177 # /usr/dt is used on Solaris (Motif).
178 # /usr/lesstif is used on Linux (Lesstif).
179 # /usr/openwin is used on Solaris (X and Athena).
180 # Other directories are just guesses.
181 for dir in "$x_libraries" "${prefix}/lib" /usr/lib /usr/local/lib \
182 /usr/lib/Motif2.0 /usr/lib/Motif1.2 /usr/lib/Motif1.1 \
183 /usr/lib/X11R6 /usr/lib/X11R5 /usr/lib/X11R4 /usr/lib/X11 \
184 /usr/dt/lib /usr/openwin/lib \
185 /usr/dt/*/lib /opt/*/lib /usr/lib/Motif* \
186 /usr/lesstif*/lib /usr/lib/Lesstif* \
187 "${prefix}"/*/lib /usr/*/lib /usr/local/*/lib \
188 "${prefix}"/lib/* /usr/lib/* /usr/local/lib/*; do
189 if test -d "$dir" && test "`ls $dir/libXm.* 2> /dev/null`" != ""; then
190 xdvi_cv_motif_libdir=$dir
191 break
192 fi
193 done])
194 #
195 LIBS=$xdvi_motif_save_LIBS
196 CFLAGS=$xdvi_motif_save_CFLAGS
197 CPPFLAGS=$xdvi_motif_save_CPPFLAGS
198 LDFLAGS=$xdvi_motif_save_LDFLAGS])
199 #
200 motif_libdir="$xdvi_cv_motif_libdir"
201 ]) # _XDVI_FIND_MOTIF_LIBRARIES
202
203 # _XDVI_CHECK_MOTIF_XP
204 # --------------------
205 # Check if libXm (explicitly) requires libXp
206 m4_define([_XDVI_CHECK_MOTIF_XP],
207 [AC_CACHE_CHECK([if libXm requires libXp],
208 [xdvi_cv_motif_xp],
209 [xdvi_motif_save_LIBS=$LIBS
210 xdvi_motif_save_CFLAGS=$CFLAGS
211 xdvi_motif_save_CPPFLAGS=$CPPFLAGS
212 xdvi_motif_save_LDFLAGS=$LDFLAGS
213 #
214 LIBS="$X_PRE_LIBS -lXm -lXt -lX11 $X_EXTRA_LIBS $LIBS"
215 CFLAGS="$X_CFLAGS $CFLAGS"
216 CPPFLAGS="$X_CFLAGS $CPPFLAGS"
217 LDFLAGS="$X_LIBS $LDFLAGS"
218 #
219 # We use XtToolkitInitialize() here since it takes no arguments
220 # and thus also works with a C++ compiler.
221 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Intrinsic.h>
222 #include <Xm/Xm.h>]],
223 [[XtToolkitInitialize();]])],
224 [xdvi_cv_motif_xp=no],
225 [xdvi_cv_motif_xp=yes])
226 #
227 LIBS=$xdvi_motif_save_LIBS
228 CFLAGS=$xdvi_motif_save_CFLAGS
229 CPPFLAGS=$xdvi_motif_save_CPPFLAGS
230 LDFLAGS=$xdvi_motif_save_LDFLAGS])
231 if test "x$xdvi_cv_motif_xp" = xyes; then
232 x_tool_libs="$x_tool_libs $x_xp_lib"
233 fi
234 ]) # _XDVI_CHECK_MOTIF_XP
235
236 # _XDVI_CHECK_LESSTIF
237 # -------------------
238 # Check if using LessTif and warn if so.
239 m4_define([_XDVI_CHECK_LESSTIF],
240 [AC_CACHE_CHECK([for LessTif],
241 [xdvi_cv_using_lesstif],
242 [save_CPPFLAGS=$CPPFLAGS
243 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
244 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/X.h>
245 #include <X11/Xlib.h>
246 #include <X11/Xutil.h>
247 #include <X11/Xos.h>
248 #include <X11/Intrinsic.h>
249 #include <Xm/Xm.h>]],
250 [[const char *p = LesstifVERSION_STRING;]])],
251 [xdvi_cv_using_lesstif=yes],
252 [xdvi_cv_using_lesstif=no])
253 CPPFLAGS=$save_CPPFLAGS])
254 if test "x$xdvi_cv_using_lesstif" = xyes; then
255 AC_MSG_WARN([LessTif header detected.
256 *****************************************************************
257 * Warning: You are using LessTif instead of OpenMotif. *
258 * Some GUI elements might be broken; please see the file *
259 * *
260 * texk/xdvik/LESSTIF-BUGS *
261 * *
262 * for more information. *
263 *****************************************************************])
264 fi
265 ]) # _XDVI_CHECK_LESSTIF
266
267 # _XDVI_CHECK_PANNER
268 # ------------------
269 # Check whether to compile for Motif with Xaw Panner.
270 m4_define([_XDVI_CHECK_PANNER],
271 [AC_CACHE_CHECK([whether to compile in panner (requires Xaw)],
272 [xdvi_cv_use_xaw_panner],
273 [save_CPPFLAGS=$CPPFLAGS
274 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
275 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/X.h>
276 #include <X11/Xlib.h>
277 #include <X11/Xutil.h>
278 #include <X11/Xos.h>
279 #include <X11/Xfuncs.h>
280 #include <X11/Intrinsic.h>
281 #include <X11/Xaw/Reports.h>]])],
282 [xdvi_cv_use_xaw_panner=yes],
283 [xdvi_cv_use_xaw_panner=no])
284 CPPFLAGS=$save_CPPFLAGS])
285 if test "x$xdvi_cv_use_xaw_panner" = xyes; then
286 AC_DEFINE([USE_XAW_PANNER], 1, [Define to use Xaw panner.])
287 fi
288 ]) # _XDVI_CHECK_PANNER