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