]> git.lyx.org Git - lyx.git/blob - config/xforms.m4
add missing getext marks
[lyx.git] / config / xforms.m4
1 dnl some macros to test for xforms-related functionality  -*- sh -*-
2
3 dnl Usage LYX_PATH_XPM: Checks for xpm library and header
4 AC_DEFUN([LYX_PATH_XPM],[
5 ### Check for Xpm library
6 AC_CHECK_LIB(Xpm, XpmCreateBufferFromImage, XPM_LIB="-lXpm",
7         [LYX_LIB_ERROR(libXpm,Xpm)])
8 ### Check for Xpm headers
9 lyx_cv_xpm_h_location="<xpm.h>"
10 AC_CHECK_HEADER(X11/xpm.h,[
11   ac_cv_header_xpm_h=yes
12   lyx_cv_xpm_h_location="<X11/xpm.h>"],[
13 AC_CHECK_HEADER(xpm.h,[],[
14 LYX_LIB_ERROR(xpm.h,Xpm)])])
15 AC_SUBST(XPM_H_LOCATION,$lyx_cv_xpm_h_location)
16 ### Test for the header version
17 if test $ac_cv_header_xpm_h = yes; then
18   AC_CACHE_CHECK([xpm header version],lyx_cv_xpmversion,
19   [ cat > conftest.$ac_ext <<EOF
20 #line __oline__ "configure"
21 #include "confdefs.h"
22
23 #include $lyx_cv_xpm_h_location
24 "%%%"lyx_cv_xpmv=XpmVersion;lyx_cv_xpmr=XpmRevision"%%%"
25 EOF
26     eval `(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
27       grep '^"%%%"'  2>/dev/null | \
28       sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
29     case "$lyx_cv_xpmr" in
30 changequote(,)
31      [0-9]) lyxxpmr_alpha=`echo $lyx_cv_xpmr |tr 123456789 abcdefghi`
32             lyxxpmv_alpha=" (aka 3.$lyx_cv_xpmv$lyxxpmr_alpha)";;
33 changequote([,])
34          *) ;;
35     esac
36     lyx_cv_xpmversion="$lyx_cv_xpmv.$lyx_cv_xpmr$lyxxpmv_alpha"
37     rm -f conftest*])
38   XPM_VERSION=${lyx_cv_xpmversion}
39   case "$lyx_cv_xpmr" in
40 changequote(,)
41         [789]|[0-9][0-9]*) ;;
42 changequote([,])
43         *) LYX_WARNING([Version $lyx_cv_xpmversion of the Xpm library is a bit old.
44    If you experience strange crashes with LyX, try to upgrade
45    to at least version 4.7 (aka 3.4g).
46    If you have installed a newer version of the library, check whether you
47    have an old xpm.h header file in your include path.]);;
48   esac
49 fi])
50
51
52 dnl Usage LYX_PATH_XFORMS: Checks for xforms library and flags
53 dnl   If it is found, the variable XFORMS_LIB is set to the relevant -l flags,
54 dnl and FORMS_H_LOCATION / FLIMAGE_H_LOCATION is also set
55 AC_DEFUN([LYX_PATH_XFORMS],[
56 AC_REQUIRE([LYX_PATH_XPM])
57
58 AC_CHECK_LIB(forms, fl_initialize, XFORMS_LIB="-lforms",
59   [AC_CHECK_LIB(xforms, fl_initialize, XFORMS_LIB="-lxforms",
60     [LYX_LIB_ERROR(libforms or libxforms,xforms)], $XPM_LIB)], $XPM_LIB)
61
62 ### Check for xforms headers
63 lyx_cv_forms_h_location="<forms.h>"
64 AC_CHECK_HEADER(X11/forms.h,[
65   ac_cv_header_forms_h=yes
66   lyx_cv_forms_h_location="<X11/forms.h>"],[
67 AC_CHECK_HEADER(forms.h,[],[
68 LYX_LIB_ERROR(forms.h,forms)])])
69 AC_SUBST(FORMS_H_LOCATION,$lyx_cv_forms_h_location)
70
71 if test $ac_cv_header_forms_h = yes; then
72   AC_CACHE_CHECK([xforms header version],lyx_cv_xfversion,
73   [ cat > conftest.$ac_ext <<EOF
74 #line __oline__ "configure"
75 #include "confdefs.h"
76
77 #include $lyx_cv_forms_h_location
78 #if ! defined(FL_INCLUDE_VERSION)
79 "%%%"(unknown)"%%%"
80 #else
81 "%%%"FL_VERSION.FL_REVISION.FL_FIXLEVEL"%%%"
82 #endif
83 EOF
84 lyx_cv_xfversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
85   grep '^"%%%"'  2>/dev/null | \
86   sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
87 rm -f conftest*])
88
89 XFORMS_VERSION=$lyx_cv_xfversion
90 case "$lyx_cv_xfversion" in
91 "(unknown)"|0.8[[1-8]]*|0.89[[01234]])
92         LYX_ERROR(dnl
93 Version $lyx_cv_xfversion of xforms is not compatible with LyX.
94    This version of LyX works best with version 1.0 (recommended) and later.) ;;
95 0.89*|0.9999*)
96         LYX_WARNING(dnl
97 LyX should work ok with version $lyx_cv_xfversion of xforms[,] but
98    it contains many bugs that have been squashed in version 1.0.
99    You should consider upgrading.) ;;
100 1.0*) ;;
101 esac
102 fi
103 ])
104
105
106 dnl Check the details of the xforms image loader
107 AC_DEFUN([LYX_CHECK_XFORMS_IMAGE_LOADER],
108 [AC_REQUIRE([LYX_PATH_XFORMS])
109 save_LIBS=$LIBS
110 LIBS="$XFORMS_LIB $XPM_LIB $LIBS"
111 lyx_use_jpeg_image_loader=no
112
113 AC_LANG_SAVE
114 AC_LANG_C
115
116 dnl The image headers were split out of forms.h in xforms version 1.0.
117 AC_CHECK_HEADERS(flimage.h X11/flimage.h, break,,[#include $lyx_cv_forms_h_location])
118
119 dnl Only enable native loading of jpeg images if the jpeg library is installed.
120 dnl This test comes before that of flimage itself to ensure that the necessary
121 dnl libraries are linked into the "flimage_dup" test program below.
122 XFORMS_IMAGE_LIB=""
123 AC_CHECK_LIB(jpeg, jpeg_read_header,
124   [lyx_use_jpeg_image_loader=yes
125    XFORMS_IMAGE_LIB="-ljpeg"
126    LIBS="-ljpeg $LIBS"])
127
128 AC_SEARCH_LIBS(flimage_dup, flimage,
129   [if test "$ac_cv_search_flimage_dup" != "none required" ; then
130      XFORMS_IMAGE_LIB="-lflimage $XFORMS_IMAGE_LIB"
131   fi])
132
133 if test $lyx_use_jpeg_image_loader = yes ; then
134   lyx_flags="$lyx_flags jpeg-image-loader"
135   AC_DEFINE(USE_JPEG_IMAGE_LOADER, 1,
136             [Define if you want to be able to load jpeg images natively])
137 fi
138
139 AC_LANG_RESTORE
140 LIBS=$save_LIBS])
141
142 dnl Do all check required to use xforms
143 AC_DEFUN([XFORMS_DO_IT_ALL],
144 [LYX_PATH_XPM
145 LYX_PATH_XFORMS
146 LYX_CHECK_XFORMS_IMAGE_LOADER
147 AC_SUBST(XFORMS_LIBS, ["$XFORMS_IMAGE_LIB $XFORMS_LIB $XPM_LIB"])])