Synch with Gnus.
[elisp/gnus.git-] / aclocal.m4
1 AC_DEFUN(AC_DEFINE_GNUS_PRODUCT_NAME,
2  [echo $ac_n "defining gnus product name... $ac_c"
3   AC_CACHE_VAL(EMACS_cv_GNUS_PRODUCT_NAME,[EMACS_cv_GNUS_PRODUCT_NAME=$1])
4   GNUS_PRODUCT_NAME=${EMACS_cv_GNUS_PRODUCT_NAME}
5   AC_MSG_RESULT(${GNUS_PRODUCT_NAME})
6   AC_SUBST(GNUS_PRODUCT_NAME)])
7
8 AC_DEFUN(AC_CHECK_EMACS,
9  [dnl Check for Emacsen.
10
11   dnl Apparently, if you run a shell window in Emacs, it sets the EMACS
12   dnl environment variable to 't'.  Lets undo the damage.
13   test x$EMACS = xt && EMACS=
14
15   dnl Ignore cache.
16   unset ac_cv_prog_EMACS; unset ac_cv_prog_XEMACS;
17
18   AC_ARG_WITH(emacs,
19    [  --with-emacs=EMACS      compile with EMACS [EMACS=emacs, mule...]],
20    [if test x$withval = xyes -o x$withval = x; then
21       AC_CHECK_PROGS(EMACS, emacs xemacs mule, emacs)
22     else
23       AC_CHECK_PROG(EMACS, $withval, $withval, emacs)
24     fi])
25   AC_ARG_WITH(xemacs,
26    [  --with-xemacs=XEMACS    compile with XEMACS [XEMACS=xemacs]],
27    [if test x$withval = xyes -o x$withval = x; then
28       AC_CHECK_PROG(XEMACS, xemacs, xemacs, xemacs)
29     else
30       AC_CHECK_PROG(XEMACS, $withval, $withval, xemacs)
31     fi
32     EMACS=$XEMACS],
33    [XEMACS=xemacs
34     test x$EMACS = x &&\
35       AC_CHECK_PROGS(EMACS, emacs xemacs mule, emacs)])
36   AC_SUBST(EMACS)
37   AC_SUBST(XEMACS)])
38
39 AC_DEFUN(AC_EMACS_LISP, [
40 elisp="$2"
41 if test -z "$3"; then
42         AC_MSG_CHECKING(for $1)
43 fi
44 AC_CACHE_VAL(EMACS_cv_SYS_$1,[
45         OUTPUT=./conftest-$$
46         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
47         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
48         retval=`cat ${OUTPUT}`
49         echo "=> ${retval}" >& AC_FD_CC 2>&1
50         rm -f ${OUTPUT}
51         EMACS_cv_SYS_$1=$retval
52 ])
53 $1=${EMACS_cv_SYS_$1}
54 if test -z "$3"; then
55         AC_MSG_RESULT($$1)
56 fi
57 ])
58
59 AC_DEFUN(AC_CHECK_EMACS_FLAVOR,
60  [AC_MSG_CHECKING([what a flavor does $EMACS have])
61
62   dnl Ignore cache.
63   unset EMACS_cv_SYS_flavor;
64
65   AC_EMACS_LISP(flavor,
66     (cond ((featurep (quote xemacs)) \"XEmacs\")\
67           ((boundp (quote MULE)) \"MULE\")\
68           (t \"FSF Emacs\")),
69     "noecho")
70   case $EMACS_cv_SYS_flavor in
71   XEmacs)
72     EMACS_FLAVOR=xemacs;;
73   MULE)
74     EMACS_FLAVOR=mule;;
75   *)
76     EMACS_FLAVOR=emacs;;
77   esac
78   AC_MSG_RESULT($EMACS_cv_SYS_flavor)])
79
80 AC_DEFUN(AC_PATH_LISPDIR, [
81   AC_CHECK_EMACS_FLAVOR
82   if test "$prefix" = "NONE"; then
83         AC_MSG_CHECKING([prefix for your Emacs])
84         AC_EMACS_LISP(prefix,(expand-file-name \"..\" invocation-directory),"noecho")
85         prefix=${EMACS_cv_SYS_prefix}
86         AC_MSG_RESULT($prefix)
87   fi
88   AC_ARG_WITH(lispdir,
89     [  --with-lispdir=DIR      Where to install lisp files
90                           (for XEmacs package, use --with-packagedir instead)],
91     lispdir=${withval})
92   AC_MSG_CHECKING([where lisp files should go])
93   if test -z "$lispdir"; then
94     dnl Set default value
95     theprefix=$prefix
96     if test "x$theprefix" = "xNONE"; then
97         theprefix=$ac_default_prefix
98     fi
99     lispdir="\$(datadir)/${EMACS_FLAVOR}/site-lisp/${GNUS_PRODUCT_NAME}"
100     for thedir in share lib; do
101         potential=
102         if test -d ${theprefix}/${thedir}/${EMACS_FLAVOR}/site-lisp; then
103            lispdir="\$(prefix)/${thedir}/${EMACS_FLAVOR}/site-lisp/${GNUS_PRODUCT_NAME}"
104            break
105         fi
106     done
107   fi
108   if test ${EMACS_FLAVOR} = xemacs; then
109     AC_MSG_RESULT([$lispdir
110          (it will be ignored when \"make install-package[[-ja]]\" is done)])
111   else
112     AC_MSG_RESULT([$lispdir])
113   fi
114   AC_SUBST(lispdir)
115 ])
116
117 dnl
118 dnl Check whether a function exists in a library
119 dnl All '_' characters in the first argument are converted to '-'
120 dnl
121 AC_DEFUN(AC_EMACS_CHECK_LIB, [
122 if test -z "$3"; then
123         AC_MSG_CHECKING(for $2 in $1)
124 fi
125 library=`echo $1 | tr _ -`
126 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")
127 if test "${EMACS_cv_SYS_$1}" = "nil"; then
128         EMACS_cv_SYS_$1=no
129 fi
130 if test "${EMACS_cv_SYS_$1}" = "t"; then
131         EMACS_cv_SYS_$1=yes
132 fi
133 HAVE_$1=${EMACS_cv_SYS_$1}
134 AC_SUBST(HAVE_$1)
135 if test -z "$3"; then
136         AC_MSG_RESULT($HAVE_$1)
137 fi
138 ])
139
140 dnl
141 dnl Perform sanity checking and try to locate the W3 package
142 dnl
143 AC_DEFUN(AC_CHECK_W3, [
144 AC_MSG_CHECKING(for acceptable W3 version)
145
146 dnl Ignore cache.
147 unset EMACS_cv_ACCEPTABLE_W3;
148 unset EMACS_cv_SYS_w3_dir;
149 unset EMACS_cv_SYS_w3_forms;
150
151 AC_CACHE_VAL(EMACS_cv_ACCEPTABLE_W3,[
152 AC_EMACS_CHECK_LIB(w3_forms, w3-form-encode-xwfu,"noecho")
153 if test "${HAVE_w3_forms}" = "yes"; then
154         EMACS_cv_ACCEPTABLE_W3=yes
155 else
156         EMACS_cv_ACCEPTABLE_W3=
157 fi
158
159 if test "x${EMACS_cv_ACCEPTABLE_W3}" = "xyes"; then
160         AC_EMACS_LISP(w3_dir,(file-name-directory (locate-library \"w3-forms\")),"noecho")
161         EMACS_cv_ACCEPTABLE_W3=$EMACS_cv_SYS_w3_dir
162 fi
163 ])
164    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` ])
165    W3=${EMACS_cv_ACCEPTABLE_W3}
166    AC_SUBST(W3)
167    if test "x${EMACS_cv_ACCEPTABLE_W3}" = "x"; then
168         AC_MSG_RESULT(not found)
169    else
170         AC_MSG_RESULT(${W3})
171    fi
172 ])
173
174 AC_DEFUN(AC_EXAMINE_PACKAGEDIR,
175  [dnl Examine PACKAGEDIR.
176   AC_EMACS_LISP(PACKAGEDIR,
177     (let (package-dir)\
178       (if (boundp (quote early-packages))\
179           (let ((dirs (delq nil (append (if early-package-load-path\
180                                             early-packages)\
181                                         (if late-package-load-path\
182                                             late-packages)\
183                                         (if last-package-load-path\
184                                             last-packages)))))\
185             (while (and dirs (not package-dir))\
186               (if (file-directory-p (car dirs))\
187                   (setq package-dir (car dirs)\
188                         dirs (cdr dirs))))))\
189       (or package-dir \"\")),
190     "noecho")])
191
192 AC_DEFUN(AC_PATH_PACKAGEDIR,
193  [dnl Check for PACKAGEDIR.
194   if test ${EMACS_FLAVOR} = xemacs; then
195     AC_MSG_CHECKING([where the XEmacs package is])
196     AC_ARG_WITH(packagedir,
197       [  --with-packagedir=DIR   package DIR for XEmacs],
198       [if test x$withval != xyes -a x$withval != x; then
199         PACKAGEDIR=$withval
200       else
201         AC_EXAMINE_PACKAGEDIR
202       fi],
203       AC_EXAMINE_PACKAGEDIR)
204     if test x$PACKAGEDIR = x; then
205       AC_MSG_RESULT(not found)
206     else
207       AC_MSG_RESULT($PACKAGEDIR)
208     fi
209   else
210     PACKAGEDIR=
211   fi
212   AC_SUBST(PACKAGEDIR)])
213
214 AC_DEFUN(AC_ADD_LOAD_PATH,
215  [dnl Check for additional load path.
216   AC_ARG_WITH(addpath,
217    [  --with-addpath=PATH     search Emacs-Lisp libraries with PATH
218                           use colons to separate directory names],
219    [if test x$withval != xyes -a x$withval != x; then
220       AC_MSG_CHECKING([where to find the additional elisp libraries])
221       ADDITIONAL_LOAD_PATH=$withval
222       AC_MSG_RESULT($ADDITIONAL_LOAD_PATH)
223     fi],
224     ADDITIONAL_LOAD_PATH=)
225   AC_SUBST(ADDITIONAL_LOAD_PATH)])