Cleaning up more.
[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 AC_DEFUN(AC_PATH_ETCDIR, [
118   AC_ARG_WITH(etcdir,[  --with-etcdir=DIR       Where to install etc files], etcdir=${withval})
119   AC_MSG_CHECKING([where etc files should go])
120   if test -z "$etcdir"; then
121     dnl Set default value
122     etcdir="\$(lispdir)/../etc"
123   fi
124   AC_MSG_RESULT($etcdir)
125   AC_SUBST(etcdir)
126 ])
127
128 dnl
129 dnl Check whether a function exists in a library
130 dnl All '_' characters in the first argument are converted to '-'
131 dnl
132 AC_DEFUN(AC_EMACS_CHECK_LIB, [
133 if test -z "$3"; then
134         AC_MSG_CHECKING(for $2 in $1)
135 fi
136 library=`echo $1 | tr _ -`
137 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")
138 if test "${EMACS_cv_SYS_$1}" = "nil"; then
139         EMACS_cv_SYS_$1=no
140 fi
141 if test "${EMACS_cv_SYS_$1}" = "t"; then
142         EMACS_cv_SYS_$1=yes
143 fi
144 HAVE_$1=${EMACS_cv_SYS_$1}
145 AC_SUBST(HAVE_$1)
146 if test -z "$3"; then
147         AC_MSG_RESULT($HAVE_$1)
148 fi
149 ])
150
151 dnl
152 dnl Perform sanity checking and try to locate the W3 package
153 dnl
154 AC_DEFUN(AC_CHECK_W3, [
155 AC_MSG_CHECKING(for acceptable W3 version)
156
157 dnl Ignore cache.
158 unset EMACS_cv_ACCEPTABLE_W3;
159 unset EMACS_cv_SYS_w3_dir;
160 unset EMACS_cv_SYS_w3_forms;
161
162 AC_CACHE_VAL(EMACS_cv_ACCEPTABLE_W3,[
163 AC_EMACS_CHECK_LIB(w3_forms, w3-form-encode-xwfu,"noecho")
164 if test "${HAVE_w3_forms}" = "yes"; then
165         EMACS_cv_ACCEPTABLE_W3=yes
166 else
167         EMACS_cv_ACCEPTABLE_W3=
168 fi
169
170 if test "x${EMACS_cv_ACCEPTABLE_W3}" = "xyes"; then
171         AC_EMACS_LISP(w3_dir,(file-name-directory (locate-library \"w3-forms\")),"noecho")
172         EMACS_cv_ACCEPTABLE_W3=$EMACS_cv_SYS_w3_dir
173 fi
174 ])
175    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` ])
176    W3=${EMACS_cv_ACCEPTABLE_W3}
177    AC_SUBST(W3)
178    if test "x${EMACS_cv_ACCEPTABLE_W3}" = "x"; then
179         AC_MSG_RESULT(not found)
180    else
181         AC_MSG_RESULT(${W3})
182    fi
183 ])
184
185 dnl
186 dnl Perform sanity checking and try to locate the W3 package
187 dnl
188 AC_DEFUN(AC_CHECK_URL, [
189 AC_MSG_CHECKING(for acceptable URL version)
190
191 dnl Ignore cache.
192 unset EMACS_cv_ACCEPTABLE_URL;
193 unset EMACS_cv_SYS_url_dir;
194 unset EMACS_cv_SYS_url;
195
196 AC_CACHE_VAL(EMACS_cv_ACCEPTABLE_URL,[
197 AC_EMACS_CHECK_LIB(url, url-retrieve, "noecho")
198 if test "${HAVE_url}" = "yes"; then
199         EMACS_cv_ACCEPTABLE_URL=yes
200 else
201         EMACS_cv_ACCEPTABLE_URL=
202 fi
203
204 if test "x${EMACS_cv_ACCEPTABLE_URL}" = "xyes"; then
205         AC_EMACS_LISP(url_dir,(file-name-directory (locate-library \"url\")),"noecho")
206         EMACS_cv_ACCEPTABLE_URL=$EMACS_cv_SYS_url_dir
207 fi
208 ])
209    AC_ARG_WITH(url,[  --with-url=DIR          Specify where to find the url package], [ EMACS_cv_ACCEPTABLE_URL=`( cd $withval && pwd || echo "$withval" ) 2> /dev/null` ])
210    URL=${EMACS_cv_ACCEPTABLE_URL}
211    AC_SUBST(URL)
212    if test "x${EMACS_cv_ACCEPTABLE_URL}" = "x"; then
213         AC_MSG_RESULT(not found)
214    else
215         AC_MSG_RESULT("${URL}")
216    fi
217 ])
218
219 AC_DEFUN(AC_EXAMINE_PACKAGEDIR,
220  [dnl Examine PACKAGEDIR.
221   AC_EMACS_LISP(PACKAGEDIR,
222     (let (package-dir)\
223       (if (boundp (quote early-packages))\
224           (let ((dirs (delq nil (append (if early-package-load-path\
225                                             early-packages)\
226                                         (if late-package-load-path\
227                                             late-packages)\
228                                         (if last-package-load-path\
229                                             last-packages)))))\
230             (while (and dirs (not package-dir))\
231               (if (file-directory-p (car dirs))\
232                   (setq package-dir (car dirs)\
233                         dirs (cdr dirs))))))\
234       (or package-dir \"\")),
235     "noecho")])
236
237 AC_DEFUN(AC_PATH_PACKAGEDIR,
238  [dnl Check for PACKAGEDIR.
239   if test ${EMACS_FLAVOR} = xemacs; then
240     AC_MSG_CHECKING([where the XEmacs package is])
241     AC_ARG_WITH(packagedir,
242       [  --with-packagedir=DIR   package DIR for XEmacs],
243       [if test x$withval != xyes -a x$withval != x; then
244         PACKAGEDIR=$withval
245       else
246         AC_EXAMINE_PACKAGEDIR
247       fi],
248       AC_EXAMINE_PACKAGEDIR)
249     if test x$PACKAGEDIR = x; then
250       AC_MSG_RESULT(not found)
251     else
252       AC_MSG_RESULT($PACKAGEDIR)
253     fi
254   else
255     PACKAGEDIR=
256   fi
257   AC_SUBST(PACKAGEDIR)])
258
259 AC_DEFUN(AC_ADD_LOAD_PATH,
260  [dnl Check for additional load path.
261   AC_ARG_WITH(addpath,
262    [  --with-addpath=PATH     search Emacs-Lisp libraries with PATH
263                           use colons to separate directory names],
264    [if test x$withval != xyes -a x$withval != x; then
265       AC_MSG_CHECKING([where to find the additional elisp libraries])
266       ADDITIONAL_LOAD_PATH=$withval
267       AC_MSG_RESULT($ADDITIONAL_LOAD_PATH)
268     fi],
269     ADDITIONAL_LOAD_PATH=)
270   AC_SUBST(ADDITIONAL_LOAD_PATH)])