d628a6815fb2875d9b80cdaaeba01cd1f53a086b
[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 "$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   AC_SUBST(info_dir)
159 ])
160
161 dnl
162 dnl This will set the XEmacs command line options to be slightly different
163 dnl from the Emacs ones.  If building with XEmacs the options will be
164 dnl "-batch -no-autoloads..." to give a much cleaner build environment.
165 dnl
166 AC_DEFUN(AC_SET_BUILD_FLAGS, [
167   AC_MSG_CHECKING([which options to pass on to (X)Emacs])
168   if test "x$FLAGS" = "x"; then
169     if test "$EMACS_FLAVOR" = "xemacs"; then
170       FLAGS="-batch -no-autoloads -l \$(srcdir)/dgnushack.el"
171     else
172       FLAGS="-batch -q -no-site-file -l \$(srcdir)/dgnushack.el"
173     fi
174   else
175     FLAGS=$FLAGS
176   fi
177   AC_MSG_RESULT($FLAGS)
178   AC_SUBST(FLAGS)
179 ])
180
181 dnl
182 dnl Check whether a function exists in a library
183 dnl All '_' characters in the first argument are converted to '-'
184 dnl
185 AC_DEFUN(AC_EMACS_CHECK_LIB, [
186 if test -z "$3"; then
187         AC_MSG_CHECKING(for $2 in $1)
188 fi
189 library=`echo $1 | tr _ -`
190 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")
191 if test "${EMACS_cv_SYS_$1}" = nil; then
192         EMACS_cv_SYS_$1=no
193 fi
194 if test "${EMACS_cv_SYS_$1}" = t; then
195         EMACS_cv_SYS_$1=yes
196 fi
197 HAVE_$1=${EMACS_cv_SYS_$1}
198 AC_SUBST(HAVE_$1)
199 if test -z "$3"; then
200         AC_MSG_RESULT($HAVE_$1)
201 fi
202 ])
203
204 dnl
205 dnl Perform sanity checking and try to locate the W3 package
206 dnl
207 AC_DEFUN(AC_CHECK_W3, [
208 AC_MSG_CHECKING(for acceptable W3 version)
209
210 dnl Ignore cache.
211 unset EMACS_cv_ACCEPTABLE_W3;
212 unset EMACS_cv_SYS_w3_dir;
213 unset EMACS_cv_SYS_w3_forms;
214
215 AC_CACHE_VAL(EMACS_cv_ACCEPTABLE_W3,[
216 AC_EMACS_CHECK_LIB(w3_forms, w3-form-encode-xwfu,"noecho")
217 if test "${HAVE_w3_forms}" = yes; then
218         EMACS_cv_ACCEPTABLE_W3=yes
219 else
220         EMACS_cv_ACCEPTABLE_W3=
221 fi
222
223 if test "${EMACS_cv_ACCEPTABLE_W3}" = yes; then
224         AC_EMACS_LISP(w3_dir,(file-name-directory (locate-library \"w3-forms\")),"noecho")
225         EMACS_cv_ACCEPTABLE_W3=$EMACS_cv_SYS_w3_dir
226 fi
227 ])
228    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` ])
229    W3=${EMACS_cv_ACCEPTABLE_W3}
230    AC_SUBST(W3)
231    if test -z "${EMACS_cv_ACCEPTABLE_W3}"; then
232         AC_MSG_RESULT(not found)
233    else
234         AC_MSG_RESULT(${W3})
235    fi
236 ])
237
238 dnl
239 dnl Perform sanity checking and try to locate the W3 package
240 dnl
241 AC_DEFUN(AC_CHECK_URL, [
242 AC_MSG_CHECKING(for acceptable URL version)
243
244 dnl Ignore cache.
245 unset EMACS_cv_ACCEPTABLE_URL;
246 unset EMACS_cv_SYS_url_dir;
247 unset EMACS_cv_SYS_url;
248
249 AC_CACHE_VAL(EMACS_cv_ACCEPTABLE_URL,[
250 AC_EMACS_CHECK_LIB(url, url-retrieve, "noecho")
251 if test "${HAVE_url}" = yes; then
252         EMACS_cv_ACCEPTABLE_URL=yes
253 else
254         EMACS_cv_ACCEPTABLE_URL=
255 fi
256
257 if test "${EMACS_cv_ACCEPTABLE_URL}" = yes; then
258         AC_EMACS_LISP(url_dir,(file-name-directory (locate-library \"url\")),"noecho")
259         EMACS_cv_ACCEPTABLE_URL=$EMACS_cv_SYS_url_dir
260 fi
261 ])
262    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` ])
263    URL=${EMACS_cv_ACCEPTABLE_URL}
264    AC_SUBST(URL)
265    if test -z "${EMACS_cv_ACCEPTABLE_URL}"; then
266         AC_MSG_RESULT(not found)
267    else
268         AC_MSG_RESULT("${URL}")
269    fi
270 ])
271
272 dnl
273 dnl Perform checking available fonts: Adobe Bembo, Adobe Futura and 
274 dnl Bitstream Courier.
275 dnl
276
277 AC_DEFUN(GNUS_CHECK_FONTS, [
278 test "$LATEX" = t && LATEX=
279 test "$LATEX" || AC_PATH_PROGS(LATEX, latex, no)
280 AC_MSG_CHECKING(for available fonts)
281 AC_ARG_WITH(fonts,[  --with-fonts            Assume all fonts required are available],[USE_FONTS="$withval"])
282 WITH_FONTS_bembo='%'
283 WITHOUT_FONTS_bembo=
284 WITH_FONTS_pfu='%'
285 WITHOUT_FONTS_pfu=
286 WITH_FONTS_bcr='%'
287 WITHOUT_FONTS_bcr=
288 if test -z "${USE_FONTS}"; then
289   if test "${LATEX}" = no; then
290         :
291   else
292     OUTPUT=./conftest-$$
293     echo '\nonstopmode\documentclass{article}\usepackage{bembo}\begin{document}\end{document}' > ${OUTPUT}
294     if ${LATEX} ${OUTPUT} </dev/null >& AC_FD_CC 2>&1  ; then  
295       if test -z "${USE_FONTS}"; then
296         USE_FONTS="Adobe Bembo"
297       else
298         USE_FONTS="${USE_FONTS}, Adobe Bembo"
299       fi
300       WITH_FONTS_bembo=
301       WITHOUT_FONTS_bembo='%'
302     fi
303     echo '\nonstopmode\documentclass{article}\begin{document}{\fontfamily{pfu}\fontsize{10pt}{10}\selectfont test}\end{document}' > ${OUTPUT}
304     if retval=`${LATEX} ${OUTPUT} </dev/null 2>& AC_FD_CC`; then
305       if echo "$retval" | grep 'Some font shapes were not available' >& AC_FD_CC 2>&1  ; then  
306         :
307       else
308          if test -z "${USE_FONTS}"; then
309           USE_FONTS="Adobe Futura"
310          else
311           USE_FONTS="${USE_FONTS}, Adobe Futura"
312          fi
313          WITH_FONTS_pfu=
314          WITHOUT_FONTS_pfu='%'
315       fi
316     fi
317     echo '\nonstopmode\documentclass{article}\begin{document}{\fontfamily{bcr}\fontsize{10pt}{10}\selectfont test}\end{document}' > ${OUTPUT}
318     if retval=`${LATEX} ${OUTPUT} </dev/null 2>& AC_FD_CC`; then
319       if echo "$retval" | grep 'Some font shapes were not available' >& AC_FD_CC 2>&1  ; then  
320         :
321       else
322          if test -z "${USE_FONTS}"; then
323           USE_FONTS="Bitstream Courier"
324          else
325           USE_FONTS="${USE_FONTS}, Bitstream Courier"
326          fi
327          WITH_FONTS_bcr=
328          WITHOUT_FONTS_bcr='%'
329       fi
330     fi
331     rm -f ${OUTPUT} ${OUTPUT}.aux ${OUTPUT}.log ${OUTPUT}.dvi
332   fi
333 elif test "${USE_FONTS}" = yes ; then
334   WITH_FONTS_bembo=
335   WITHOUT_FONTS_bembo='%'
336   WITH_FONTS_pfu=
337   WITHOUT_FONTS_pfu='%'
338   WITH_FONTS_bcr=
339   WITHOUT_FONTS_bcr='%'
340 fi
341 AC_SUBST(WITH_FONTS_bembo)
342 AC_SUBST(WITHOUT_FONTS_bembo)
343 AC_SUBST(WITH_FONTS_pfu)
344 AC_SUBST(WITHOUT_FONTS_pfu)
345 AC_SUBST(WITH_FONTS_bcr)
346 AC_SUBST(WITHOUT_FONTS_bcr)
347 if test -z "${USE_FONTS}" ; then
348   USE_FONTS=no
349 fi
350 USE_FONTS=`echo "${USE_FONTS}" | sed 's/,\([[^,]]*\)$/ and\1/'`
351 AC_MSG_RESULT("${USE_FONTS}")
352 if test "${USE_FONTS}" = yes ; then
353   USE_FONTS='Set in Adobe Bembo, Adobe Futura and Bitstream Courier.'
354 elif test "${USE_FONTS}" = no ; then
355   USE_FONTS=''
356 else
357   USE_FONTS="Set in ${USE_FONTS}."
358 fi
359 AC_SUBST(USE_FONTS)
360 ])
361
362 AC_DEFUN(AC_EXAMINE_PACKAGEDIR,
363  [dnl Examine PACKAGEDIR.
364   AC_EMACS_LISP(PACKAGEDIR,
365     (let (package-dir)\
366       (if (boundp (quote early-packages))\
367           (let ((dirs (delq nil (append (if early-package-load-path\
368                                             early-packages)\
369                                         (if late-package-load-path\
370                                             late-packages)\
371                                         (if last-package-load-path\
372                                             last-packages)))))\
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)])