]> git.lyx.org Git - lyx.git/blob - config/xforms.m4
Test for the presence of rpmbuild.
[lyx.git] / config / xforms.m4
1 dnl some macros to test for xforms-related functionality  -*- sh -*-
2
3 dnl Usage LYX_PATH_XFORMS: Checks for xforms library and flags
4 dnl   If it is found, the variable XFORMS_LIB is set to the relevant -l flags,
5 dnl and FORMS_H_LOCATION / FLIMAGE_H_LOCATION is also set
6 AC_DEFUN(LYX_PATH_XFORMS,[
7 AC_REQUIRE([LYX_PATH_XPM])
8
9 AC_CHECK_LIB(forms, fl_initialize, XFORMS_LIB="-lforms",
10   [AC_CHECK_LIB(xforms, fl_initialize, XFORMS_LIB="-lxforms",
11     [LYX_LIB_ERROR(libforms or libxforms,xforms)], $XPM_LIB)], $XPM_LIB)
12 AC_SUBST(XFORMS_LIB)
13
14 ### Check for xforms headers
15 lyx_cv_forms_h_location="<forms.h>"
16 AC_CHECK_HEADER(X11/forms.h,[
17   ac_cv_header_forms_h=yes
18   lyx_cv_forms_h_location="<X11/forms.h>"],[
19 AC_CHECK_HEADER(forms.h,[],[
20 LYX_LIB_ERROR(forms.h,forms)])])
21 AC_DEFINE_UNQUOTED(FORMS_H_LOCATION,$lyx_cv_forms_h_location,
22    [define this to the location of forms.h to be used with #include, e.g. <forms.h>])
23
24 if test $ac_cv_header_forms_h = yes; then
25   AC_CACHE_CHECK([xforms header version],lyx_cv_xfversion,
26   [ cat > conftest.$ac_ext <<EOF
27 #line __oline__ "configure"
28 #include "confdefs.h"
29
30 #include FORMS_H_LOCATION
31 #if ! defined(FL_INCLUDE_VERSION)
32 "%%%"(unknown)"%%%"
33 #else
34 "%%%"FL_VERSION.FL_REVISION.FL_FIXLEVEL"%%%"
35 #endif
36 EOF
37 lyx_cv_xfversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
38   grep '^"%%%"'  2>/dev/null | \
39   sed -e 's/^"%%%"\(.*\)"%%%"/\1/' -e 's/ //g'`
40 rm -f conftest*])
41
42 XFORMS_VERSION=$lyx_cv_xfversion
43 case "$lyx_cv_xfversion" in
44 "(unknown)"|0.8[[1-8]]*|0.89[[01234]])
45         LYX_ERROR(dnl
46 Version $lyx_cv_xfversion of xforms is not compatible with LyX.
47    This version of LyX works best with version 1.0 (recommended) and later.) ;;
48 0.89*|0.9999*)
49         LYX_WARNING(dnl
50 LyX should work ok with version $lyx_cv_xfversion of xforms[,] but
51    it contains many bugs that have been squashed in version 1.0.
52    You should consider upgrading.) ;;
53 1.0*) ;;
54 esac
55 fi
56 ])
57
58
59 dnl Check the details of the xforms image loader
60 AC_DEFUN(LYX_CHECK_XFORMS_IMAGE_LOADER,
61 [AC_REQUIRE([LYX_PATH_XFORMS])
62 save_LIBS=$LIBS
63 LIBS="$XFORMS_LIB $XPM_LIB $LIBS"
64 lyx_use_jpeg_image_loader=no
65
66 AC_LANG_SAVE
67 AC_LANG_C
68
69 dnl The image headers were split out of forms.h in xforms version 1.0.
70 AC_CHECK_HEADERS(flimage.h X11/flimage.h, break,,[#include $lyx_cv_forms_h_location])
71 AC_SEARCH_LIBS(flimage_dup, flimage,
72   [if test "$ac_cv_search_flimage_dup" != "none required" ; then
73      XFORMS_IMAGE_LIB="-lflimage"
74      LIBS="$XFORMS_IMAGE_LIB $LIBS"
75   fi])
76
77 dnl Only enable native loading of jpeg images if the jpeg library is installed.
78 AC_CHECK_LIB(jpeg, jpeg_read_header,
79   [lyx_use_jpeg_image_loader=yes
80    XFORMS_IMAGE_LIB="$XFORMS_IMAGE_LIB -ljpeg"
81    LIBS="$LIBS -ljpeg"])
82 AC_SUBST(XFORMS_IMAGE_LIB)
83
84 if test $lyx_use_jpeg_image_loader = yes ; then
85   lyx_flags="$lyx_flags xforms-image-loader"
86   AC_DEFINE(USE_JPEG_IMAGE_LOADER, 1,
87             [Define if you want to be able to load jpeg images natively])
88 fi
89
90 AC_LANG_RESTORE
91 LIBS=$save_LIBS])