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