Fix docs.
[elisp/mixi.git] / acinclude.m4
1 AC_DEFUN([AC_CHECK_EMACS],
2  [dnl Check for Emacsen.
3
4   dnl Apparently, if you run a shell window in Emacs, it sets the EMACS
5   dnl environment variable to 't'.  Lets undo the damage.
6   test "$EMACS" = t && EMACS=
7
8   dnl Ignore cache.
9   unset ac_cv_prog_EMACS; unset ac_cv_prog_XEMACS;
10
11   AC_ARG_WITH(emacs,
12    [  --with-emacs=EMACS      compile with EMACS [EMACS=emacs, mule...]],
13    [if test "$withval" = yes -o -z "$withval"; then
14       AC_CHECK_PROGS(EMACS, emacs xemacs mule, emacs)
15     else
16       AC_CHECK_PROG(EMACS, $withval, $withval, emacs)
17     fi])
18   AC_ARG_WITH(xemacs,
19    [  --with-xemacs=XEMACS    compile with XEMACS [XEMACS=xemacs]],
20    [if test "$withval" = yes -o -z "$withval"; then
21       AC_CHECK_PROG(XEMACS, xemacs, xemacs, xemacs)
22     else
23       AC_CHECK_PROG(XEMACS, $withval, $withval, xemacs)
24     fi
25     EMACS=$XEMACS],
26    [XEMACS=xemacs
27     test -z "$EMACS" && AC_CHECK_PROGS(EMACS, emacs xemacs mule, emacs)])
28   AC_SUBST(EMACS)
29   AC_SUBST(XEMACS)])
30
31 AC_DEFUN([AC_EMACS_LISP], [
32 elisp="$2"
33 if test -z "$3"; then
34         AC_MSG_CHECKING(for $1)
35 fi
36 AC_CACHE_VAL(EMACS_cv_SYS_$1,[
37         OUTPUT=./conftest-$$
38         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
39         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
40         if test -f ${OUTPUT}; then
41                 retval=`cat ${OUTPUT}`
42                 echo "=> ${retval}" >& AC_FD_CC 2>&1
43                 rm -f ${OUTPUT}
44                 EMACS_cv_SYS_$1=$retval
45         else
46                 EMACS_cv_SYS_$1=
47         fi
48 ])
49 $1=${EMACS_cv_SYS_$1}
50 if test -z "$3"; then
51         AC_MSG_RESULT($$1)
52 fi
53 ])
54
55 AC_DEFUN([AC_CHECK_EMACS_FLAVOR],
56  [AC_MSG_CHECKING([what flavor does $EMACS have])
57
58   dnl Ignore cache.
59   unset EMACS_cv_SYS_flavor;
60
61   AC_EMACS_LISP(flavor,
62     (cond ((featurep (quote xemacs)) \"XEmacs\")\
63           ((boundp (quote MULE)) \"MULE\")\
64           (t \"FSF Emacs\")),
65     "noecho")
66   case $EMACS_cv_SYS_flavor in
67   XEmacs)
68     EMACS_FLAVOR=xemacs;;
69   MULE)
70     EMACS_FLAVOR=mule;;
71   *)
72     EMACS_FLAVOR=emacs;;
73   esac
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     lispdir="\$(datadir)/${EMACS_FLAVOR}/site-lis"
96     for thedir in share lib; do
97         potential=
98         if test -d ${theprefix}/${thedir}/${EMACS_FLAVOR}/site-lisp; then
99            lispdir="\$(prefix)/${thedir}/${EMACS_FLAVOR}/site-lisp"
100            break
101         fi
102     done
103   fi
104   if test ${EMACS_FLAVOR} = xemacs; then
105     AC_MSG_RESULT([$lispdir
106          (it will be ignored when \"make install-package[[-ja]]\" is done)])
107   else
108     AC_MSG_RESULT([$lispdir])
109   fi
110   AC_SUBST(lispdir)
111 ])
112
113 dnl
114 dnl Perform sanity checking and try to locate the Shimbun package
115 dnl
116 AC_DEFUN([AC_CHECK_SHIMBUN], [
117   AC_MSG_CHECKING(have shimbun)
118
119   dnl Ignore cache.
120   unset EMACS_cv_SYS_shimbun_dir;
121
122   AC_ARG_WITH(shimbun,[  --with-shimbun[[=ARG]]    Use shimbun [[ARG=yes]]],
123     [if test "$withval" = yes -o -z "$withval"; then
124        HAVE_SHIMBUN=yes
125      else
126        HAVE_SHIMBUN=$withval
127      fi], HAVE_SHIMBUN=yes)
128   AC_SUBST(HAVE_SHIMBUN)
129
130   if test "${HAVE_SHIMBUN}" = yes; then
131     AC_EMACS_LISP(shimbun_dir,(file-name-directory (locate-library \"shimbun\")),"noecho")
132     SHIMBUN_DIR=$EMACS_cv_SYS_shimbun_dir
133   fi
134
135   if test "${HAVE_SHIMBUN}" != yes; then
136     AC_MSG_RESULT(no)
137   elif test -z "${SHIMBUN_DIR}"; then
138     HAVE_SHIMBUN=no
139     AC_MSG_RESULT(not found)
140   else
141     AC_MSG_RESULT(${HAVE_SHIMBUN})
142  fi
143 ])
144
145 dnl
146 dnl Perform sanity checking and try to locate the Riece package
147 dnl
148 AC_DEFUN([AC_CHECK_RIECE], [
149   AC_MSG_CHECKING(have riece)
150
151   dnl Ignore cache.
152   unset EMACS_cv_SYS_riece_dir;
153
154   AC_ARG_WITH(riece,[  --with-riece[[=ARG]]      Use riece [[ARG=yes]]],
155     [if test "$withval" = yes -o -z "$withval"; then
156        HAVE_RIECE=yes
157      else
158        HAVE_RIECE=$withval
159      fi], HAVE_RIECE=yes)
160   AC_SUBST(HAVE_RIECE)
161
162   if test "${HAVE_RIECE}" = yes; then
163     AC_EMACS_LISP(riece_dir,(file-name-directory (locate-library \"riece\")),"noecho")
164     RIECE_DIR=$EMACS_cv_SYS_riece_dir
165   fi
166
167   if test "${HAVE_RIECE}" != yes; then
168     AC_MSG_RESULT(no)
169   elif test -z "${RIECE_DIR}"; then
170     HAVE_RIECE=no
171     AC_MSG_RESULT(not found)
172   else
173     AC_MSG_RESULT(${HAVE_RIECE})
174  fi
175 ])
176
177 AC_DEFUN([AC_EXAMINE_PACKAGEDIR],
178  [dnl Examine PACKAGEDIR.
179   AC_EMACS_LISP(PACKAGEDIR,
180     (let (package-dir)\
181       (if (boundp (quote early-packages))\
182           (let ((dirs (delq nil (append (if early-package-load-path\
183                                             early-packages)\
184                                         (if late-package-load-path\
185                                             late-packages)\
186                                         (if last-package-load-path\
187                                             last-packages)))))\
188             (while (and dirs (not package-dir))\
189               (if (file-directory-p (car dirs))\
190                   (setq package-dir (car dirs)\
191                         dirs (cdr dirs))))))\
192       (or package-dir \"\")),
193     "noecho")])
194
195 AC_DEFUN([AC_PATH_PACKAGEDIR],
196  [dnl Check for PACKAGEDIR.
197   if test ${EMACS_FLAVOR} = xemacs; then
198     AC_MSG_CHECKING([where the XEmacs package is])
199     AC_ARG_WITH(packagedir,
200       [  --with-packagedir=DIR   package DIR for XEmacs],
201       [if test "$withval" != yes -a -n "$withval"; then
202         PACKAGEDIR=$withval
203       else
204         AC_EXAMINE_PACKAGEDIR
205       fi],
206       AC_EXAMINE_PACKAGEDIR)
207     if test -z "$PACKAGEDIR"; then
208       AC_MSG_RESULT(not found)
209     else
210       AC_MSG_RESULT($PACKAGEDIR)
211     fi
212   else
213     PACKAGEDIR=
214   fi
215   AC_SUBST(PACKAGEDIR)])
216
217 AC_DEFUN([AC_ADD_LOAD_PATH],
218  [dnl Check for additional load path.
219   AC_ARG_WITH(addpath,
220    [  --with-addpath=PATH     search Emacs-Lisp libraries with PATH
221                           use colons to separate directory names],
222    [if test "$withval" != yes -a -n "$withval"; then
223       AC_MSG_CHECKING([where to find the additional elisp libraries])
224       ADDITIONAL_LOAD_PATH=$withval
225       AC_MSG_RESULT($ADDITIONAL_LOAD_PATH)
226     fi],
227     ADDITIONAL_LOAD_PATH=)
228   AC_SUBST(ADDITIONAL_LOAD_PATH)])
229