1 dnl some macros to test for xforms-related functionality -*- sh -*-
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"
23 #include $lyx_cv_xpm_h_location
24 "%%%"lyx_cv_xpmv=XpmVersion;lyx_cv_xpmr=XpmRevision"%%%"
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
31 [0-9]) lyxxpmr_alpha=`echo $lyx_cv_xpmr |tr 123456789 abcdefghi`
32 lyxxpmv_alpha=" (aka 3.$lyx_cv_xpmv$lyxxpmr_alpha)";;
36 lyx_cv_xpmversion="$lyx_cv_xpmv.$lyx_cv_xpmr$lyxxpmv_alpha"
38 XPM_VERSION=${lyx_cv_xpmversion}
39 case "$lyx_cv_xpmr" in
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.]);;
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])
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)
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)
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"
77 #include $lyx_cv_forms_h_location
78 #if ! defined(FL_INCLUDE_VERSION)
81 "%%%"FL_VERSION.FL_REVISION.FL_FIXLEVEL"%%%"
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'`
89 XFORMS_VERSION=$lyx_cv_xfversion
90 case "$lyx_cv_xfversion" in
91 "(unknown)"|0.8[[1-8]]*|0.89[[01234]])
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.) ;;
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.) ;;
106 dnl Check the details of the xforms image loader
107 AC_DEFUN([LYX_CHECK_XFORMS_IMAGE_LOADER],
108 [AC_REQUIRE([LYX_PATH_XFORMS])
110 LIBS="$XFORMS_LIB $XPM_LIB $LIBS"
111 lyx_use_jpeg_image_loader=no
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])
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.
123 AC_CHECK_LIB(jpeg, jpeg_read_header,
124 [lyx_use_jpeg_image_loader=yes
125 XFORMS_IMAGE_LIB="-ljpeg"
126 LIBS="-ljpeg $LIBS"])
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"
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])
142 dnl Do all check required to use xforms
143 AC_DEFUN([XFORMS_DO_IT_ALL],
146 LYX_CHECK_XFORMS_IMAGE_LOADER
147 AC_SUBST(XFORMS_LIBS, ["$XFORMS_IMAGE_LIB $XFORMS_LIB $XPM_LIB"])])