2 dnl Execute arbitrary emacs lisp
4 AC_DEFUN(AC_EMACS_LISP, [
7 AC_MSG_CHECKING(for $1)
9 AC_CACHE_VAL(EMACS_cv_SYS_$1,[
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
16 EMACS_cv_SYS_$1=$retval
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}
29 if test "$XEMACS" = "yes"; then
32 AC_MSG_RESULT($XEMACS)
34 AC_SUBST(EMACS_FLAVOR)
37 AC_DEFUN(AC_PATH_LISPDIR, [
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)
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
50 if test "x$theprefix" = "xNONE"; then
51 theprefix=$ac_default_prefix
53 lispdir="\$(datadir)/${EMACS_FLAVOR}/site-lisp"
54 for thedir in share lib; do
56 if test -d ${theprefix}/${thedir}/${EMACS_FLAVOR}/site-lisp; then
57 lispdir="\$(prefix)/${thedir}/${EMACS_FLAVOR}/site-lisp"
62 AC_MSG_RESULT($lispdir)
67 dnl Determine the emacs version we are running.
68 dnl Automatically substitutes @EMACS_VERSION@ with this number.
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")
74 EMACS_VERSION=${EMACS_cv_SYS_version}
75 AC_SUBST(EMACS_VERSION)
76 AC_MSG_RESULT(${EMACS_VERSION})
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
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])
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'
96 AC_SUBST(EMACS_PACKAGE_DIR)
100 dnl Check whether a function exists in a library
101 dnl All '_' characters in the first argument are converted to '-'
103 AC_DEFUN(AC_EMACS_CHECK_LIB, [
104 if test -z "$3"; then
105 AC_MSG_CHECKING(for $2 in $1)
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
112 if test "${EMACS_cv_SYS_$1}" = "t"; then
115 HAVE_$1=${EMACS_cv_SYS_$1}
117 if test -z "$3"; then
118 AC_MSG_RESULT($HAVE_$1)
123 dnl Check whether a variable exists in a library
124 dnl All '_' characters in the first argument are converted to '-'
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
133 HAVE_$1=${EMACS_cv_SYS_$1}
135 AC_MSG_RESULT($HAVE_$1)
139 dnl Perform sanity checking and try to locate the custom and widget packages
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
149 if test "${HAVE_wid_edit}" != "no"; then
150 EMACS_cv_ACCEPTABLE_CUSTOM=yes
152 EMACS_cv_ACCEPTABLE_CUSTOM=no
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
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}
163 AC_MSG_RESULT("${CUSTOM}")