added textile-mode and mmm-mode. xpath stuff
[emacs-init.git] / mmm-mode-0.4.8 / acinclude.m4
1 dnl
2 dnl Execute arbitrary emacs lisp
3 dnl
4 AC_DEFUN(AC_EMACS_LISP, [
5 elisp="$2"
6 if test -z "$3"; then
7         AC_MSG_CHECKING(for $1)
8 fi
9 AC_CACHE_VAL(EMACS_cv_SYS_$1,[
10         OUTPUT=./conftest-$$
11         echo ${EMACS} -batch -eval "(let ((x ${elisp})) (write-region (if (stringp x) (princ x) (prin1-to-string x)) nil \"${OUTPUT}\"))" >& AC_FD_CC 2>&1  
12         ${EMACS} -batch -eval "(let ((x ${elisp})) (write-region (if (stringp x) (princ x 'ignore) (prin1-to-string x)) nil \"${OUTPUT}\"nil 5))" >& AC_FD_CC 2>&1
13         retval=`cat ${OUTPUT}`
14         echo "=> ${retval}" >& AC_FD_CC 2>&1
15         rm -f ${OUTPUT}
16         EMACS_cv_SYS_$1=$retval
17 ])
18 $1=${EMACS_cv_SYS_$1}
19 if test -z "$3"; then
20         AC_MSG_RESULT($$1)
21 fi
22 ])
23
24 AC_DEFUN(AC_XEMACS_P, [
25   AC_MSG_CHECKING([if $EMACS is really XEmacs])
26   AC_EMACS_LISP(xemacsp,(if (string-match \"XEmacs\" emacs-version) \"yes\" \"no\") ,"noecho")
27   XEMACS=${EMACS_cv_SYS_xemacsp}
28   EMACS_FLAVOR=emacs
29   if test "$XEMACS" = "yes"; then
30      EMACS_FLAVOR=xemacs
31   fi
32   AC_MSG_RESULT($XEMACS)
33   AC_SUBST(XEMACS)
34   AC_SUBST(EMACS_FLAVOR)
35 ])
36
37 AC_DEFUN(AC_PATH_LISPDIR, [
38   AC_XEMACS_P
39   if test "$prefix" = "NONE"; then
40         AC_MSG_CHECKING([prefix for your Emacs])
41         AC_EMACS_LISP(prefix,(expand-file-name \"..\" invocation-directory),"noecho")
42         prefix=${EMACS_cv_SYS_prefix}
43         AC_MSG_RESULT($prefix)
44   fi
45   AC_ARG_WITH(lispdir,          --with-lispdir            Where to install lisp files, lispdir=${withval})
46   AC_MSG_CHECKING([where .elc files should go])
47   if test -z "$lispdir"; then
48     dnl Set default value
49     theprefix=$prefix
50     if test "x$theprefix" = "xNONE"; then
51         theprefix=$ac_default_prefix
52     fi
53     lispdir="\$(datadir)/${EMACS_FLAVOR}/site-lisp"
54     for thedir in share lib; do
55         potential=
56         if test -d ${theprefix}/${thedir}/${EMACS_FLAVOR}/site-lisp; then
57            lispdir="\$(prefix)/${thedir}/${EMACS_FLAVOR}/site-lisp"
58            break
59         fi
60     done
61   fi
62   AC_MSG_RESULT($lispdir)
63   AC_SUBST(lispdir)
64 ])
65
66 dnl
67 dnl Determine the emacs version we are running.
68 dnl Automatically substitutes @EMACS_VERSION@ with this number.
69 dnl
70 AC_DEFUN(AC_EMACS_VERSION, [
71 AC_MSG_CHECKING(for emacs version)
72 AC_EMACS_LISP(version,(and (boundp 'emacs-major-version) (format \"%d.%d\" emacs-major-version emacs-minor-version)),"noecho")
73
74 EMACS_VERSION=${EMACS_cv_SYS_version}
75 AC_SUBST(EMACS_VERSION)
76 AC_MSG_RESULT(${EMACS_VERSION})
77 ])
78
79 dnl
80 dnl Determine whether the specified version of Emacs supports packages
81 dnl or not.  Currently, only XEmacs 20.3 does, but this is a general
82 dnl check.
83 dnl
84 AC_DEFUN(AC_EMACS_PACKAGES, [
85 AC_ARG_WITH(package-dir,      --with-package-dir        Configure as a XEmacs package in directory, [ EMACS_PACKAGE_DIR="${withval}"])
86 if test -n "$EMACS_PACKAGE_DIR"; then
87   if test "$prefix" != "NONE"; then
88         AC_MSG_ERROR([--with-package-dir and --prefix are mutually exclusive])
89   fi
90   dnl Massage everything to use $(prefix) correctly.
91   prefix=$EMACS_PACKAGE_DIR
92   datadir='$(prefix)/etc/w3'
93   infodir='$(prefix)/info'
94   lispdir='$(prefix)/lisp/w3'
95 fi
96 AC_SUBST(EMACS_PACKAGE_DIR)
97 ])
98
99 dnl
100 dnl Check whether a function exists in a library
101 dnl All '_' characters in the first argument are converted to '-'
102 dnl
103 AC_DEFUN(AC_EMACS_CHECK_LIB, [
104 if test -z "$3"; then
105         AC_MSG_CHECKING(for $2 in $1)
106 fi
107 library=`echo $1 | tr _ -`
108 AC_EMACS_LISP($1,(progn (fmakunbound '$2) (condition-case nil (progn (require '$library) (fboundp '$2)) (error (prog1 nil (message \"$library not found\"))))),"noecho")
109 if test "${EMACS_cv_SYS_$1}" = "nil"; then
110         EMACS_cv_SYS_$1=no
111 fi
112 if test "${EMACS_cv_SYS_$1}" = "t"; then
113         EMACS_cv_SYS_$1=yes
114 fi
115 HAVE_$1=${EMACS_cv_SYS_$1}
116 AC_SUBST(HAVE_$1)
117 if test -z "$3"; then
118         AC_MSG_RESULT($HAVE_$1)
119 fi
120 ])
121
122 dnl
123 dnl Check whether a variable exists in a library
124 dnl All '_' characters in the first argument are converted to '-'
125 dnl
126 AC_DEFUN(AC_EMACS_CHECK_VAR, [
127 AC_MSG_CHECKING(for $2 in $1)
128 library=`echo $1 | tr _ -`
129 AC_EMACS_LISP($1,(progn (makunbound '$2) (condition-case nil (progn (require '$library) (boundp '$2)) (error nil))),"noecho")
130 if test "${EMACS_cv_SYS_$1}" = "nil"; then
131         EMACS_cv_SYS_$1=no
132 fi
133 HAVE_$1=${EMACS_cv_SYS_$1}
134 AC_SUBST(HAVE_$1)
135 AC_MSG_RESULT($HAVE_$1)
136 ])
137
138 dnl
139 dnl Perform sanity checking and try to locate the custom and widget packages
140 dnl
141 AC_DEFUN(AC_CHECK_CUSTOM, [
142 AC_MSG_CHECKING(for acceptable custom library)
143 AC_CACHE_VAL(EMACS_cv_ACCEPTABLE_CUSTOM,[
144 AC_EMACS_CHECK_LIB(widget,widget-convert-text,"noecho")
145 AC_EMACS_CHECK_LIB(wid_edit,widget-convert-text,"noecho")
146 if test "${HAVE_widget}" = "yes"; then
147         EMACS_cv_ACCEPTABLE_CUSTOM=yes
148 else
149         if test "${HAVE_wid_edit}" != "no"; then
150                 EMACS_cv_ACCEPTABLE_CUSTOM=yes
151         else
152                 EMACS_cv_ACCEPTABLE_CUSTOM=no
153         fi
154 fi
155 if test "${EMACS_cv_ACCEPTABLE_CUSTOM}" = "yes"; then
156         AC_EMACS_LISP(widget_dir,(file-name-directory (locate-library \"widget\")),"noecho")
157         EMACS_cv_ACCEPTABLE_CUSTOM=$EMACS_cv_SYS_widget_dir
158 fi
159 ])
160    AC_ARG_WITH(custom,           --with-custom             Specify where to find the custom package, [ EMACS_cv_ACCEPTABLE_CUSTOM=`( cd $withval && pwd || echo "$withval" ) 2> /dev/null` ])
161    CUSTOM=${EMACS_cv_ACCEPTABLE_CUSTOM}
162    AC_SUBST(CUSTOM)
163    AC_MSG_RESULT("${CUSTOM}")
164 ])
165