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)])
9 ### Check for Xpm headers
10 lyx_cv_xpm_h_location="<xpm.h>"
11 AC_CHECK_HEADER(X11/xpm.h,[
12 ac_cv_header_xpm_h=yes
13 lyx_cv_xpm_h_location="<X11/xpm.h>"],[
14 AC_CHECK_HEADER(xpm.h,[],[
15 LYX_LIB_ERROR(xpm.h,Xpm)])])
16 #AC_DEFINE_UNQUOTED(XPM_H_LOCATION,$lyx_cv_xpm_h_location,
17 # [define this to the location of xpm.h to be used with #include, e.g. <xpm.h>])
18 AC_SUBST(XPM_H_LOCATION,$lyx_cv_xpm_h_location)
19 ### Test for the header version
20 if test $ac_cv_header_xpm_h = yes; then
21 AC_CACHE_CHECK([xpm header version],lyx_cv_xpmversion,
22 [ cat > conftest.$ac_ext <<EOF
23 #line __oline__ "configure"
26 #include $lyx_cv_xpm_h_location
27 "%%%"lyx_cv_xpmv=XpmVersion;lyx_cv_xpmr=XpmRevision"%%%"
29 eval `(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
30 grep '^"%%%"' 2>/dev/null | \
31 sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
32 case "$lyx_cv_xpmr" in
34 [0-9]) lyxxpmr_alpha=`echo $lyx_cv_xpmr |tr 123456789 abcdefghi`
35 lyxxpmv_alpha=" (aka 3.$lyx_cv_xpmv$lyxxpmr_alpha)";;
39 lyx_cv_xpmversion="$lyx_cv_xpmv.$lyx_cv_xpmr$lyxxpmv_alpha"
41 XPM_VERSION=${lyx_cv_xpmversion}
42 case "$lyx_cv_xpmr" in
46 *) LYX_WARNING([Version $lyx_cv_xpmversion of the Xpm library is a bit old.
47 If you experience strange crashes with LyX, try to upgrade
48 to at least version 4.7 (aka 3.4g).
49 If you have installed a newer version of the library, check whether you
50 have an old xpm.h header file in your include path.]);;
55 dnl Usage LYX_PATH_XFORMS: Checks for xforms library and flags
56 dnl If it is found, the variable XFORMS_LIB is set to the relevant -l flags,
57 dnl and FORMS_H_LOCATION / FLIMAGE_H_LOCATION is also set
58 AC_DEFUN(LYX_PATH_XFORMS,[
59 AC_REQUIRE([LYX_PATH_XPM])
61 AC_CHECK_LIB(forms, fl_initialize, XFORMS_LIB="-lforms",
62 [AC_CHECK_LIB(xforms, fl_initialize, XFORMS_LIB="-lxforms",
63 [LYX_LIB_ERROR(libforms or libxforms,xforms)], $XPM_LIB)], $XPM_LIB)
66 ### Check for xforms headers
67 lyx_cv_forms_h_location="<forms.h>"
68 AC_CHECK_HEADER(X11/forms.h,[
69 ac_cv_header_forms_h=yes
70 lyx_cv_forms_h_location="<X11/forms.h>"],[
71 AC_CHECK_HEADER(forms.h,[],[
72 LYX_LIB_ERROR(forms.h,forms)])])
73 AC_SUBST(FORMS_H_LOCATION,$lyx_cv_forms_h_location)
75 if test $ac_cv_header_forms_h = yes; then
76 AC_CACHE_CHECK([xforms header version],lyx_cv_xfversion,
77 [ cat > conftest.$ac_ext <<EOF
78 #line __oline__ "configure"
81 #include $lyx_cv_forms_h_location
82 #if ! defined(FL_INCLUDE_VERSION)
85 "%%%"FL_VERSION.FL_REVISION.FL_FIXLEVEL"%%%"
88 lyx_cv_xfversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
89 grep '^"%%%"' 2>/dev/null | \
90 sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
93 XFORMS_VERSION=$lyx_cv_xfversion
94 case "$lyx_cv_xfversion" in
95 "(unknown)"|0.8[[1-8]]*|0.89[[01234]])
97 Version $lyx_cv_xfversion of xforms is not compatible with LyX.
98 This version of LyX works best with version 1.0 (recommended) and later.) ;;
101 LyX should work ok with version $lyx_cv_xfversion of xforms[,] but
102 it contains many bugs that have been squashed in version 1.0.
103 You should consider upgrading.) ;;
110 dnl Check the details of the xforms image loader
111 AC_DEFUN(LYX_CHECK_XFORMS_IMAGE_LOADER,
112 [AC_REQUIRE([LYX_PATH_XFORMS])
114 LIBS="$XFORMS_LIB $XPM_LIB $LIBS"
115 lyx_use_jpeg_image_loader=no
120 dnl The image headers were split out of forms.h in xforms version 1.0.
121 AC_CHECK_HEADERS(flimage.h X11/flimage.h, break,,[#include $lyx_cv_forms_h_location])
123 dnl Only enable native loading of jpeg images if the jpeg library is installed.
124 dnl This test comes before that of flimage itself to ensure that the necessary
125 dnl libraries are linked into the "flimage_dup" test program below.
127 AC_CHECK_LIB(jpeg, jpeg_read_header,
128 [lyx_use_jpeg_image_loader=yes
129 XFORMS_IMAGE_LIB="-ljpeg"
130 LIBS="-ljpeg $LIBS"])
132 AC_SEARCH_LIBS(flimage_dup, flimage,
133 [if test "$ac_cv_search_flimage_dup" != "none required" ; then
134 XFORMS_IMAGE_LIB="-lflimage $XFORMS_IMAGE_LIB"
137 AC_SUBST(XFORMS_IMAGE_LIB)
139 if test $lyx_use_jpeg_image_loader = yes ; then
140 lyx_flags="$lyx_flags xforms-image-loader"
141 AC_DEFINE(USE_JPEG_IMAGE_LOADER, 1,
142 [Define if you want to be able to load jpeg images natively])