]> git.lyx.org Git - lyx.git/blob - config/xforms.m4
constify
[lyx.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_CHECK_HEADER(flimage.h,[],[
26 LYX_LIB_ERROR(flimage.h,forms)])])
27 AC_DEFINE_UNQUOTED(FORMS_IMAGE_H_LOCATION,$lyx_cv_flimage_h_location)
28  
29 AC_DEFINE_UNQUOTED(FORMS_H_LOCATION,$lyx_cv_forms_h_location)
30  
31 if test $ac_cv_header_forms_h = yes; then
32   AC_CACHE_CHECK([xforms header version],lyx_cv_xfversion,
33   [ cat > conftest.$ac_ext <<EOF
34 #line __oline__ "configure"
35 #include "confdefs.h"
36
37 #include FORMS_H_LOCATION
38 #if ! defined(FL_INCLUDE_VERSION)
39 "%%%"(unknown)"%%%"
40 #else
41 "%%%"FL_VERSION.FL_REVISION.FL_FIXLEVEL"%%%"
42 #endif
43 EOF
44 lyx_cv_xfversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
45   grep '^"%%%"'  2>/dev/null | \
46   sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
47 rm -f conftest*])
48  
49 XFORMS_VERSION=$lyx_cv_xfversion
50 case "$lyx_cv_xfversion" in
51   "(unknown)"|0.8[1-7]*)
52          LYX_ERROR(dnl
53 Version $lyx_cv_xfversion of xforms is not compatible with LyX.
54    This version of LyX works best with versions 0.88 (recommended) and later.) ;;
55     0.88*) ;;
56     0.89[01234]) LYX_WARNING(dnl
57 LyX should work ok with version $lyx_cv_xfversion of xforms[,] but
58 it is an unproven version and might still have some bugs. You should
59 probably use version 0.89.6 (or 0.88) instead) ;;
60     0.89*) ;;
61     1.0*) ;;
62        *) LYX_WARNING(dnl
63 Version $lyx_cv_xfversion of xforms might not be compatible with LyX[,]
64  since it is newer than 0.89. You might have slight problems with it.);;
65 esac
66 fi])
67
68
69 dnl Check whether the xforms library has a viable image loader
70 AC_DEFUN(LYX_USE_XFORMS_IMAGE_LOADER,
71 [
72 save_LIBS=$LIBS
73 LIBS="-lflimage $XFORMS_LIB -ljpeg $LIBS"
74 lyx_use_xforms_image_loader=no
75 AC_CHECK_FUNCS(flimage_dup,[
76   AC_CHECK_FUNCS(flimage_to_pixmap,[
77     lyx_use_xforms_image_loader=yes
78     AC_CHECK_FUNCS(flimage_enable_ps)])])
79 LIBS=$save_LIBS
80 test $lyx_use_xforms_image_loader = yes && lyx_flags="$lyx_flags xforms-image-loader" && XFORMS_IMAGE_LIB=-lflimage
81 AC_SUBST(XFORMS_IMAGE_LIB)
82 ### If the gui cannot load images itself, then we default to the
83 ### very simple one in graphics/GraphicsImageXPM.[Ch]
84 AM_CONDITIONAL(USE_BASIC_IMAGE_LOADER,
85                test $lyx_use_xforms_image_loader = no)
86 ])
87
88
89 dnl Check if the image loader needs libjpeg
90 AC_DEFUN(LYX_XFORMS_IMAGE_LOADER_NEEDS_JPEG,
91 [
92     if test "$lyx_use_xforms_image_loader" = "yes" ; then
93         AC_MSG_CHECKING([whether libjpeg is needed])
94         AC_LANG_SAVE
95         AC_LANG_C
96         AC_TRY_LINK([#include FORMS_H_LOCATION
97 #include FORMS_IMAGE_H_LOCATION],
98             [jpeg_abort(0);],
99             [lyx_need_jpeg=no],[lyx_need_jpeg=yes])
100         AC_LANG_RESTORE
101         AC_MSG_RESULT($lyx_need_jpeg)
102         if test "$lyx_need_jpeg" = "yes" ; then
103             LIBS="-ljpeg $LIBS"
104         fi
105     fi
106 ])