* tests/instsh.test: Do not reset $ACLOCAL and $AUTOMAKE now
[automake.git] / m4 / lispdir.m4
blob5ef871731a2aca7c9d4a1d72e93b63da51d7ee93
1 ## ------------------------                           -*- Autoconf -*-
2 ## Emacs LISP file handling
3 ## From Ulrich Drepper
4 ## Almost entirely rewritten by Alexandre Oliva
5 ## ------------------------
7 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
8 # Free Software Foundation, Inc.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
13 # any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 # 02111-1307, USA.
25 # serial 7
27 # AM_PATH_LISPDIR
28 # ---------------
29 AC_DEFUN([AM_PATH_LISPDIR],
30 [AC_ARG_WITH([lispdir],
31  [  --with-lispdir          Override the default lisp directory ],
32  [ lispdir="$withval"
33    AC_MSG_CHECKING([where .elc files should go])
34    AC_MSG_RESULT([$lispdir])],
35  [
36  # If set to t, that means we are running in a shell under Emacs.
37  # If you have an Emacs named "t", then use the full path.
38  test x"$EMACS" = xt && EMACS=
39  AC_CHECK_PROGS([EMACS], [emacs xemacs], [no])
40  AC_ARG_VAR([EMACS], [the Emacs editor command])
41  AC_ARG_VAR([EMACSLOADPATH], [the Emacs library search path])
42  if test $EMACS != "no"; then
43    if test x${lispdir+set} != xset; then
44      AC_CACHE_CHECK([where .elc files should go], [am_cv_lispdir],
45        [# If $EMACS isn't GNU Emacs or XEmacs, this can blow up pretty badly
46   # Some emacsen will start up in interactive mode, requiring C-x C-c to exit,
47   #  which is non-obvious for non-emacs users.
48   # Redirecting /dev/null should help a bit; pity we can't detect "broken"
49   #  emacsen earlier and avoid running this altogether.
50   AC_RUN_LOG([$EMACS -batch -q -eval '(while load-path (princ (concat (car load-path) "\n")) (setq load-path (cdr load-path)))' </dev/null >conftest.out])
51         am_cv_lispdir=`sed -n \
52        -e 's,/$,,' \
53        -e '/.*\/lib\/x\?emacs\/site-lisp$/{s,.*/lib/\(x\?emacs/site-lisp\)$,${libdir}/\1,;p;q;}' \
54        -e '/.*\/share\/x\?emacs\/site-lisp$/{s,.*/share/\(x\?emacs/site-lisp\),${datadir}/\1,;p;q;}' \
55        conftest.out`
56        rm conftest.out
57        if test -z "$am_cv_lispdir"; then
58          am_cv_lispdir='${datadir}/emacs/site-lisp'
59        fi
60      ])
61      lispdir="$am_cv_lispdir"
62    fi
63  fi
65 AC_SUBST([lispdir])
66 ])# AM_PATH_LISPDIR
68 AU_DEFUN([ud_PATH_LISPDIR], [AM_PATH_LISPDIR])