home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / lyx-0.13.2.tar.gz / lyx-0.13.2.tar / lyx-0.13.2 / config / aclocal.m4 < prev    next >
Text File  |  1998-04-23  |  13KB  |  477 lines

  1. dnl Some useful functions for LyX's configure.in                 -*- sh -*-
  2. dnl Author: Jean-Marc Lasgouttes (Jean-Marc.Lasgouttes@inria.fr)
  3. dnl
  4. dnl
  5. dnl Usage LYX_GET_VERSION   Sets `lyx_version' to the version of LyX being 
  6. dnl   built, displays it and sets variable `lyx_devel' to yes or no depending 
  7. dnl   whether the version is a development release or not. 
  8. AC_DEFUN(LYX_GET_VERSION,[
  9. changequote(, ) dnl
  10. # Get LyX version from $1 and guess wether is is stable or experimental.
  11. VERSION=`grep '#define *LYX_VERSION' $1 | 
  12.              sed -e 's/^.*"\([0-9.]*\)[^0-9.].*$/\1/' 2>/dev/null`
  13. echo "configuring LyX version $VERSION"
  14. if echo "$VERSION" | grep '[0-9]*\.[0-9]*[13579]\.[0-9]*' >/dev/null ; then
  15.   lyx_devel_version=yes
  16.   echo "WARNING: This is a development version. Expect bugs."
  17. else
  18.   lyx_devel_version=no
  19. fi
  20. changequote([, ]) dnl
  21. PACKAGE=lyx${program_suffix}
  22. AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
  23. AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
  24. AC_SUBST(PACKAGE)
  25. AC_SUBST(VERSION)
  26. AC_SUBST(lyx_devel_version)
  27. test $lyx_devel_version = yes && AC_DEFINE(DEVEL_VERSION)])
  28. dnl
  29. dnl
  30. dnl
  31. dnl Usage: LYX_ERROR(message)  Displays the warning `message' and sets the
  32. dnl flag lyx_error to yes.
  33. AC_DEFUN(LYX_ERROR,[
  34. lyx_error_txt="$lyx_error_txt
  35. ** $1
  36. "
  37. lyx_error=yes])
  38. dnl
  39. dnl
  40. dnl
  41. dnl Usage: LYX_WARNING(message)  Displays the warning `message' and sets the
  42. dnl flag lyx_warning to yes.
  43. AC_DEFUN(LYX_WARNING,[
  44. lyx_warning_txt="$lyx_warning_txt
  45. == $1
  46. "
  47. lyx_warning=yes])
  48. dnl
  49. dnl
  50. dnl
  51. dnl Usage: LYX_LIB_ERROR(file,library)  Displays an error message indication 
  52. dnl  that 'file' cannot be found because 'lib' may be uncorrectly installed.
  53. AC_DEFUN(LYX_LIB_ERROR,[
  54. LYX_ERROR([Can't find $1. Please check that the $2 library
  55.    is correctly installed on your system.])])
  56. dnl
  57. dnl
  58. dnl Usage: LYX_CHECK_ERRORS  Displays a warning message if a LYX_ERROR
  59. dnl   has occured previously. 
  60. AC_DEFUN(LYX_CHECK_ERRORS,[
  61. if test x$lyx_error = xyes; then
  62. cat <<EOF
  63. **** The following problems have been detected by configure. 
  64. **** Please check the messages below before running 'make'.
  65. **** (see the section 'Problems' in the INSTALL file)
  66. $lyx_error_txt
  67. $lyx_warning_txt
  68. deleting cache $cache_file
  69. EOF
  70.   rm -f $cache_file
  71. else
  72.  
  73. if test x$lyx_warning = xyes; then
  74. cat <<EOF
  75. === The following minor problems have been detected by configure. 
  76. === Please check the messages below before running 'make'.
  77. === (see the section 'Problems' in the INSTALL file)
  78. $lyx_warning_txt
  79. EOF
  80. fi
  81. cat <<EOF
  82. Configuration of LyX was successful.  
  83. Type 'make' to compile the program, 
  84. and then 'make install' to install it.
  85. EOF
  86. fi])
  87. dnl
  88. dnl
  89. dnl LYX_SEARCH_PROG(VARIABLE-NAME,PROGRAMS-LIST,ACTION-IF-FOUND)
  90. dnl             
  91. define(LYX_SEARCH_PROG,[dnl
  92. for ac_prog in $2 ; do
  93. # Extract the first word of "$ac_prog", so it can be a program name with args.
  94.   set dummy $ac_prog ; ac_word=$[2]
  95.   if test ! -n "[$]$1"; then
  96.     IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  97.     for ac_dir in $PATH; do
  98.       test -z "$ac_dir" && ac_dir=.
  99.       if test -f [$ac_dir/$ac_word]; then
  100.         $1="$ac_prog"
  101.         break
  102.       fi
  103.     done
  104.     IFS="$ac_save_ifs"
  105.   fi
  106.  
  107.   if test -n "[$]$1"; then
  108.     ac_result=yes
  109.   else
  110.     ac_result=no
  111.   fi
  112.   ifelse($3,,,[$3])
  113.   test -n "[$]$1" && break
  114. done
  115. ])dnl
  116. dnl
  117. dnl
  118. dnl
  119. AC_DEFUN(LYX_PROG_CXX_WORKS,
  120. [AC_LANG_SAVE
  121. AC_LANG_CPLUSPLUS
  122. AC_TRY_COMPILER([class foo { int bar; }; int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross)
  123. AC_LANG_RESTORE
  124. if test $ac_cv_prog_cxx_works = no; then
  125.   CXX=
  126. fi
  127. cross_compiling=$ac_cv_prog_cxx_cross
  128. ])
  129. dnl
  130. dnl
  131. dnl
  132. AC_DEFUN(LYX_PROG_CXX,
  133. [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
  134. AC_MSG_CHECKING([for a working C++ compiler])
  135. LYX_SEARCH_PROG(CXX, $CCC g++ gcc c++ CC cxx xlC cc++, LYX_PROG_CXX_WORKS)
  136.  
  137. if test -z "$CXX" ; then
  138.   AC_ERROR([Unable to find a working C++ compiler])
  139. fi
  140.  
  141. AC_SUBST(CXX)
  142. AC_MSG_RESULT($CXX)
  143.  
  144. AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler])
  145. AC_MSG_RESULT($cross_compiling)
  146.  
  147. AC_PROG_CXX_GNU
  148.  
  149. dnl We might want to get or shut warnings.
  150. AC_ARG_WITH(warnings,
  151.   [  --with-warnings         tell GNU C++ to display more warnings],,
  152.   [if test $lyx_devel_version = yes && test $ac_cv_prog_gxx = yes ; then
  153.      with_warnings=yes;
  154.    else
  155.      with_warnings=no;
  156.    fi;])
  157. if test "x$with_warnings" = xyes ; then
  158.   lyx_flags="$lyx_flags warnings"
  159.   AC_DEFINE(WITH_WARNINGS)
  160. fi
  161.  
  162. # optimize less for development versions
  163. if test "$lyx_devel_version" = yes ; then
  164.   lyx_opt="-O"
  165. else
  166.   lyx_opt="-O2"
  167. fi
  168.  
  169. # set the debug flags correctly.
  170. if test $ac_cv_prog_gxx = yes; then
  171.   GXX=yes
  172. dnl Check whether -g works, even if CXXFLAGS is set, in case the package
  173. dnl plays around with CXXFLAGS (such as to build both debugging and
  174. dnl normal versions of a library), tasteless as that idea is.
  175.   ac_test_CXXFLAGS="${CXXFLAGS+set}"
  176.   ac_save_CXXFLAGS="$CXXFLAGS"
  177.   CXXFLAGS=
  178.   AC_PROG_CXX_G
  179.   if test "$ac_test_CXXFLAGS" = set; then
  180.     CXXFLAGS="$ac_save_CXXFLAGS"
  181.   elif test $ac_cv_prog_cxx_g = yes; then
  182.     CXXFLAGS="-g $lyx_opt"
  183.   else
  184.     CXXFLAGS="$lyx_opt"
  185.   fi
  186.   if test $with_warnings = yes ; then
  187.     CXXFLAGS="$CXXFLAGS -ansi -Wall"
  188.     # a small hack to avoid problems with headers
  189.     echo '#undef __STRICT_ANSI__' >>confdefs.h
  190.   fi
  191. else
  192.   GXX=
  193.   test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
  194. fi
  195. ])dnl
  196. dnl
  197. dnl
  198. dnl
  199. AC_DEFUN(LYX_GXX_STRENGTH_REDUCE,[
  200. #check for the strength reduction bug of gcc
  201. if test x$GXX = xyes && test $cross_compiling = no ; then
  202.   AC_CACHE_CHECK( "for gcc strength-reduce bug", ac_cv_c_gcc_strength_bug,
  203.                   AC_TRY_RUN([
  204. int main(void) {
  205.   static int Array[[3]];
  206.   unsigned int B = 3;
  207.   int i;
  208.   for(i=0; i<B; i++) Array[[i]] = i - 3;
  209.   exit( Array[[1]] != -2 );
  210. }],
  211.     ac_cv_c_gcc_strength_bug="no",
  212.     ac_cv_c_gcc_strength_bug="yes",
  213.     ac_cv_c_gcc_strength_bug="yes") )
  214.   if test "$ac_cv_c_gcc_strength_bug" = "yes"
  215.   then
  216.     CXXFLAGS="$CXXFLAGS -fno-strength-reduce"
  217.   fi
  218. fi
  219. ])dnl
  220. dnl
  221. dnl
  222. dnl
  223. dnl Usage: LYX_CXX_EXPLICIT : checks whether the C++ compiler
  224. dnl   understands the `explicit' directive.
  225. AC_DEFUN(LYX_CXX_EXPLICIT,[
  226. ### Check whether the compiler understands the keyword `explicit'
  227. AC_CACHE_CHECK(whether the C++ compiler understands explicit,lyx_cv_explicit,
  228.  [AC_TRY_COMPILE([
  229. class Expl {
  230. public:
  231.     explicit Expl() {};
  232. };],,lyx_cv_explicit=yes,lyx_cv_explicit=no)
  233. ])
  234. if test $lyx_cv_explicit = no ; then
  235.   AC_DEFINE(explicit,[ ])
  236. fi])
  237. dnl
  238. dnl
  239. dnl
  240. dnl Usage LYX_PATH_XPM: Checks for xpm library and header
  241. AC_DEFUN(LYX_PATH_XPM,[
  242. ### Check for Xpm library
  243. AC_CHECK_LIB(Xpm, XpmCreateBufferFromImage,LYX_LIBS="-lXpm $LYX_LIBS",
  244.         [LYX_LIB_ERROR(libXpm,Xpm)], $LYX_LIBS)
  245.  
  246. ### Check for Xpm headers
  247. lyx_cv_xpm_h_location="<xpm.h>"
  248. AC_CHECK_HEADER(X11/xpm.h,[
  249.   ac_cv_header_xpm_h=yes
  250.   lyx_cv_xpm_h_location="<X11/xpm.h>"],[
  251. AC_CHECK_HEADER(xpm.h,[],[
  252. LYX_LIB_ERROR(xpm.h,Xpm)])])
  253. AC_DEFINE_UNQUOTED(XPM_H_LOCATION,$lyx_cv_xpm_h_location)
  254.  
  255. ### Test for the header version
  256. if test $ac_cv_header_xpm_h = yes; then
  257.   AC_CACHE_CHECK([xpm header version],lyx_cv_xpmversion,
  258.   [ cat > conftest.$ac_ext <<EOF
  259. #line __oline__ "configure"
  260. #include "confdefs.h"
  261.  
  262. #include XPM_H_LOCATION
  263. %%%lyx_cv_xpmv=XpmVersion;lyx_cv_xpmr=XpmRevision%%%
  264. EOF
  265.     eval `(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
  266.       grep "^%%%"  2>/dev/null | \
  267.       sed -e 's/^%%%\(.*\)%%%$/\1/' -e 's/ //g'`
  268.     case "$lyx_cv_xpmr" in
  269. dnl for emacs font lock ((
  270. changequote(,)
  271.      [0-9]) lyxxpmr_alpha=`echo $lyx_cv_xpmr |tr 123456789 abcdefghi`
  272.             lyxxpmv_alpha=" (aka 3.$lyx_cv_xpmv$lyxxpmr_alpha)";;
  273. changequote([,])
  274.          *) ;;
  275.     esac
  276.     lyx_cv_xpmversion="$lyx_cv_xpmv.$lyx_cv_xpmr$lyxxpmv_alpha"
  277.     rm -f conftest*])
  278.   case "$lyx_cv_xpmr" in 
  279. dnl for emacs font lock ((
  280. changequote(,)
  281.         [789]|[0-9][0-9]*) ;;
  282. changequote([,])
  283.         *) LYX_WARNING([Version $lyx_cv_xpmversion of the Xpm library is a bit old. 
  284.    If you experience strange crashes with LyX, try to upgrade 
  285.    to at least version 4.7 (aka 3.4g).
  286.    If you have installed a newer version of the library, check whether you
  287.    have an old xpm.h header file in your include path.]);;
  288.   esac
  289. fi])
  290. dnl
  291. dnl
  292. dnl
  293. dnl Usage LYX_PATH_XFORMS: Checks for xforms library and flags
  294. AC_DEFUN(LYX_PATH_XFORMS,[
  295. ### Check for xforms library
  296. AC_CHECK_LIB(forms, fl_initialize, LYX_LIBS="-lforms $LYX_LIBS", 
  297.   [AC_CHECK_LIB(xforms, fl_initialize, LYX_LIBS="-lxforms $LYX_LIBS", 
  298.     [LYX_LIB_ERROR(libforms or libxforms,xforms)], $LYX_LIBS)], $LYX_LIBS) 
  299.  
  300. ### Check for xforms headers
  301. lyx_cv_forms_h_location="<forms.h>"
  302. AC_CHECK_HEADER(X11/forms.h,[
  303.   ac_cv_header_forms_h=yes
  304.   lyx_cv_forms_h_location="<X11/forms.h>"],[
  305. AC_CHECK_HEADER(forms.h,[],[
  306. LYX_LIB_ERROR(forms.h,forms)])])
  307. AC_DEFINE_UNQUOTED(FORMS_H_LOCATION,$lyx_cv_forms_h_location)
  308. if test $ac_cv_header_forms_h = yes; then
  309.   AC_CACHE_CHECK([xforms header version],lyx_cv_xfversion,
  310.   [ cat > conftest.$ac_ext <<EOF
  311. #line __oline__ "configure"
  312. #include "confdefs.h"
  313.  
  314. #include FORMS_H_LOCATION
  315. #if ! defined(FL_INCLUDE_VERSION)
  316. %%%(unknown)%%%
  317. #else
  318. %%%FL_VERSION.FL_REVISION%%%
  319. #endif
  320. EOF
  321. lyx_cv_xfversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
  322.   grep "^%%%"  2>/dev/null | \
  323.   sed -e 's/^%%%\(.*\)%%%$/\1/' -e 's/ //g'`
  324. rm -f conftest*])
  325. case "$lyx_cv_xfversion" in 
  326. dnl for emacs font lock (((
  327.   "(unknown)"|0.82|0.83|0.84|0.85) 
  328.      LYX_ERROR(dnl
  329. Version $lyx_cv_xfversion of xforms is not compatible with LyX. 
  330.    This version of LyX works best with version 0.88[,] although it
  331.    supports also versions 0.81[,] 0.86 and 0.87.) ;;
  332.   0.81|0.86|0.87) 
  333.      LYX_WARNING(dnl
  334. While LyX is compatible with version $lyx_cv_xfversion of xforms[,] 
  335.    it is recommended that you upgrade to version 0.88.) ;;
  336.      0.88) ;;
  337.           *) LYX_WARNING(dnl
  338. Version $lyx_cv_xfversion of xforms might not be compatible with LyX[,] 
  339.    since it is newer than 0.88. You might have slight problems with it.);;
  340. esac
  341. fi])
  342. dnl
  343. dnl
  344. dnl Usage: LYX_HPUX  Checks for HP-UX and update CXXFLAGS accordingly
  345. AC_DEFUN(LYX_HPUX,
  346. [#It seems that HPUX requires using -fpcc-struct-return with gcc.
  347. AC_CACHE_CHECK(for HP-UX,ac_cv_hpux,[
  348. os=`uname -s | tr '[A-Z]' '[a-z]'`
  349. ac_cv_hpux=no
  350. test "$os" = hp-ux && ac_cv_hpux=yes])
  351. if test "$ac_cv_hpux" = yes; then
  352.  test "x$GXX" = xyes && CXXFLAGS="$CXXFLAGS -fpcc-struct-return"
  353. fi])
  354. dnl
  355. dnl
  356. dnl
  357. dnl Usage: LYX_SUNOS4 Checks for SunOS 4.x and sets the flag lyx_broken_headers
  358. dnl   if necessary
  359. AC_DEFUN(LYX_SUNOS4,
  360. [#The headers are not correct under SunOS4
  361. AC_CACHE_CHECK(for SunOS 4.x,ac_cv_sunos4,[
  362. changequote(, ) dnl
  363. os=`uname -a | sed -e 's/^\([^ ]*\) [^ ]* \([0-9]\)\..*/\1\2/'`
  364. changequote([, ]) dnl
  365. ac_cv_sunos4=no
  366. test "$os" = SunOS4 && ac_cv_sunos4=yes])
  367. if test "$ac_cv_sunos4" = yes; then
  368.  test "x$GXX" = xyes && lyx_broken_headers=yes
  369. fi])
  370. dnl
  371. dnl
  372. dnl
  373. dnl Usage: LYX_SCO Checks for SCO and sets the flag lyx_broken_headers
  374. dnl   if necessary
  375. AC_DEFUN(LYX_SCO,
  376. [AC_CACHE_CHECK(for SCO 3.2v4,ac_cv_sco,[
  377. ac_cv_sco=no
  378. if test `uname -s` != "SCO_SV"; then
  379.   lyx_machine_rel=`uname -m`:`uname -r`
  380.   if test $lyx_machine_rel = i386:3.2 || test $lyx_machine_rel = i486:3.2;
  381.   then
  382.     if test -f /usr/options/cb.name; then
  383.       ac_cv_sco=no
  384.     elif /bin/uname -X 2>/dev/null >/dev/null ; then
  385.       ac_cv_sco=yes
  386.     fi
  387.   fi
  388. fi])
  389. if test "$ac_cv_sco" = yes; then
  390.  test "x$GXX" = xyes && lyx_broken_headers=yes
  391. fi])
  392. dnl
  393. dnl
  394. dnl Usage: LYX_WITH_DIR(dir-name,desc,dir-var-name,default-value, 
  395. dnl                       [default-yes-value])  
  396. dnl  Adds a --with-'dir-name' option (described by 'desc') and puts the 
  397. dnl  resulting directory name in 'dir-var-name'.
  398. AC_DEFUN(LYX_WITH_DIR,[
  399.   AC_ARG_WITH($1,[  --with-$1        specify $2])
  400.   AC_MSG_CHECKING([for $2])
  401.   if test -z "$with_$3"; then
  402.      AC_CACHE_VAL(lyx_cv_$3, lyx_cv_$3=$4)
  403.   else
  404.     test "x$with_$3" = xyes && with_$3=$5
  405.     lyx_cv_$3="$with_$3"
  406.   fi
  407.   AC_MSG_RESULT($lyx_cv_$3)])
  408. dnl
  409. dnl
  410. dnl Usage: LYX_LOOP_DIR(value,action)
  411. dnl Executes action for values of variable `dir' in `values'. `values' can 
  412. dnl use `:' as a separator.
  413. AC_DEFUN(LYX_LOOP_DIR,[
  414. IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
  415. for dir in `eval "echo $1"`; do
  416.   if test ! "$dir" = NONE; then
  417.     test ! -d "$dir" && AC_ERROR([\`$dir' is not a directory])
  418.     $2
  419.   fi
  420. done
  421. IFS=$ac_save_ifs
  422. ])
  423. dnl
  424. dnl
  425. dnl
  426. dnl Usage: LYX_ADD_LIB_DIR(var-name,dir) Adds a -L directive to variable 
  427. dnl var-name. 
  428. AC_DEFUN(LYX_ADD_LIB_DIR,[
  429. $1="${$1} -L$2"
  430. if test "`(uname) 2>/dev/null`" = SunOS &&
  431.     uname -r | grep '^5' >/dev/null; then
  432.   if test $ac_cv_prog_gxx = yes ; then 
  433.     $1="${$1} -Wl[,]-R$2" 
  434.   else
  435.     $1="${$1} -R$2"
  436.   fi
  437. fi])
  438. dnl
  439. dnl
  440. dnl
  441. dnl Usage: LYX_ADD_INC_DIR(var-name,dir) Adds a -I directive to variable 
  442. dnl var-name. 
  443. AC_DEFUN(LYX_ADD_INC_DIR,[$1="${$1} -I$2 "])
  444. dnl
  445. dnl
  446. dnl Usage LYX_PROG_PERL_OK
  447. AC_DEFUN(LYX_PROG_PERL_OK,[
  448. if echo 'require 5.002;exit' | $ac_dir/$ac_prog 2>&5
  449. then
  450.   PERL=$ac_dir/$ac_prog
  451. else
  452.   PERL=
  453. fi])
  454. dnl
  455. dnl
  456. dnl Usage LYX_CHECK_RELYX
  457. AC_DEFUN(LYX_CHECK_RELYX,[
  458. AC_MSG_CHECKING([for perl >= 5.002])
  459. LYX_SEARCH_PROG(PERL, perl perl5 perl5.002 perl5.003 perl5.004, LYX_PROG_PERL_OK)
  460. if test -n "$PERL" ; then
  461.   RELYXDIR=reLyX
  462.   install_reLyX=install-reLyX
  463.   output_reLyX=lib/reLyX/reLyX
  464.   AC_MSG_RESULT($PERL)
  465. else
  466.   RELYXDIR=
  467.   install_reLyX=
  468.   output_reLyX=
  469.   AC_MSG_RESULT(no)
  470.   LYX_WARNING(dnl
  471. Configure has not been able to find a version 5.002 or better of Perl.
  472.    The installation of reLyX has been disabled)
  473. fi
  474. AC_SUBST(PERL)
  475. AC_SUBST(RELYXDIR)
  476. AC_SUBST(install_reLyX)])
  477.