Merge branch 'maint'
[platform/upstream/automake.git] / m4 / lispdir.m4
1 ## ------------------------                                 -*- Autoconf -*-
2 ## Emacs LISP file handling
3 ## From Ulrich Drepper
4 ## Almost entirely rewritten by Alexandre Oliva
5 ## ------------------------
6 # Copyright (C) 1996-2012 Free Software Foundation, Inc.
7 #
8 # This file is free software; the Free Software Foundation
9 # gives unlimited permission to copy and/or distribute it,
10 # with or without modifications, as long as this notice is preserved.
11
12 # serial 12
13
14 # AM_PATH_LISPDIR
15 # ---------------
16 AC_DEFUN([AM_PATH_LISPDIR],
17 [AC_PREREQ([2.60])dnl
18  # If set to t, that means we are running in a shell under Emacs.
19  # If you have an Emacs named "t", then use the full path.
20  test x"$EMACS" = xt && EMACS=
21  AC_CHECK_PROGS([EMACS], [emacs xemacs], [no])
22  AC_ARG_VAR([EMACS], [the Emacs editor command])
23  AC_ARG_VAR([EMACSLOADPATH], [the Emacs library search path])
24  AC_ARG_WITH([lispdir],
25  [AS_HELP_STRING([--with-lispdir],
26                  [override the default lisp directory])],
27  [ lispdir="$withval"
28    AC_MSG_CHECKING([where .elc files should go])
29    AC_MSG_RESULT([$lispdir])],
30  [
31  AC_CACHE_CHECK([where .elc files should go], [am_cv_lispdir], [
32    if test $EMACS != "no"; then
33      if test x${lispdir+set} != xset; then
34   # If $EMACS isn't GNU Emacs or XEmacs, this can blow up pretty badly
35   # Some emacsen will start up in interactive mode, requiring C-x C-c to exit,
36   #  which is non-obvious for non-emacs users.
37   # Redirecting /dev/null should help a bit; pity we can't detect "broken"
38   #  emacsen earlier and avoid running this altogether.
39   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])
40         am_cv_lispdir=`sed -n \
41        -e 's,/$,,' \
42        -e '/.*\/lib\/x*emacs\/site-lisp$/{s,.*/lib/\(x*emacs/site-lisp\)$,${libdir}/\1,;p;q;}' \
43        -e '/.*\/share\/x*emacs\/site-lisp$/{s,.*/share/\(x*emacs/site-lisp\),${datarootdir}/\1,;p;q;}' \
44        conftest.out`
45        rm conftest.out
46      fi
47    fi
48    test -z "$am_cv_lispdir" && am_cv_lispdir='${datadir}/emacs/site-lisp'
49   ])
50   lispdir="$am_cv_lispdir"
51 ])
52 AC_SUBST([lispdir])
53 ])# AM_PATH_LISPDIR