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