Debian Codegraph @

texk/xdvik/m4/xdvi-check-xaw.m4

raw
1 # Autoconf macros for xdvik.
2 # Copyright (C) 2003 - 2009 Stefan Ulrich <[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_CHECK_XAW_HEADERS
10 # ----------------------
11 # Check for Xaw headers and library version.
12 AC_DEFUN([XDVI_CHECK_XAW_HEADERS],
13 [save_CPPFLAGS=$CPPFLAGS
14 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
15 AC_CACHE_CHECK([for Xaw headers],
16 [xdvi_cv_xaw_headers],
17 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
18 #include <X11/X.h>
19 #include <X11/Xlib.h>
20 #include <X11/Xutil.h>
21 #include <X11/Xos.h>
22 #include <X11/Xfuncs.h>
23 #include <X11/Intrinsic.h>
24 #include <X11/Xaw/Form.h>]])],
25 [xdvi_cv_xaw_headers=yes],
26 [xdvi_cv_xaw_headers=no])])
27 xdvi_have_xaw=$xdvi_cv_xaw_headers
28 #
29 if test "x$xdvi_have_xaw" = xyes; then
30 _XDVI_CHECK_XAW_VERSION
31 fi
32 CPPFLAGS=$save_CPPFLAGS
33 ]) # XDVI_CHECK_XAW_HEADERS
34
35 # _XDVI_CHECK_XAW_VERSION
36 # -----------------------
37 # Check Xaw version.
38 m4_define([_XDVI_CHECK_XAW_VERSION],
39 [AC_CHECK_MEMBER([SimpleClassPart.extension],
40 [],
41 [AC_DEFINE([HAVE_OLD_XAW], 1,
42 [Define if you have an old version of the Xaw library])],
43 [[
44 #include <X11/IntrinsicP.h>
45 #include <X11/StringDefs.h>
46 #include <X11/Intrinsic.h>
47 #include <X11/StringDefs.h>
48 #include <X11/Xos.h>
49 #include <X11/Xaw/SimpleP.h>]])
50 ]) # _XDVI_CHECK_XAW_VERSION
51
52 # XDVI_CHECK_XAW_LIBRARY
53 # ----------------------
54 # Check for Xaw library.
55 # If found, set prog_extension and x_tool_libs, and define XAW.
56 AC_DEFUN([XDVI_CHECK_XAW_LIBRARY],
57 [AC_REQUIRE([XDVI_CHECK_XAW_HEADERS])
58 if test "x$xdvi_have_xaw" = xyes; then
59 # First try without libXp
60 AC_CHECK_LIB([Xaw], [XawInitializeWidgetSet],
61 [x_tool_libs="-lXaw"],
62 [# libXaw without libXp failed
63 if test "x$x_xp_lib" = x; then
64 xdvi_have_xaw=no
65 else
66 # Now try with libXp
67 AC_CHECK_LIB([Xaw], [XawTextReplace],
68 [x_tool_libs="-lXaw $x_xp_lib"],
69 [xdvi_have_xaw=no],
70 [$x_xp_lib $x_xmu_lib -lXt $X_PRE_LIBS $x_ext_lib $x_xpm_libs -lX11 $X_EXTRA_LIBS $XLFLAG])
71 fi],
72 [$x_xmu_lib -lXt $X_PRE_LIBS $x_ext_lib $x_xpm_libs -lX11 $X_EXTRA_LIBS $XLFLAG])
73 fi
74 if test "x$xdvi_have_xaw" = xyes; then
75 prog_extension="xaw"
76 AC_DEFINE([XAW], 1, [Define to use the Xaw toolkit.])
77
78 # We need the type of the "list" parameter to XawListChange
79 # (the second parameter), for use in gui/pagesel.c. See more comments there.
80 #
81 AC_MSG_CHECKING([for type of XawListChange list parameter])
82 # Although we could try to use the compiler to discern the location of
83 # <X11/Xaw/List.h>, that seems likely to have its own problems. Let's
84 # try just assuming the standard location.
85 #
86 listh=/usr/include/X11/Xaw/List.h
87
88 # Clearly this simple search is subject to plenty of problems in
89 # theory, but in practice, if no one gratuitously changes the
90 # formatting in Xaw/List.h, it should be ok? The line intended to be
91 # matched looks like
92 # String *list, [except with tabs]
93 # or
94 # _Xconst char *list,
95 # or who knows what else. Hopefully it will be the complete type.
96 #
97 list_type=`sed -n 's/list,$//p' $listh`
98 #
99 # The type ordinarily has lots of whitespace, as in the String line above.
100 # People will uselessly complain about that, so reduce it to a single space:
101 tab=' ' # that's a tab character
102 # The outer square brackets are the Autoconf quote pair;
103 # the inner square brackets are the normal regexp character class.
104 #echo "got '$list_type' from $listh, tab=$tab." >/tmp/lh
105 list_type=`echo "$list_type" | sed ["s/[ $tab][ $tab]*/ /g"]`
106 #echo "new '$list_type' from $listh" >>/tmp/lh
107 #
108 if test -z "$list_type"; then
109 # But if we didn't find anything, default to the type of our
110 # page_labels member in pagesel.c, which has been the traditional
111 # effective behavior.
112 list_type="char **"
113 fi
114 AC_MSG_RESULT([$list_type])
115 #debug: echo "got '$list_type' from $listh" >/tmp/lh
116 #
117 # autoconf internally quotes the shell variable value with
118 # ac_define_unquoted; we don't use shell "quotes" here since the final
119 # value must not have any quotes, being a type that we want to use in
120 # a cast, not a string constant.
121 AC_DEFINE_UNQUOTED([XAWLISTCHANGELISTTYPE], $list_type,
122 [type of XawListChange list parameter])
123 else
124 AC_MSG_ERROR([Sorry, you will need at least the Xaw header/library files to compile xdvik.])
125 fi
126 ]) # XDVI_CHECK_XAW_LIBRARY