* mixi-utils.el: New file.
[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(for 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 AC_DEFUN([AC_EXAMINE_PACKAGEDIR],
146  [dnl Examine PACKAGEDIR.
147   AC_EMACS_LISP(PACKAGEDIR,
148     (let (package-dir)\
149       (if (boundp (quote early-packages))\
150           (let ((dirs (delq nil (append (if early-package-load-path\
151                                             early-packages)\
152                                         (if late-package-load-path\
153                                             late-packages)\
154                                         (if last-package-load-path\
155                                             last-packages)))))\
156             (while (and dirs (not package-dir))\
157               (if (file-directory-p (car dirs))\
158                   (setq package-dir (car dirs)\
159                         dirs (cdr dirs))))))\
160       (or package-dir \"\")),
161     "noecho")])
162
163 AC_DEFUN([AC_PATH_PACKAGEDIR],
164  [dnl Check for PACKAGEDIR.
165   if test ${EMACS_FLAVOR} = xemacs; then
166     AC_MSG_CHECKING([where the XEmacs package is])
167     AC_ARG_WITH(packagedir,
168       [  --with-packagedir=DIR   package DIR for XEmacs],
169       [if test "$withval" != yes -a -n "$withval"; then
170         PACKAGEDIR=$withval
171       else
172         AC_EXAMINE_PACKAGEDIR
173       fi],
174       AC_EXAMINE_PACKAGEDIR)
175     if test -z "$PACKAGEDIR"; then
176       AC_MSG_RESULT(not found)
177     else
178       AC_MSG_RESULT($PACKAGEDIR)
179     fi
180   else
181     PACKAGEDIR=
182   fi
183   AC_SUBST(PACKAGEDIR)])
184
185 AC_DEFUN([AC_ADD_LOAD_PATH],
186  [dnl Check for additional load path.
187   AC_ARG_WITH(addpath,
188    [  --with-addpath=PATH     search Emacs-Lisp libraries with PATH
189                           use colons to separate directory names],
190    [if test "$withval" != yes -a -n "$withval"; then
191       AC_MSG_CHECKING([where to find the additional elisp libraries])
192       ADDITIONAL_LOAD_PATH=$withval
193       AC_MSG_RESULT($ADDITIONAL_LOAD_PATH)
194     fi],
195     ADDITIONAL_LOAD_PATH=)
196   AC_SUBST(ADDITIONAL_LOAD_PATH)])
197