AC major changed.
[elisp/gnus.git-] / aclocal.m4
1 AC_DEFUN(AC_DEFINE_GNUS_PRODUCT_NAME,
2  [dnl Defining gnus product name.
3   GNUS_PRODUCT_NAME=$1])
4
5 AC_DEFUN(AC_CHECK_EMACS,
6  [dnl Check for Emacsen.
7   AC_ARG_WITH(emacs,
8    [  --with-emacs=EMACS      compile with EMACS [EMACS=emacs, mule...]],
9    [if test x$withval = xyes -o x$withval = xt -o x$withval = x; then
10       AC_CHECK_PROGS(EMACS, emacs xemacs mule, emacs)
11     else
12       AC_CHECK_PROG(EMACS, $withval, $withval, emacs)
13     fi])
14   AC_ARG_WITH(xemacs,
15    [  --with-xemacs=XEMACS    compile with XEMACS [XEMACS=xemacs]],
16    [if test x$withval = xyes -o x$withval = x; then
17       AC_CHECK_PROG(XEMACS, xemacs, xemacs, xemacs)
18     else
19       AC_CHECK_PROG(XEMACS, $withval, $withval, xemacs)
20     fi
21     EMACS=$XEMACS],
22    [XEMACS=xemacs
23     test x$EMACS = xt -o x$EMACS = x &&\
24       AC_CHECK_PROGS(EMACS, emacs xemacs mule, emacs)])
25   AC_SUBST(EMACS)
26   AC_SUBST(XEMACS)])
27
28 AC_DEFUN(AC_EMACS_LISP, [
29 elisp="$2"
30 if test -z "$3"; then
31         AC_MSG_CHECKING(for $1)
32 fi
33 AC_CACHE_VAL(EMACS_cv_SYS_$1,[
34         OUTPUT=./conftest-$$
35         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
36         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
37         retval=`cat ${OUTPUT}`
38         echo "=> ${retval}" >& AC_FD_CC 2>&1
39         rm -f ${OUTPUT}
40         EMACS_cv_SYS_$1=$retval
41 ])
42 $1=${EMACS_cv_SYS_$1}
43 if test -z "$3"; then
44         AC_MSG_RESULT($$1)
45 fi
46 ])
47
48 AC_DEFUN(AC_CHECK_EMACS_FLAVOR,
49  [AC_MSG_CHECKING([what a flavor does $EMACS have])
50   AC_EMACS_LISP(flavor,
51     (cond ((featurep (quote xemacs)) \"XEmacs\")\
52           ((boundp (quote MULE)) \"MULE\")\
53           (t \"FSF Emacs\")),
54     "noecho")
55   case $EMACS_cv_SYS_flavor in
56   XEmacs)
57     EMACS_FLAVOR=xemacs;;
58   MULE)
59     EMACS_FLAVOR=mule;;
60   *)
61     EMACS_FLAVOR=emacs;;
62   esac
63   AC_MSG_RESULT($EMACS_cv_SYS_flavor)])
64
65 AC_DEFUN(AC_PATH_LISPDIR, [
66   AC_CHECK_EMACS_FLAVOR
67   if test "$prefix" = "NONE"; then
68         AC_MSG_CHECKING([prefix for your Emacs])
69         AC_EMACS_LISP(prefix,(expand-file-name \"..\" invocation-directory),"noecho")
70         prefix=${EMACS_cv_SYS_prefix}
71         AC_MSG_RESULT($prefix)
72   fi
73   AC_ARG_WITH(lispdir,
74     [  --with-lispdir=DIR      Where to install lisp files
75                           (for XEmacs package, use --with-packagedir instead)],
76     lispdir=${withval})
77   AC_MSG_CHECKING([where lisp files should go])
78   if test -z "$lispdir"; then
79     dnl Set default value
80     theprefix=$prefix
81     if test "x$theprefix" = "xNONE"; then
82         theprefix=$ac_default_prefix
83     fi
84     lispdir="\$(datadir)/${EMACS_FLAVOR}/site-lisp/${GNUS_PRODUCT_NAME}"
85     for thedir in share lib; do
86         potential=
87         if test -d ${theprefix}/${thedir}/${EMACS_FLAVOR}/site-lisp; then
88            lispdir="\$(prefix)/${thedir}/${EMACS_FLAVOR}/site-lisp/${GNUS_PRODUCT_NAME}"
89            break
90         fi
91     done
92   fi
93   AC_MSG_RESULT([$lispdir
94          (it will be ignored when \"make install-package[[-ja]]\" is done)])
95   AC_SUBST(lispdir)
96 ])
97
98 dnl
99 dnl Check whether a function exists in a library
100 dnl All '_' characters in the first argument are converted to '-'
101 dnl
102 AC_DEFUN(AC_EMACS_CHECK_LIB, [
103 if test -z "$3"; then
104         AC_MSG_CHECKING(for $2 in $1)
105 fi
106 library=`echo $1 | tr _ -`
107 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")
108 if test "${EMACS_cv_SYS_$1}" = "nil"; then
109         EMACS_cv_SYS_$1=no
110 fi
111 if test "${EMACS_cv_SYS_$1}" = "t"; then
112         EMACS_cv_SYS_$1=yes
113 fi
114 HAVE_$1=${EMACS_cv_SYS_$1}
115 AC_SUBST(HAVE_$1)
116 if test -z "$3"; then
117         AC_MSG_RESULT($HAVE_$1)
118 fi
119 ])
120
121 dnl
122 dnl Perform sanity checking and try to locate the W3 package
123 dnl
124 AC_DEFUN(AC_CHECK_W3, [
125 AC_MSG_CHECKING(for acceptable W3 version)
126 AC_CACHE_VAL(EMACS_cv_ACCEPTABLE_W3,[
127 AC_EMACS_CHECK_LIB(w3_forms, w3-form-encode-xwfu,"noecho")
128 if test "${HAVE_w3_forms}" = "yes"; then
129         EMACS_cv_ACCEPTABLE_W3=yes
130 else
131         EMACS_cv_ACCEPTABLE_W3=no
132 fi
133
134 if test "${EMACS_cv_ACCEPTABLE_W3}" = "yes"; then
135         AC_EMACS_LISP(w3_dir,(file-name-directory (locate-library \"w3-forms\")),"noecho")
136         EMACS_cv_ACCEPTABLE_W3=$EMACS_cv_SYS_w3_dir
137 fi
138 ])
139    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` ])
140    W3=${EMACS_cv_ACCEPTABLE_W3}
141    AC_SUBST(W3)
142    AC_MSG_RESULT("${W3}")
143 ])
144
145 AC_DEFUN(AC_PATH_PACKAGEDIR,
146  [dnl Check for PACKAGEDIR.
147   AC_ARG_WITH(packagedir,
148    [  --with-packagedir=DIR   package DIR for XEmacs],
149    [if test x$withval != xyes -a x$withval != x; then
150       AC_MSG_CHECKING([where the package should go])
151       PACKAGEDIR=$withval
152       AC_MSG_RESULT($PACKAGEDIR)
153     fi],
154     PACKAGEDIR=)
155   AC_SUBST(PACKAGEDIR)])
156
157 AC_DEFUN(AC_ADD_LOAD_PATH,
158  [dnl Check for additional load path.
159   AC_ARG_WITH(addpath,
160    [  --with-addpath=PATH     search Emacs-Lisp libraries with PATH
161                           use colons to separate directory names],
162    [if test x$withval != xyes -a x$withval != x; then
163       AC_MSG_CHECKING([where to find the additional elisp libraries])
164       ADDITIONAL_LOAD_PATH=$withval
165       AC_MSG_RESULT($ADDITIONAL_LOAD_PATH)
166     fi],
167     ADDITIONAL_LOAD_PATH=)
168   AC_SUBST(ADDITIONAL_LOAD_PATH)])