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