# serial 1 dnl this was once done by Katsumi Yamaoka , but dnl pretty much no original code remains. dnl EMACS_LISP takes 5 arguments. $1 is the name of the shell dnl variable to assign a value, $2 is a Lisp expression placed into dnl shell double quotes (which has consequences for quoting and dnl variable expansion). $3 is a list of Emacs options evaluated before dnl the expression itself, $4 is a list of Elisp variables that is dnl assigned from the command line arguments from $5. AC_DEFUN(EMACS_LISP, [ elisp="$2" OUTPUT=./conftest-$$ echo "${EMACS}" -batch $3 -eval "(let* (patsubst([$4], [\w+], [(\&(pop command-line-args-left))])(x ${elisp})) (write-region (if (stringp x) x (prin1-to-string x)) nil \"${OUTPUT}\"))" $5 >& AC_FD_CC 2>&1 "${EMACS}" -batch $3 -eval "(let* (patsubst([$4], [\w+], [(\&(pop command-line-args-left))])(x ${elisp})) (write-region (if (stringp x) x (prin1-to-string x)) nil \"${OUTPUT}\"))" $5 >& AC_FD_CC 2>&1 $1="`cat ${OUTPUT}`" echo "=> ${1}" >& AC_FD_CC 2>&1 rm -f ${OUTPUT} ]) AC_DEFUN(EMACS_PROG_EMACS, [ # Check for (X)Emacs, report its path, flavor and prefix # Apparently, if you run a shell window in Emacs, it sets the EMACS # environment variable to 't'. Let's undo the damage. if test "${EMACS}" = "t"; then EMACS="" fi AC_ARG_WITH(emacs, [ --with-emacs@<:@=PATH@:>@ Use Emacs to build (on PATH if given)], [if test "${withval}" = "yes"; then EMACS=emacs else if test "${withval}" = "no"; then EMACS=xemacs else EMACS="${withval}"; fi ; fi]) AC_ARG_WITH(xemacs, [ --with-xemacs@<:@=PATH@:>@ Use XEmacs to build (on PATH if given)], [if test "${withval}" = "yes"; then EMACS=xemacs; else if test "${withval}" = "no"; then EMACS=emacs else EMACS="${withval}"; fi ; fi]) # "${prefix}/bin" is for Windows users AC_PATH_PROGS(EMACS, ${EMACS} emacs xemacs, "", ${PATH} "${prefix}/bin" ) if test -z "${EMACS}"; then AC_MSG_ERROR([(X)Emacs not found! Aborting!]) fi AC_MSG_CHECKING([if ${EMACS} is XEmacs]) EMACS_LISP(XEMACS, [[(if (featurep (quote xemacs)) \"yes\" \"no\")]],[[-no-site-file]]) if test "${XEMACS}" = "yes"; then EMACS_FLAVOR=xemacs EMACS_NAME="XEmacs" else if test "${XEMACS}" = "no"; then EMACS_FLAVOR=emacs EMACS_NAME="Emacs" else AC_MSG_ERROR([Unable to run ${EMACS}! Aborting!]) fi fi AC_MSG_RESULT(${XEMACS}) AC_SUBST(XEMACS) AC_SUBST(EMACS_FLAVOR) AC_MSG_CHECKING([for ${EMACS_NAME} prefix]) EMACS_LISP(emacsprefix,[(expand-file-name \"..\" invocation-directory)],[-no-site-file]) AC_MSG_RESULT($emacsprefix) AC_SUBST(emacsprefix) ]) AC_DEFUN(EMACS_CHECK_VERSION, [ AC_MSG_CHECKING([if ${EMACS_NAME} is recent enough]) EMACS_LISP(result,[(cond ((< emacs-major-version $1) \"no\") ((> emacs-major-version $1) \"yes\") ((< emacs-minor-version 0$2) \"no\") (t \"yes\"))],[[-no-site-file]]) AC_MSG_RESULT([${result}]) if test "${result}" != "yes" then AC_MSG_ERROR([This package requires at least ${EMACS_NAME} version $1.$2 Aborting!]) fi ]) dnl Look for an installation directory under emacsprefix, datadir and prefix. dnl $1 is the variable name we are looking for. dnl $2 is a Lisp expression giving a list of directories names dnl $3 is Lisp expression giving a list of locations where to find them dnl $4,$5,$6 are additional arguments for the elisp call AC_DEFUN(EMACS_EXAMINE_INSTALLATION_DIR, [ for currentprefix in '${emacsprefix}' '${datadir}' '${prefix}' do expprefix="${currentprefix}" AC_FULL_EXPAND(expprefix) EMACS_LISP([$1], [(catch 22 (let ((dirs $3)) (dolist (name $2 \"NONE\") (dolist (dir dirs) (setq dir (directory-file-name dir)) (and (file-name-absolute-p dir) (file-directory-p dir) (not (string-match \"\\\\\`\\\\.\\\\.\" (file-relative-name dir expanded))) (or (null name) (string= name (file-name-nondirectory dir))) (throw 22 (concat (file-name-as-directory prefix) (file-relative-name dir expanded))))))))],[$4], [prefix expanded $5],["${currentprefix}" "${expprefix}" $6]) if test "[$]$1" != NONE; then break; fi; done]) AC_DEFUN(EMACS_PATH_PACKAGEDIR, [AC_ARG_WITH(packagedir, [ --with-packagedir=DIR package DIR for XEmacs], [packagedir="`echo ${withval} | sed 's/^~\//${HOME}\//;s/[[\/\\]]$//'`"], [if test ${EMACS_FLAVOR} = xemacs; then AC_MSG_CHECKING([for XEmacs package directory]) EMACS_EXAMINE_INSTALLATION_DIR(packagedir, [[(list \"site-packages\" \"xemacs-packages\")]], [[(append late-packages last-packages early-packages)]]) if test "${packagedir}" = NONE -o -z "${packagedir}"; then AC_MSG_ERROR([not found, exiting!]) fi AC_MSG_RESULT(${packagedir}) else packagedir=no fi]) AC_SUBST(packagedir)]) AC_DEFUN(EMACS_PATH_LISPDIR, [ AC_MSG_CHECKING([where lisp files go]) AC_ARG_WITH(lispdir, [ --with-lispdir=DIR Where to install the $1 file, note that most of the package will be relative to it.], [[lispdir="${withval}"]], [if test "${EMACS_FLAVOR}" = 'emacs'; then # Test paths relative to prefixes EMACS_EXAMINE_INSTALLATION_DIR(lispdir, [[(list \"site-lisp\" \"site-packages\")]], load-path) if test "${lispdir}" = "NONE"; then # No? notify user. AC_MSG_ERROR([Cannot locate lisp directory, use --with-lispdir, --datadir, or possibly --prefix to rectify this]) fi else # XEmacs lispdir="${packagedir}/lisp" fi ]) AC_MSG_RESULT([[${lispdir}]]) AC_SUBST(lispdir) ]) AC_DEFUN(TEX_PATH_TEXMFDIR, [ AC_ARG_WITH(texmf-dir,[ --with-texmf-dir=DIR TEXMF tree to install into], [ texmfdir="${withval}" ; AC_FULL_EXPAND(withval) if test ! -d "${withval}" ; then AC_MSG_ERROR([--with-texmf-dir="${texmfdir}": Directory does not exist]) fi previewtexmfdir='${texmfdir}/tex/latex/preview' previewdocdir='${texmfdir}/doc/latex/styles' ]) AC_ARG_WITH(tex-dir, [ --with-tex-dir=DIR Location to install preview TeX sources], [ previewtexmfdir="${withval}" ; AC_FULL_EXPAND(withval) if test ! -d "${withval}" ; then AC_MSG_ERROR([--with-tex-dir="${previewtexmfdir}": Directory does not exist]) fi ]) AC_ARG_WITH(doc-dir, [ --with-doc-dir=DIR Location to install preview.dvi], [ previewdocdir="${withval}" ; AC_FULL_EXPAND(withval) if test ! -d "${withval}" ; then AC_MSG_ERROR([--with-doc-dir="${previewdocdir}": Directory does not exist]) fi ]) # First check for docstrip.cfg information -- removed. Too high # likelihood to pick up a user preference instead of a system setting. # Next # kpsepath -n latex tex # and then go for the following in its output: # a) first path component in datadir/prefix ending in tex/latex// (strip trailing # // and leading !!): "Searching for TDS-compliant directory." Install # in preview subdirectory. # b) first absolute path component ending in // "Searching for directory # hierarchy" Install in preview subdirectory. # c) anything absolute. Install both files directly there. if test -z "${previewtexmfdir}" -o "${previewtexmfdir}" = no ; then AC_MSG_CHECKING([for TDS-compliant directory]) pathoutput="`kpsepath -n latex tex`" EMACS_EXAMINE_INSTALLATION_DIR(texmfdir, [[(list nil)]], [[(let (lst) (dolist (d (append (split-string pathoutput \";\") (split-string pathoutput \":\")) (nreverse lst)) (and (string-match \"\\\\\`!*\\\\(.*/texmf\\\\)/tex/latex//+\\\\'\" d) (push (match-string 1 d) lst))))]], [[-no-site-file]], [[pathoutput]],[["${pathoutput}"]]) if test -z "${texmfdir}" -o "${texmfdir}" = "NONE" ; then EMACS_EXAMINE_INSTALLATION_DIR(texmfdir, [[(list nil)]], [[(let (lst) (dolist (d (append (split-string pathoutput \";\") (split-string pathoutput \":\")) (nreverse lst)) (and (string-match \"\\\\\`!*\\\\(.*[^/]\\\\)/tex/latex//+\\\\'\" d) (push (match-string 1 d) lst))))]], [[-no-site-file]], [[pathoutput]],[["${pathoutput}"]]) fi if test -n "${texmfdir}" -a "${texmfdir}" != "NONE" ; then previewdocdir='${texmfdir}/doc/latex/styles' previewtexmfdir='${texmfdir}/tex/latex/preview' fi fi if test -z "${previewtexmfdir}" -o "${previewtexmfdir}" = no ; then AC_MSG_RESULT([no]) AC_MSG_CHECKING([for TeX directory hierarchy]) EMACS_EXAMINE_INSTALLATION_DIR(texmfdir, [[(list nil)]], [[(let (lst) (dolist (d (append (split-string pathoutput \";\") (split-string pathoutput \":\")) (nreverse lst)) (and (string-match \"\\\\\`!*\\\\(.*[^/]\\\\)//+\\\\'\" d) (push (match-string 1 d) lst))))]], [[-no-site-file]], [[pathoutput]],[["${pathoutput}"]]) if test -n "${texmfdir}" -a "${texmfdir}" != "NONE" ; then previewtexmfdir='${texmfdir}/preview' previewdocdir='${texmfdir}/preview' fi fi if test -z "${previewtexmfdir}" -o "${previewtexmfdir}" = no ; then AC_MSG_RESULT([no]) AC_MSG_CHECKING([for TeX input directory]) EMACS_EXAMINE_INSTALLATION_DIR(texmfdir, [[(list nil)]], [[(let (lst) (dolist (d (append (split-string pathoutput \";\") (split-string pathoutput \":\")) (nreverse lst)) (and (string-match \"\\\\\`!*\\\\(.*[^/]\\\\)/?\\\\'\" d) (push (match-string 1 d) lst))))]], [[-no-site-file]], [[pathoutput]],[["${pathoutput}"]]) if test -n "${texmfdir}" -a "${texmfdir}" != "NONE" ; then previewtexmfdir='${texmfdir}' previewdocdir='${texmfdir}' fi fi if test -z "${previewtexmfdir}" -o "${previewtexmfdir}" = no ; then AC_MSG_RESULT([no]) AC_MSG_ERROR([Cannot find the texmf directory! Please use --with-texmf-dir=dir to specify where the preview tex files go]) fi AC_MSG_RESULT(${texmfdir}) echo Preview will be placed in ${previewtexmfdir} echo Preview docs will be placed in ${previewdocdir} AC_SUBST(texmfdir) AC_SUBST(previewtexmfdir) AC_SUBST(previewdocdir)]) AC_DEFUN(AC_FULL_EXPAND, [ while :;do case "[$]$1" in *\[$]*) __ac_tmp__='s/[[\`"]]/\\&/g' eval "$1=`sed ${__ac_tmp__} < conftest.texi echo @$1{test} >> conftest.texi if ${MAKEINFO} conftest.texi > /dev/null 2> /dev/null; then AC_MSG_RESULT(yes) ifelse([$2], , :, [$2]) else AC_MSG_RESULT(no) ifelse([$3], , :, [$3]) fi rm -f conftest.texi conftest.info fi ]) dnl dnl MAKEINFO_CHECK_MACROS( MACRO ... [, ACTION-IF-FOUND dnl [, ACTION-IF-NOT-FOUND]]) dnl AC_DEFUN(MAKEINFO_CHECK_MACROS, [for ac_macro in $1; do MAKEINFO_CHECK_MACRO(${ac_macro}, $2, [MAKEINFO_MACROS="-D no-${ac_macro} ${MAKEINFO_MACROS}" $3])dnl done AC_SUBST(MAKEINFO_MACROS) ]) AC_DEFUN(AC_SHELL_QUOTIFY, [$1=["`sed 's/[^-0-9a-zA-Z_./:$]/\\\\&/g;s/[$]\\\\[{(]\\([^)}]*\\)\\\\[})]/${\\1}/g' <