]> git.lyx.org Git - lyx.git/blob - config/xforms.m4
prepare for further work and a parlist thingie
[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 AC_SUBST(XPM_LIB)
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
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"
24 #include "confdefs.h"
25
26 #include XPM_H_LOCATION
27 "%%%"lyx_cv_xpmv=XpmVersion;lyx_cv_xpmr=XpmRevision"%%%"
28 EOF
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
33 changequote(,)
34      [0-9]) lyxxpmr_alpha=`echo $lyx_cv_xpmr |tr 123456789 abcdefghi`
35             lyxxpmv_alpha=" (aka 3.$lyx_cv_xpmv$lyxxpmr_alpha)";;
36 changequote([,])
37          *) ;;
38     esac
39     lyx_cv_xpmversion="$lyx_cv_xpmv.$lyx_cv_xpmr$lyxxpmv_alpha"
40     rm -f conftest*])
41   XPM_VERSION=${lyx_cv_xpmversion}
42   case "$lyx_cv_xpmr" in
43 changequote(,)
44         [789]|[0-9][0-9]*) ;;
45 changequote([,])
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.]);;
51   esac
52 fi])
53
54
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])
60
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)
64 AC_SUBST(XFORMS_LIB)
65
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_DEFINE_UNQUOTED(FORMS_H_LOCATION,$lyx_cv_forms_h_location,
74    [define this to the location of forms.h to be used with #include, e.g. <forms.h>])
75
76 if test $ac_cv_header_forms_h = yes; then
77   AC_CACHE_CHECK([xforms header version],lyx_cv_xfversion,
78   [ cat > conftest.$ac_ext <<EOF
79 #line __oline__ "configure"
80 #include "confdefs.h"
81
82 #include FORMS_H_LOCATION
83 #if ! defined(FL_INCLUDE_VERSION)
84 "%%%"(unknown)"%%%"
85 #else
86 "%%%"FL_VERSION.FL_REVISION.FL_FIXLEVEL"%%%"
87 #endif
88 EOF
89 lyx_cv_xfversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
90   grep '^"%%%"'  2>/dev/null | \
91   sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
92 rm -f conftest*])
93
94 XFORMS_VERSION=$lyx_cv_xfversion
95 case "$lyx_cv_xfversion" in
96 "(unknown)"|0.8[[1-8]]*|0.89[[01234]])
97         LYX_ERROR(dnl
98 Version $lyx_cv_xfversion of xforms is not compatible with LyX.
99    This version of LyX works best with version 1.0 (recommended) and later.) ;;
100 0.89*|0.9999*)
101         LYX_WARNING(dnl
102 LyX should work ok with version $lyx_cv_xfversion of xforms[,] but
103    it contains many bugs that have been squashed in version 1.0.
104    You should consider upgrading.) ;;
105 1.0*) ;;
106 esac
107 fi
108 ])
109
110
111 dnl Check the details of the xforms image loader
112 AC_DEFUN(LYX_CHECK_XFORMS_IMAGE_LOADER,
113 [AC_REQUIRE([LYX_PATH_XFORMS])
114 save_LIBS=$LIBS
115 LIBS="$XFORMS_LIB $XPM_LIB $LIBS"
116 lyx_use_jpeg_image_loader=no
117
118 AC_LANG_SAVE
119 AC_LANG_C
120
121 dnl The image headers were split out of forms.h in xforms version 1.0.
122 AC_CHECK_HEADERS(flimage.h X11/flimage.h, break,,[#include $lyx_cv_forms_h_location])
123 AC_SEARCH_LIBS(flimage_dup, flimage,
124   [if test "$ac_cv_search_flimage_dup" != "none required" ; then
125      XFORMS_IMAGE_LIB="-lflimage"
126      LIBS="$XFORMS_IMAGE_LIB $LIBS"
127   fi])
128
129 dnl Only enable native loading of jpeg images if the jpeg library is installed.
130 AC_CHECK_LIB(jpeg, jpeg_read_header,
131   [lyx_use_jpeg_image_loader=yes
132    XFORMS_IMAGE_LIB="$XFORMS_IMAGE_LIB -ljpeg"
133    LIBS="$LIBS -ljpeg"])
134 AC_SUBST(XFORMS_IMAGE_LIB)
135
136 if test $lyx_use_jpeg_image_loader = yes ; then
137   lyx_flags="$lyx_flags xforms-image-loader"
138   AC_DEFINE(USE_JPEG_IMAGE_LOADER, 1,
139             [Define if you want to be able to load jpeg images natively])
140 fi
141
142 AC_LANG_RESTORE
143 LIBS=$save_LIBS])