(riece-log-display-message-function): Use
[elisp/riece.git] / acinclude.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 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     lispdir="\$(datadir)/${EMACS_FLAVOR}/site-lisp/${GNUS_PRODUCT_NAME}"
99     for thedir in share lib; do
100         potential=
101         if test -d ${theprefix}/${thedir}/${EMACS_FLAVOR}/site-lisp; then
102            lispdir="\$(prefix)/${thedir}/${EMACS_FLAVOR}/site-lisp/${GNUS_PRODUCT_NAME}"
103            break
104         fi
105     done
106   fi
107   if test ${EMACS_FLAVOR} = xemacs; then
108     AC_MSG_RESULT([$lispdir
109          (it will be ignored when \"make install-package[[-ja]]\" is done)])
110   else
111     AC_MSG_RESULT([$lispdir])
112   fi
113   AC_SUBST(lispdir)
114 ])
115
116 AC_DEFUN([AC_PATH_ETCDIR], [
117   AC_ARG_WITH(etcdir,[  --with-etcdir=DIR       Where to install etc files], etcdir=${withval})
118   AC_MSG_CHECKING([where etc files should go])
119   if test -z "$etcdir"; then
120     dnl Set default value
121     etcdir="\$(lispdir)/../etc"
122   fi
123   AC_MSG_RESULT($etcdir)
124   AC_SUBST(etcdir)
125 ])
126
127 dnl
128 dnl Check whether a function exists in a library
129 dnl All '_' characters in the first argument are converted to '-'
130 dnl
131 AC_DEFUN([AC_EMACS_CHECK_LIB], [
132 if test -z "$3"; then
133         AC_MSG_CHECKING(for $2 in $1)
134 fi
135 library=`echo $1 | tr _ -`
136 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")
137 if test "${EMACS_cv_SYS_$1}" = nil; then
138         EMACS_cv_SYS_$1=no
139 fi
140 if test "${EMACS_cv_SYS_$1}" = t; then
141         EMACS_cv_SYS_$1=yes
142 fi
143 HAVE_$1=${EMACS_cv_SYS_$1}
144 AC_SUBST(HAVE_$1)
145 if test -z "$3"; then
146         AC_MSG_RESULT($HAVE_$1)
147 fi
148 ])
149
150 dnl
151 dnl Perform sanity checking and try to locate the W3 package
152 dnl
153 AC_DEFUN([AC_CHECK_W3], [
154 AC_MSG_CHECKING(for acceptable W3 version)
155
156 dnl Ignore cache.
157 unset EMACS_cv_ACCEPTABLE_W3;
158 unset EMACS_cv_SYS_w3_dir;
159 unset EMACS_cv_SYS_w3_forms;
160
161 AC_CACHE_VAL(EMACS_cv_ACCEPTABLE_W3,[
162 AC_EMACS_CHECK_LIB(w3_forms, w3-form-encode-xwfu,"noecho")
163 if test "${HAVE_w3_forms}" = yes; then
164         EMACS_cv_ACCEPTABLE_W3=yes
165 else
166         EMACS_cv_ACCEPTABLE_W3=
167 fi
168
169 if test "${EMACS_cv_ACCEPTABLE_W3}" = yes; then
170         AC_EMACS_LISP(w3_dir,(file-name-directory (locate-library \"w3-forms\")),"noecho")
171         EMACS_cv_ACCEPTABLE_W3=$EMACS_cv_SYS_w3_dir
172 fi
173 ])
174    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` ])
175    W3=${EMACS_cv_ACCEPTABLE_W3}
176    AC_SUBST(W3)
177    if test -z "${EMACS_cv_ACCEPTABLE_W3}"; then
178         AC_MSG_RESULT(not found)
179    else
180         AC_MSG_RESULT(${W3})
181    fi
182 ])
183
184 dnl
185 dnl Perform sanity checking and try to locate the W3 package
186 dnl
187 AC_DEFUN([AC_CHECK_URL], [
188 AC_MSG_CHECKING(for acceptable URL version)
189
190 dnl Ignore cache.
191 unset EMACS_cv_ACCEPTABLE_URL;
192 unset EMACS_cv_SYS_url_dir;
193 unset EMACS_cv_SYS_url;
194
195 AC_CACHE_VAL(EMACS_cv_ACCEPTABLE_URL,[
196 AC_EMACS_CHECK_LIB(url, url-retrieve, "noecho")
197 if test "${HAVE_url}" = yes; then
198         EMACS_cv_ACCEPTABLE_URL=yes
199 else
200         EMACS_cv_ACCEPTABLE_URL=
201 fi
202
203 if test "${EMACS_cv_ACCEPTABLE_URL}" = yes; then
204         AC_EMACS_LISP(url_dir,(file-name-directory (locate-library \"url\")),"noecho")
205         EMACS_cv_ACCEPTABLE_URL=$EMACS_cv_SYS_url_dir
206 fi
207 ])
208    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` ])
209    URL=${EMACS_cv_ACCEPTABLE_URL}
210    AC_SUBST(URL)
211    if test -z "${EMACS_cv_ACCEPTABLE_URL}"; then
212         AC_MSG_RESULT(not found)
213    else
214         AC_MSG_RESULT("${URL}")
215    fi
216 ])
217
218 dnl
219 dnl Perform checking available fonts: Adobe Bembo, Adobe Futura and 
220 dnl Bitstream Courier.
221 dnl
222
223 AC_DEFUN([GNUS_CHECK_FONTS], [
224 test "$LATEX" = t && LATEX=
225 test "$LATEX" || AC_PATH_PROGS(LATEX, latex, no)
226 AC_MSG_CHECKING(for available fonts)
227 AC_ARG_WITH(fonts,[  --with-fonts            Assume all fonts required are available],[USE_FONTS="$withval"])
228 WITH_FONTS_bembo='%'
229 WITHOUT_FONTS_bembo=
230 WITH_FONTS_pfu='%'
231 WITHOUT_FONTS_pfu=
232 WITH_FONTS_bcr='%'
233 WITHOUT_FONTS_bcr=
234 if test -z "${USE_FONTS}"; then
235   if test "${LATEX}" = no; then
236         :
237   else
238     OUTPUT=./conftest-$$
239     echo '\nonstopmode\documentclass{article}\usepackage{bembo}\begin{document}\end{document}' > ${OUTPUT}
240     if ${LATEX} ${OUTPUT} </dev/null >& AC_FD_CC 2>&1  ; then  
241       if test -z "${USE_FONTS}"; then
242         USE_FONTS="Adobe Bembo"
243       else
244         USE_FONTS="${USE_FONTS}, Adobe Bembo"
245       fi
246       WITH_FONTS_bembo=
247       WITHOUT_FONTS_bembo='%'
248     fi
249     echo '\nonstopmode\documentclass{article}\begin{document}{\fontfamily{pfu}\fontsize{10pt}{10}\selectfont test}\end{document}' > ${OUTPUT}
250     if retval=`${LATEX} ${OUTPUT} </dev/null 2>& AC_FD_CC`; then
251       if echo "$retval" | grep 'Some font shapes were not available' >& AC_FD_CC 2>&1  ; then  
252         :
253       else
254         if test -z "${USE_FONTS}"; then
255           USE_FONTS="Adobe Futura"
256         else
257           USE_FONTS="${USE_FONTS}, Adobe Futura"
258         fi
259         WITH_FONTS_pfu=
260         WITHOUT_FONTS_pfu='%'
261       fi
262     fi
263     echo '\nonstopmode\documentclass{article}\begin{document}{\fontfamily{bcr}\fontsize{10pt}{10}\selectfont test}\end{document}' > ${OUTPUT}
264     if retval=`${LATEX} ${OUTPUT} </dev/null 2>& AC_FD_CC`; then
265       if echo "$retval" | grep 'Some font shapes were not available' >& AC_FD_CC 2>&1  ; then  
266         :
267       else
268         if test -z "${USE_FONTS}"; then
269           USE_FONTS="Bitstream Courier"
270         else
271           USE_FONTS="${USE_FONTS}, Bitstream Courier"
272         fi
273         WITH_FONTS_bcr=
274         WITHOUT_FONTS_bcr='%'
275       fi
276     fi
277     rm -f ${OUTPUT} ${OUTPUT}.aux ${OUTPUT}.log ${OUTPUT}.dvi
278   fi
279 elif test "${USE_FONTS}" = yes ; then
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 fi
287 AC_SUBST(WITH_FONTS_bembo)
288 AC_SUBST(WITHOUT_FONTS_bembo)
289 AC_SUBST(WITH_FONTS_pfu)
290 AC_SUBST(WITHOUT_FONTS_pfu)
291 AC_SUBST(WITH_FONTS_bcr)
292 AC_SUBST(WITHOUT_FONTS_bcr)
293 if test -z "${USE_FONTS}" ; then
294   USE_FONTS=no
295 fi
296 USE_FONTS=`echo "${USE_FONTS}" | sed 's/,\([[^,]]*\)$/ and\1/'`
297 AC_MSG_RESULT("${USE_FONTS}")
298 if test "${USE_FONTS}" = yes ; then
299   USE_FONTS='Set in Adobe Bembo, Adobe Futura and Bitstream Courier.'
300 elif test "${USE_FONTS}" = no ; then
301   USE_FONTS=''
302 else
303   USE_FONTS="Set in ${USE_FONTS}."
304 fi
305 AC_SUBST(USE_FONTS)
306 ])
307
308 AC_DEFUN([AC_EXAMINE_PACKAGEDIR],
309  [dnl Examine PACKAGEDIR.
310   AC_EMACS_LISP(PACKAGEDIR,
311     (let (package-dir)\
312       (if (boundp (quote early-packages))\
313           (let ((dirs (delq nil (append (if early-package-load-path\
314                                             early-packages)\
315                                         (if late-package-load-path\
316                                             late-packages)\
317                                         (if last-package-load-path\
318                                             last-packages)))))\
319             (while (and dirs (not package-dir))\
320               (if (file-directory-p (car dirs))\
321                   (setq package-dir (car dirs)\
322                         dirs (cdr dirs))))))\
323       (or package-dir \"\")),
324     "noecho")])
325
326 AC_DEFUN([AC_PATH_PACKAGEDIR],
327  [dnl Check for PACKAGEDIR.
328   if test ${EMACS_FLAVOR} = xemacs; then
329     AC_MSG_CHECKING([where the XEmacs package is])
330     AC_ARG_WITH(packagedir,
331       [  --with-packagedir=DIR   package DIR for XEmacs],
332       [if test "$withval" != yes -a -n "$withval"; then
333         PACKAGEDIR=$withval
334       else
335         AC_EXAMINE_PACKAGEDIR
336       fi],
337       AC_EXAMINE_PACKAGEDIR)
338     if test -z "$PACKAGEDIR"; then
339       AC_MSG_RESULT(not found)
340     else
341       AC_MSG_RESULT($PACKAGEDIR)
342     fi
343   else
344     PACKAGEDIR=
345   fi
346   AC_SUBST(PACKAGEDIR)])
347
348 AC_DEFUN([AC_ADD_LOAD_PATH],
349  [dnl Check for additional load path.
350   AC_ARG_WITH(addpath,
351    [  --with-addpath=PATH     search Emacs-Lisp libraries with PATH
352                           use colons to separate directory names],
353    [if test "$withval" != yes -a -n "$withval"; then
354       AC_MSG_CHECKING([where to find the additional elisp libraries])
355       ADDITIONAL_LOAD_PATH=$withval
356       AC_MSG_RESULT($ADDITIONAL_LOAD_PATH)
357     fi],
358     ADDITIONAL_LOAD_PATH=)
359   AC_SUBST(ADDITIONAL_LOAD_PATH)])