]> git.lyx.org Git - features.git/blob - config/xforms.m4
f80267c9e12039d2e5d13aa2b1b3507370e30c35
[features.git] / config / xforms.m4
1 dnl Usage LYX_PATH_XFORMS: Checks for xforms library and flags
2 dnl   If it is found, the variable XFORMS_LIB is set to the relevant -l flags,
3 dnl and FORMS_H_LOCATION / FORMS_IMAGE_H_LOCATION is also set
4 AC_DEFUN(LYX_PATH_XFORMS,[
5  
6 LIBS="$XPM_LIB $LIBS"
7  
8 AC_CHECK_LIB(forms, fl_initialize, XFORMS_LIB="-lforms",
9   [AC_CHECK_LIB(xforms, fl_initialize, XFORMS_LIB="-lxforms",
10     [LYX_LIB_ERROR(libforms or libxforms,xforms)])])
11 AC_SUBST(XFORMS_LIB)
12  
13 ### Check for xforms headers
14 lyx_cv_forms_h_location="<forms.h>"
15 AC_CHECK_HEADER(X11/forms.h,[
16   ac_cv_header_forms_h=yes
17   lyx_cv_forms_h_location="<X11/forms.h>"],[
18 AC_CHECK_HEADER(forms.h,[],[
19 LYX_LIB_ERROR(forms.h,forms)])])
20  
21 lyx_cv_flimage_h_location="<flimage.h>"
22 AC_CHECK_HEADER(X11/flimage.h,[
23   ac_cv_header_flimage_h=yes
24   lyx_cv_flimage_h_location="<X11/flimage.h>"],)
25 AC_DEFINE_UNQUOTED(FORMS_IMAGE_H_LOCATION,$lyx_cv_flimage_h_location)
26  
27 AC_DEFINE_UNQUOTED(FORMS_H_LOCATION,$lyx_cv_forms_h_location)
28  
29 if test $ac_cv_header_forms_h = yes; then
30   AC_CACHE_CHECK([xforms header version],lyx_cv_xfversion,
31   [ cat > conftest.$ac_ext <<EOF
32 #line __oline__ "configure"
33 #include "confdefs.h"
34
35 #include FORMS_H_LOCATION
36 #if ! defined(FL_INCLUDE_VERSION)
37 "%%%"(unknown)"%%%"
38 #else
39 "%%%"FL_VERSION.FL_REVISION.FL_FIXLEVEL"%%%"
40 #endif
41 EOF
42 lyx_cv_xfversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
43   grep '^"%%%"'  2>/dev/null | \
44   sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
45 rm -f conftest*])
46  
47 XFORMS_VERSION=$lyx_cv_xfversion
48 case "$lyx_cv_xfversion" in
49   "(unknown)"|0.8[1-7]*)
50          LYX_ERROR(dnl
51 Version $lyx_cv_xfversion of xforms is not compatible with LyX.
52    This version of LyX works best with versions 0.88 (recommended) and later.) ;;
53     0.88*) ;;
54     0.89[01234]) LYX_WARNING(dnl
55 LyX should work ok with version $lyx_cv_xfversion of xforms[,] but
56 it is an unproven version and might still have some bugs. You should
57 probably use version 0.89.6 (or 0.88) instead) ;;
58     0.89*) ;;
59     1.0*) ;;
60        *) LYX_WARNING(dnl
61 Version $lyx_cv_xfversion of xforms might not be compatible with LyX[,]
62  since it is newer than 0.89. You might have slight problems with it.);;
63 esac
64 fi])
65
66
67 dnl Check whether the xforms library has a viable image loader
68 AC_DEFUN(LYX_USE_XFORMS_IMAGE_LOADER,
69 [
70 save_LIBS=$LIBS
71 LIBS="-lflimage $XFORMS_LIB -ljpeg $LIBS"
72 lyx_use_xforms_image_loader=no
73 AC_CHECK_FUNCS(flimage_dup,[
74   AC_CHECK_FUNCS(flimage_to_pixmap,[
75     lyx_use_xforms_image_loader=yes
76     AC_CHECK_FUNCS(flimage_enable_ps)])])
77 LIBS=$save_LIBS
78 test $lyx_use_xforms_image_loader = yes && lyx_flags="$lyx_flags xforms-image-loader" && XFORMS_IMAGE_LIB=-lflimage
79  
80 # try without flimage 
81 if test $lyx_use_xforms_image_loader = no ; then
82         LIBS="$XFORMS_LIB -ljpeg $LIBS"
83         lyx_use_xforms_image_loader=no
84         AC_CHECK_FUNCS(flimage_dup,[
85           AC_CHECK_FUNCS(flimage_to_pixmap,[
86             lyx_use_xforms_image_loader=yes
87             AC_CHECK_FUNCS(flimage_enable_ps)])])
88         LIBS=$save_LIBS
89
90         # try without -ljpeg
91         if test $lyx_use_xforms_image_loader = no ; then
92                 LIBS="$XFORMS_LIB $LIBS"
93                 lyx_use_xforms_image_loader=no
94                 AC_CHECK_FUNCS(flimage_dup,[
95                   AC_CHECK_FUNCS(flimage_to_pixmap,[
96                     lyx_use_xforms_image_loader=yes
97                     AC_CHECK_FUNCS(flimage_enable_ps)])])
98                 LIBS=$save_LIBS
99         fi
100  
101 fi
102  
103 AC_SUBST(XFORMS_IMAGE_LIB)
104  
105 ### If the gui cannot load images itself, then we default to the
106 ### very simple one in graphics/GraphicsImageXPM.[Ch]
107 AM_CONDITIONAL(USE_BASIC_IMAGE_LOADER,
108                test $lyx_use_xforms_image_loader = no)
109 ])
110
111
112 dnl Check if the image loader needs libjpeg
113 AC_DEFUN(LYX_XFORMS_IMAGE_LOADER_NEEDS_JPEG,
114 [
115     if test "$lyx_use_xforms_image_loader" = "yes" ; then
116         AC_MSG_CHECKING([whether libjpeg is needed])
117         AC_LANG_SAVE
118         AC_LANG_C
119         AC_TRY_LINK([#include FORMS_H_LOCATION
120 #include FORMS_IMAGE_H_LOCATION],
121             [jpeg_abort(0);],
122             [lyx_need_jpeg=no],[lyx_need_jpeg=yes])
123         AC_LANG_RESTORE
124         AC_MSG_RESULT($lyx_need_jpeg)
125         if test "$lyx_need_jpeg" = "yes" ; then
126             LIBS="-ljpeg $LIBS"
127         fi
128     fi
129 ])