Synch to Gnus 200401041001.
[elisp/gnus.git-] / aclocal.m4
1 AC_DEFUN(AC_DEFINE_GNUS_PRODUCT_NAME,
2  [echo $ECHO_N "defining gnus product name... $ECHO_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 "$EMACS" = t && 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 "$withval" = yes -o -z "$withval"; 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 "$withval" = yes -o -z "$withval"; 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 -z "$EMACS" && AC_CHECK_PROGS(EMACS, emacs xemacs mule, emacs)])
35   AC_SUBST(EMACS)
36   AC_SUBST(XEMACS)])
37
38 AC_DEFUN(AC_EMACS_LISP, [
39 elisp="$2"
40 if test -z "$3"; then
41         AC_MSG_CHECKING(for $1)
42 fi
43 AC_CACHE_VAL(EMACS_cv_SYS_$1,[
44         OUTPUT=./conftest-$$
45         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
46         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
47         retval=`cat ${OUTPUT}`
48         echo "=> ${retval}" >& AC_FD_CC 2>&1
49         rm -f ${OUTPUT}
50         EMACS_cv_SYS_$1=$retval
51 ])
52 $1=${EMACS_cv_SYS_$1}
53 if test -z "$3"; then
54         AC_MSG_RESULT($$1)
55 fi
56 ])
57
58 AC_DEFUN(AC_CHECK_EMACS_FLAVOR,
59  [AC_MSG_CHECKING([what a flavor does $EMACS have])
60
61   dnl Ignore cache.
62   unset EMACS_cv_SYS_flavor;
63
64   AC_EMACS_LISP(flavor,
65     (cond ((featurep (quote xemacs)) \"XEmacs\")\
66           ((boundp (quote MULE)) \"MULE\")\
67           (t \"FSF Emacs\")),
68     "noecho")
69   case $EMACS_cv_SYS_flavor in
70   XEmacs)
71     EMACS_FLAVOR=xemacs;;
72   MULE)
73     EMACS_FLAVOR=mule;;
74   *)
75     EMACS_FLAVOR=emacs;;
76   esac
77   AC_MSG_RESULT($EMACS_cv_SYS_flavor)])
78
79 AC_DEFUN(AC_PATH_LISPDIR, [
80   AC_CHECK_EMACS_FLAVOR
81   if test "$prefix" = NONE; then
82         AC_MSG_CHECKING([prefix for your Emacs])
83         AC_EMACS_LISP(prefix,(expand-file-name \"..\" invocation-directory),"noecho")
84         prefix=${EMACS_cv_SYS_prefix}
85         AC_MSG_RESULT($prefix)
86   fi
87   AC_ARG_WITH(lispdir,
88     [  --with-lispdir=DIR      Where to install lisp files
89                           (for XEmacs package, use --with-packagedir instead)],
90     lispdir=${withval})
91   AC_MSG_CHECKING([where lisp files should go])
92   if test -z "$lispdir"; then
93     dnl Set default value
94     theprefix=$prefix
95     if test "$theprefix" = NONE; then
96         theprefix=$ac_default_prefix
97     fi
98     if test "$EMACS_FLAVOR" = "xemacs"; then
99         datadir="\$(prefix)/lib"
100         lispdir="\$(datadir)/${EMACS_FLAVOR}/site-packages/lisp/${GNUS_PRODUCT_NAME}"
101     else
102         lispdir="\$(datadir)/${EMACS_FLAVOR}/site-lisp/${GNUS_PRODUCT_NAME}"
103     fi
104     for thedir in share lib; do
105         potential=
106         if test -d ${theprefix}/${thedir}/${EMACS_FLAVOR}/site-lisp; then
107            if test "$EMACS_FLAVOR" = "xemacs"; then
108                lispdir="\$(prefix)/${thedir}/${EMACS_FLAVOR}/site-packages/lisp/${GNUS_PRODUCT_NAME}"
109            else
110                lispdir="\$(prefix)/${thedir}/${EMACS_FLAVOR}/site-lisp/${GNUS_PRODUCT_NAME}"
111            fi
112            break
113         fi
114     done
115   fi
116   if test ${EMACS_FLAVOR} = xemacs; then
117     AC_MSG_RESULT([$lispdir
118          (it will be ignored when \"make install-package[[-ja]]\" is done)])
119   else
120     AC_MSG_RESULT([$lispdir])
121   fi
122   AC_SUBST(lispdir)
123 ])
124
125 AC_DEFUN(AC_PATH_ETCDIR, [
126   AC_ARG_WITH(etcdir,[  --with-etcdir=DIR       Where to install etc files], etcdir=${withval})
127   AC_MSG_CHECKING([where etc files should go])
128   if test -z "$etcdir"; then
129     dnl Set default value.
130     if test "$EMACS_FLAVOR" = "xemacs"; then
131       etcdir="\$(lispdir)/../../etc"
132     else
133     etcdir="\$(lispdir)/../etc"
134     fi
135   fi
136   AC_MSG_RESULT($etcdir)
137   AC_SUBST(etcdir)
138 ])
139
140 dnl 
141 dnl This is a bit on the "evil hack" side of things.  It is so we can
142 dnl have a different default infodir for XEmacs.  A user can still specify
143 dnl someplace else with '--infodir=DIR'.
144 dnl
145 AC_DEFUN(AC_PATH_INFO_DIR, [
146   AC_MSG_CHECKING([where the TeXinfo docs should go])
147   dnl Set default value.  This must be an absolute path.
148   if test "$infodir" = "\${prefix}/info"; then
149     if test "$EMACS_FLAVOR" = "xemacs"; then
150       info_dir="\$(prefix)/${thedir}/${EMACS_FLAVOR}/site-packages/info"
151     else
152       info_dir="\$(prefix)/info"
153     fi
154   else
155     info_dir=$infodir
156   fi
157   AC_MSG_RESULT([$info_dir
158          (it will be ignored when \"make install-package[[-ja]]\" is done)])
159   AC_SUBST(info_dir)
160 ])
161
162 dnl
163 dnl This will set the XEmacs command line options to be slightly different
164 dnl from the Emacs ones.  If building with XEmacs the options will be
165 dnl "-batch -no-autoloads..." to give a much cleaner build environment.
166 dnl
167 AC_DEFUN(AC_SET_BUILD_FLAGS, [
168   AC_MSG_CHECKING([which options to pass on to (X)Emacs])
169   if test "x$FLAGS" = "x"; then
170     if test "$EMACS_FLAVOR" = "xemacs"; then
171       FLAGS="-batch -no-autoloads -l \$(srcdir)/dgnushack.el"
172     else
173       FLAGS="-batch -q -no-site-file -l \$(srcdir)/dgnushack.el"
174     fi
175   else
176     FLAGS=$FLAGS
177   fi
178   AC_MSG_RESULT($FLAGS)
179   AC_SUBST(FLAGS)
180 ])
181
182 dnl
183 dnl Check whether a function exists in a library
184 dnl All '_' characters in the first argument are converted to '-'
185 dnl
186 AC_DEFUN(AC_EMACS_CHECK_LIB, [
187 if test -z "$3"; then
188         AC_MSG_CHECKING(for $2 in $1)
189 fi
190 library=`echo $1 | tr _ -`
191 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")
192 if test "${EMACS_cv_SYS_$1}" = nil; then
193         EMACS_cv_SYS_$1=no
194 fi
195 if test "${EMACS_cv_SYS_$1}" = t; then
196         EMACS_cv_SYS_$1=yes
197 fi
198 HAVE_$1=${EMACS_cv_SYS_$1}
199 AC_SUBST(HAVE_$1)
200 if test -z "$3"; then
201         AC_MSG_RESULT($HAVE_$1)
202 fi
203 ])
204
205 dnl
206 dnl Perform sanity checking and try to locate the W3 package
207 dnl
208 AC_DEFUN(AC_CHECK_W3, [
209 AC_MSG_CHECKING(for acceptable W3 version)
210
211 dnl Ignore cache.
212 unset EMACS_cv_ACCEPTABLE_W3;
213 unset EMACS_cv_SYS_w3_dir;
214 unset EMACS_cv_SYS_w3_forms;
215
216 AC_CACHE_VAL(EMACS_cv_ACCEPTABLE_W3,[
217 AC_EMACS_CHECK_LIB(w3_forms, w3-form-encode-xwfu,"noecho")
218 if test "${HAVE_w3_forms}" = yes; then
219         EMACS_cv_ACCEPTABLE_W3=yes
220 else
221         EMACS_cv_ACCEPTABLE_W3=
222 fi
223
224 if test "${EMACS_cv_ACCEPTABLE_W3}" = yes; then
225         AC_EMACS_LISP(w3_dir,(file-name-directory (locate-library \"w3-forms\")),"noecho")
226         EMACS_cv_ACCEPTABLE_W3=$EMACS_cv_SYS_w3_dir
227 fi
228 ])
229    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` ])
230    W3=${EMACS_cv_ACCEPTABLE_W3}
231    AC_SUBST(W3)
232    if test -z "${EMACS_cv_ACCEPTABLE_W3}"; then
233         AC_MSG_RESULT(not found)
234    else
235         AC_MSG_RESULT(${W3})
236    fi
237 ])
238
239 dnl
240 dnl Perform sanity checking and try to locate the W3 package
241 dnl
242 AC_DEFUN(AC_CHECK_URL, [
243 AC_MSG_CHECKING(for acceptable URL version)
244
245 dnl Ignore cache.
246 unset EMACS_cv_ACCEPTABLE_URL;
247 unset EMACS_cv_SYS_url_dir;
248 unset EMACS_cv_SYS_url;
249
250 AC_CACHE_VAL(EMACS_cv_ACCEPTABLE_URL,[
251 AC_EMACS_CHECK_LIB(url, url-retrieve, "noecho")
252 if test "${HAVE_url}" = yes; then
253         EMACS_cv_ACCEPTABLE_URL=yes
254 else
255         EMACS_cv_ACCEPTABLE_URL=
256 fi
257
258 if test "${EMACS_cv_ACCEPTABLE_URL}" = yes; then
259         AC_EMACS_LISP(url_dir,(file-name-directory (locate-library \"url\")),"noecho")
260         EMACS_cv_ACCEPTABLE_URL=$EMACS_cv_SYS_url_dir
261 fi
262 ])
263    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` ])
264    URL=${EMACS_cv_ACCEPTABLE_URL}
265    AC_SUBST(URL)
266    if test -z "${EMACS_cv_ACCEPTABLE_URL}"; then
267         AC_MSG_RESULT(not found)
268    else
269         AC_MSG_RESULT(${URL})
270    fi
271 ])
272
273 dnl
274 dnl Perform checking available fonts: Adobe Bembo, Adobe Futura and 
275 dnl Bitstream Courier.
276 dnl
277
278 AC_DEFUN(GNUS_CHECK_FONTS, [
279 test "$LATEX" = t && LATEX=
280 test "$LATEX" || AC_PATH_PROGS(LATEX, latex, no)
281 AC_MSG_CHECKING(for available fonts)
282 AC_ARG_WITH(fonts,[  --with-fonts            Assume all fonts required are available],[USE_FONTS="$withval"])
283 WITH_FONTS_bembo='%'
284 WITHOUT_FONTS_bembo=
285 WITH_FONTS_pfu='%'
286 WITHOUT_FONTS_pfu=
287 WITH_FONTS_bcr='%'
288 WITHOUT_FONTS_bcr=
289 if test -z "${USE_FONTS}"; then
290   if test "${LATEX}" = no; then
291         :
292   else
293     OUTPUT=./conftest-$$
294     echo '\nonstopmode\documentclass{article}\usepackage{bembo}\begin{document}\end{document}' > ${OUTPUT}
295     if ${LATEX} ${OUTPUT} </dev/null >& AC_FD_CC 2>&1  ; then  
296       if test -z "${USE_FONTS}"; then
297         USE_FONTS="Adobe Bembo"
298       else
299         USE_FONTS="${USE_FONTS}, Adobe Bembo"
300       fi
301       WITH_FONTS_bembo=
302       WITHOUT_FONTS_bembo='%'
303     fi
304     echo '\nonstopmode\documentclass{article}\begin{document}{\fontfamily{pfu}\fontsize{10pt}{10}\selectfont test}\end{document}' > ${OUTPUT}
305     if retval=`${LATEX} ${OUTPUT} </dev/null 2>& AC_FD_CC`; then
306       if echo "$retval" | grep 'Some font shapes were not available' >& AC_FD_CC 2>&1  ; then  
307         :
308       else
309          if test -z "${USE_FONTS}"; then
310           USE_FONTS="Adobe Futura"
311          else
312           USE_FONTS="${USE_FONTS}, Adobe Futura"
313          fi
314          WITH_FONTS_pfu=
315          WITHOUT_FONTS_pfu='%'
316       fi
317     fi
318     echo '\nonstopmode\documentclass{article}\begin{document}{\fontfamily{bcr}\fontsize{10pt}{10}\selectfont test}\end{document}' > ${OUTPUT}
319     if retval=`${LATEX} ${OUTPUT} </dev/null 2>& AC_FD_CC`; then
320       if echo "$retval" | grep 'Some font shapes were not available' >& AC_FD_CC 2>&1  ; then  
321         :
322       else
323          if test -z "${USE_FONTS}"; then
324           USE_FONTS="Bitstream Courier"
325          else
326           USE_FONTS="${USE_FONTS}, Bitstream Courier"
327          fi
328          WITH_FONTS_bcr=
329          WITHOUT_FONTS_bcr='%'
330       fi
331     fi
332     rm -f ${OUTPUT} ${OUTPUT}.aux ${OUTPUT}.log ${OUTPUT}.dvi
333   fi
334 elif test "${USE_FONTS}" = yes ; then
335   WITH_FONTS_bembo=
336   WITHOUT_FONTS_bembo='%'
337   WITH_FONTS_pfu=
338   WITHOUT_FONTS_pfu='%'
339   WITH_FONTS_bcr=
340   WITHOUT_FONTS_bcr='%'
341 fi
342 AC_SUBST(WITH_FONTS_bembo)
343 AC_SUBST(WITHOUT_FONTS_bembo)
344 AC_SUBST(WITH_FONTS_pfu)
345 AC_SUBST(WITHOUT_FONTS_pfu)
346 AC_SUBST(WITH_FONTS_bcr)
347 AC_SUBST(WITHOUT_FONTS_bcr)
348 if test -z "${USE_FONTS}" ; then
349   USE_FONTS=no
350 fi
351 USE_FONTS=`echo "${USE_FONTS}" | sed 's/,\([[^,]]*\)$/ and\1/'`
352 AC_MSG_RESULT(${USE_FONTS})
353 if test "${USE_FONTS}" = yes ; then
354   USE_FONTS='Set in Adobe Bembo, Adobe Futura and Bitstream Courier.'
355 elif test "${USE_FONTS}" = no ; then
356   USE_FONTS=''
357 else
358   USE_FONTS="Set in ${USE_FONTS}."
359 fi
360 AC_SUBST(USE_FONTS)
361 ])
362
363 AC_DEFUN(AC_EXAMINE_PACKAGEDIR,
364  [dnl Examine PACKAGEDIR.
365   AC_EMACS_LISP(PACKAGEDIR,
366     (let (package-dir)\
367       (if (boundp (quote early-packages))\
368           (let ((dirs (delq nil (append (if early-package-load-path\
369                                             early-packages)\
370                                         (if late-package-load-path\
371                                             late-packages)\
372                                         (if last-package-load-path\
373                                             last-packages)))))\
374             (while (and dirs (not package-dir))\
375               (if (file-directory-p (car dirs))\
376                   (setq package-dir (car dirs)\
377                         dirs (cdr dirs))))))\
378       (or package-dir \"\")),
379     "noecho")])
380
381 AC_DEFUN(AC_PATH_PACKAGEDIR,
382  [dnl Check for PACKAGEDIR.
383   if test ${EMACS_FLAVOR} = xemacs; then
384     AC_MSG_CHECKING([where the XEmacs package is])
385     AC_ARG_WITH(packagedir,
386       [  --with-packagedir=DIR   package DIR for XEmacs],
387       [if test "$withval" != yes -a -n "$withval"; then
388         PACKAGEDIR=$withval
389       else
390         AC_EXAMINE_PACKAGEDIR
391       fi],
392       AC_EXAMINE_PACKAGEDIR)
393     if test -z "$PACKAGEDIR"; then
394       AC_MSG_RESULT(not found)
395     else
396       AC_MSG_RESULT($PACKAGEDIR)
397     fi
398   else
399     PACKAGEDIR=
400   fi
401   AC_SUBST(PACKAGEDIR)])
402
403 AC_DEFUN(AC_ADD_LOAD_PATH,
404  [dnl Check for additional load path.
405   AC_ARG_WITH(addpath,
406    [  --with-addpath=PATH     search Emacs-Lisp libraries with PATH
407                           use colons to separate directory names],
408    [if test "$withval" != yes -a -n "$withval"; then
409       AC_MSG_CHECKING([where to find the additional elisp libraries])
410       ADDITIONAL_LOAD_PATH=$withval
411       AC_MSG_RESULT($ADDITIONAL_LOAD_PATH)
412     fi],
413     ADDITIONAL_LOAD_PATH=)
414   AC_SUBST(ADDITIONAL_LOAD_PATH)])