1 dnl Copyright (C) 1999 NISHIDA Keisuke <knishida@ring.aist.go.jp>
3 dnl This program is free software; you can redistribute it and/or modify
4 dnl it under the terms of the GNU General Public License as published by
5 dnl the Free Software Foundation; either version 2, or (at your option)
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 dnl GNU General Public License for more details.
13 dnl You should have received a copy of the GNU General Public License
14 dnl along with this program; if not, write to the Free Software
15 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 AC_DEFUN(AM_PATH_LISPDIR,
23 [ --with-emacs=EMACS compile with EMACS [EMACS=emacs, xemacs...]],
26 no) AC_MSG_ERROR([emacs is not available]) ;;
27 *) EMACS=${withval} ;;
29 if test "x$EMACS" = "xt" -o "x$EMACS" = x; then
30 AC_PATH_PROGS(EMACS, emacs xemacs mule, no)
31 if test $EMACS = no; then
32 AC_MSG_ERROR(you should install Emacs first)
36 dnl # Check Emacs directories
38 AC_MSG_CHECKING([where emacs files are in])
39 EMACS_BASENAME="`echo x$EMACS | sed -e 's/x//' -e 's/^.*\///'`"
40 if test "x$emacsdir" = x; then
41 if test "x$prefix" = "xNONE"; then
42 prefix=$ac_default_prefix
44 emacsdir="\$(datadir)/emacs"
45 case "$EMACS_BASENAME" in
47 if test -d $prefix/lib/emacs; then
48 emacsdir="$prefix/lib/emacs"
50 if test -d $prefix/share/emacs; then
51 emacsdir="$prefix/share/emacs"
55 if test -d $prefix/lib/xemacs; then
56 emacsdir="$prefix/lib/xemacs"
58 if test -d $prefix/share/xemacs; then
59 emacsdir="$prefix/share/xemacs"
63 if test -d $prefix/lib/emacs; then
64 emacsdir="$prefix/lib/emacs"
66 if test -d $prefix/share/emacs; then
67 emacsdir="$prefix/share/emacs"
69 if test -d $prefix/lib/mule; then
70 emacsdir="$prefix/lib/mule"
72 if test -d $prefix/share/mule; then
73 emacsdir="$prefix/share/mule"
78 AC_MSG_RESULT($emacsdir)
81 dnl # Check Emacs site-lisp directories
84 [ --with-lispdir=DIR emacs lisp files go to DIR [guessed]],
87 no) AC_MSG_ERROR(lispdir is not available) ;;
88 *) lispdir=${withval} ;;
90 AC_MSG_CHECKING([where .elc files should go])
91 if test "x$lispdir" = x; then
92 lispdir="$emacsdir/site-lisp"
93 if test -d $emacsdir/lisp; then
94 lispdir="$emacsdir/lisp"
96 case "$EMACS_BASENAME" in
98 lispdir="$lispdir/lookup"
102 AC_MSG_RESULT($lispdir)
105 dnl AC_EMACS_LIST AC_XEMACS_P AC_PATH_LISPDIR and AC_EMACS_CHECK_LIB
106 dnl are stolen from w3.
107 dnl AC_PATH_LISPDIR obsoletes AM_PATH_LISPDIR.
109 AC_DEFUN(AC_EMACS_LISP, [
111 if test -z "$3"; then
112 AC_MSG_CHECKING(for $1)
114 AC_CACHE_VAL(EMACS_cv_SYS_$1,[
116 echo ${EMACS}' -batch -eval '\''(let ((x '${elisp}')) (write-region (if (stringp x) (princ x) (prin1-to-string x)) nil "'${OUTPUT}'" nil 5))'\' >& AC_FD_CC 2>&1
117 eval ${EMACS}' -batch -eval '\''(let ((x '${elisp}')) (write-region (if (stringp x) (princ x) (prin1-to-string x)) nil "'${OUTPUT}'" nil 5))'\' >& AC_FD_CC 2>&1
118 retval=`cat ${OUTPUT}`
119 echo "=> ${retval}" >& AC_FD_CC 2>&1
121 EMACS_cv_SYS_$1=$retval
123 $1=${EMACS_cv_SYS_$1}
124 if test -z "$3"; then
129 AC_DEFUN(AC_XEMACS_P, [
130 AC_MSG_CHECKING([if $EMACS is really XEmacs])
131 AC_EMACS_LISP(xemacsp,(if (string-match \"XEmacs\" emacs-version) \"yes\" \"no\") ,"noecho")
132 XEMACSP=${EMACS_cv_SYS_xemacsp}
134 if test "$XEMACSP" = "yes"; then
137 AC_MSG_RESULT($XEMACSP)
138 AC_SUBST(EMACS_FLAVOR)
141 AC_DEFUN(AC_PATH_LISPDIR, [
143 if test "$prefix" = "NONE"; then
144 AC_MSG_CHECKING([prefix for your Emacs])
145 AC_EMACS_LISP(prefix,(expand-file-name \"..\" invocation-directory),"noecho")
146 prefix=${EMACS_cv_SYS_prefix}
147 AC_MSG_RESULT($prefix)
149 AC_ARG_WITH(lispdir,[ --with-lispdir=DIR Where to install lisp files], lispdir=${withval})
150 AC_MSG_CHECKING([where .elc files should go])
151 if test -z "$lispdir"; then
152 dnl Set default value
154 if test "x$theprefix" = "xNONE"; then
155 theprefix=$ac_default_prefix
157 lispdir="\$(datadir)/${EMACS_FLAVOR}/site-lisp"
158 for thedir in share lib; do
160 if test -d ${theprefix}/${thedir}/${EMACS_FLAVOR}/site-lisp; then
161 lispdir="\$(prefix)/${thedir}/${EMACS_FLAVOR}/site-lisp"
166 AC_MSG_RESULT($lispdir)
171 dnl Check whether a function exists in a library
172 dnl All '_' characters in the first argument are converted to '-'
174 AC_DEFUN(AC_EMACS_CHECK_LIB, [
175 if test -z "$3"; then
176 AC_MSG_CHECKING(for $2 in $1)
178 library=`echo $1 | tr _ -`
179 AC_EMACS_LISP($1,(progn (fmakunbound (quote $2)) (condition-case nil (progn (require (quote $library)) (fboundp (quote $2))) (error (prog1 nil (message \"$library not found\"))))),"noecho")
180 if test "${EMACS_cv_SYS_$1}" = "nil"; then
183 if test "${EMACS_cv_SYS_$1}" = "t"; then
186 HAVE_$1=${EMACS_cv_SYS_$1}
188 if test -z "$3"; then
189 AC_MSG_RESULT($HAVE_$1)
194 dnl Perform sanity checking and try to locate the W3 package
196 AC_DEFUN(AC_CHECK_W3, [
197 AC_MSG_CHECKING(for acceptable W3 version)
198 AC_CACHE_VAL(EMACS_cv_ACCEPTABLE_W3,[
199 AC_EMACS_CHECK_LIB(w3_forms, w3-form-encode-xwfu,"noecho")
200 if test "${HAVE_w3_forms}" = "yes"; then
201 EMACS_cv_ACCEPTABLE_W3=yes
203 EMACS_cv_ACCEPTABLE_W3=no
206 if test "${EMACS_cv_ACCEPTABLE_W3}" = "yes"; then
207 AC_EMACS_LISP(w3_dir,(file-name-directory (locate-library \"w3-forms\")),"noecho")
208 EMACS_cv_ACCEPTABLE_W3=$EMACS_cv_SYS_w3_dir
211 AC_ARG_WITH(w3,[ --with-w3=DIR Specify where to find the w3 package], [ EMACS_cv_ACCEPTABLE_W3=`( cd $withval && pwd || echo "$withval" ) 2> /dev/null` ])
212 W3=${EMACS_cv_ACCEPTABLE_W3}
214 AC_MSG_RESULT("${W3}")