* lisp/gnus-art.el (gnus-article-setup-buffer): Set
[elisp/gnus.git-] / acinclude.m4
1 dnl Copyright (C) 1999 NISHIDA Keisuke <knishida@ring.aist.go.jp>
2 dnl
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)
6 dnl any later version.
7 dnl
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.
12 dnl
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
16 dnl 02111-1307, USA.
17
18 AC_DEFUN(AM_PATH_LISPDIR,
19  [dnl #
20   dnl # Check Emacs
21   dnl #
22   AC_ARG_WITH(emacs,
23     [  --with-emacs=EMACS      compile with EMACS [EMACS=emacs, xemacs...]],
24     [case "${withval}" in
25        yes)     EMACS= ;;
26        no)      AC_MSG_ERROR([emacs is not available]) ;;
27        *)       EMACS=${withval} ;;
28      esac], EMACS=)
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)
33     fi
34   fi
35   dnl #
36   dnl # Check Emacs directories
37   dnl #
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
43     fi
44     emacsdir="\$(datadir)/emacs"
45     case "$EMACS_BASENAME" in
46     emacs|emacs-*)
47       if test -d $prefix/lib/emacs; then
48         emacsdir="$prefix/lib/emacs"
49       fi
50       if test -d $prefix/share/emacs; then
51         emacsdir="$prefix/share/emacs"
52       fi
53       ;;
54     xemacs|xemacs-*)
55       if test -d $prefix/lib/xemacs; then
56         emacsdir="$prefix/lib/xemacs"
57       fi
58       if test -d $prefix/share/xemacs; then
59         emacsdir="$prefix/share/xemacs"
60       fi
61       ;;
62     mule|mule-*)
63       if test -d $prefix/lib/emacs; then
64         emacsdir="$prefix/lib/emacs"
65       fi
66       if test -d $prefix/share/emacs; then
67         emacsdir="$prefix/share/emacs"
68       fi
69       if test -d $prefix/lib/mule; then
70         emacsdir="$prefix/lib/mule"
71       fi
72       if test -d $prefix/share/mule; then
73         emacsdir="$prefix/share/mule"
74       fi
75       ;;
76     esac
77   fi
78   AC_MSG_RESULT($emacsdir)
79   AC_SUBST(emacsdir)
80   dnl #
81   dnl # Check Emacs site-lisp directories
82   dnl #
83   AC_ARG_WITH(lispdir,
84     [  --with-lispdir=DIR      emacs lisp files go to DIR [guessed]],
85     [case "${withval}" in
86        yes)     lispdir= ;;
87        no)      AC_MSG_ERROR(lispdir is not available) ;;
88        *)       lispdir=${withval} ;;
89      esac], lispdir=)
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"
95     fi
96     case "$EMACS_BASENAME" in
97     xemacs|xemacs-*)
98       lispdir="$lispdir/lookup"
99       ;;
100     esac
101   fi
102   AC_MSG_RESULT($lispdir)
103   AC_SUBST(lispdir)])
104
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.
108
109 AC_DEFUN(AC_EMACS_LISP, [
110 elisp="$2"
111 if test -z "$3"; then
112         AC_MSG_CHECKING(for $1)
113 fi
114 AC_CACHE_VAL(EMACS_cv_SYS_$1,[
115         OUTPUT=./conftest-$$
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
120         rm -f ${OUTPUT}
121         EMACS_cv_SYS_$1=$retval
122 ])
123 $1=${EMACS_cv_SYS_$1}
124 if test -z "$3"; then
125         AC_MSG_RESULT($$1)
126 fi
127 ])
128
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}
133   EMACS_FLAVOR=emacs
134   if test "$XEMACSP" = "yes"; then
135      EMACS_FLAVOR=xemacs
136   fi
137   AC_MSG_RESULT($XEMACSP)
138   AC_SUBST(EMACS_FLAVOR)
139 ])
140 ye
141 AC_DEFUN(AC_PATH_LISPDIR, [
142   AC_XEMACS_P
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)
148   fi
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
153     theprefix=$prefix
154     if test "x$theprefix" = "xNONE"; then
155         theprefix=$ac_default_prefix
156     fi
157     lispdir="\$(datadir)/${EMACS_FLAVOR}/site-lisp"
158     for thedir in share lib; do
159         potential=
160         if test -d ${theprefix}/${thedir}/${EMACS_FLAVOR}/site-lisp; then
161            lispdir="\$(prefix)/${thedir}/${EMACS_FLAVOR}/site-lisp"
162            break
163         fi
164     done
165   fi
166   AC_MSG_RESULT($lispdir)
167   AC_SUBST(lispdir)
168 ])
169
170 dnl
171 dnl Check whether a function exists in a library
172 dnl All '_' characters in the first argument are converted to '-'
173 dnl
174 AC_DEFUN(AC_EMACS_CHECK_LIB, [
175 if test -z "$3"; then
176         AC_MSG_CHECKING(for $2 in $1)
177 fi
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
181         EMACS_cv_SYS_$1=no
182 fi
183 if test "${EMACS_cv_SYS_$1}" = "t"; then
184         EMACS_cv_SYS_$1=yes
185 fi
186 HAVE_$1=${EMACS_cv_SYS_$1}
187 AC_SUBST(HAVE_$1)
188 if test -z "$3"; then
189         AC_MSG_RESULT($HAVE_$1)
190 fi
191 ])
192
193 dnl
194 dnl Perform sanity checking and try to locate the W3 package
195 dnl
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
202 else
203         EMACS_cv_ACCEPTABLE_W3=no
204 fi
205
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
209 fi
210 ])
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}
213    AC_SUBST(W3)
214    AC_MSG_RESULT("${W3}")
215 ])