# 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} ]) # This generates a prefix variables $1 from the executable in $2. # The executable is searched in PATH, and a potential bin/ or # bin/architecture/ component is stripped from it. AC_DEFUN(EMACS_PATH_PREFIX,[ EMACS_LISP([$1],[[(condition-case nil (let* ((prefix (directory-file-name (file-name-directory (executable-find cmd)))) (parent (directory-file-name (file-name-directory prefix)))) (if (string= (file-name-nondirectory prefix) \"bin\") (setq prefix parent) (if (string= (file-name-nondirectory parent) \"bin\") (setq prefix (directory-file-name (file-name-directory parent))))) prefix) (error "NONE"))]],[[-no-site-file]],[[cmd]],[$2])]) 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 elif test "${withval}" = "no"; then EMACS=xemacs else EMACS="${withval}"; fi]) AC_ARG_WITH(xemacs, [ --with-xemacs@<:@=PATH@:>@ Use XEmacs to build (on PATH if given)], [if test "x${withval}" != xno then if test "x${with_emacs}" != xno -a "x${with_emacs}" != x then AC_MSG_ERROR([[cannot use both Emacs and XEmacs]]) fi if test "x${withval}" = "xyes" then EMACS=xemacs else EMACS="${withval}" fi elif test "x${with_emacs}" = xno then AC_MSG_ERROR([[need to use either Emacs or XEmacs]]) 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" elif test "${XEMACS}" = "no"; then EMACS_FLAVOR=emacs EMACS_NAME="Emacs" else AC_MSG_ERROR([Unable to run ${EMACS}! Aborting!]) fi AC_MSG_RESULT(${XEMACS}) AC_SUBST(XEMACS) AC_SUBST(EMACS_FLAVOR) AC_MSG_CHECKING([for ${EMACS_NAME} prefix]) EMACS_PATH_PREFIX([[emacsprefix]],[["${EMACS}"]]) AC_MSG_RESULT([["${emacsprefix}"]]) ]) AC_DEFUN(AC_DATE_VERSION_FROM_CHANGELOG, [ AC_MSG_CHECKING([for date in ChangeLog]) $1=[`sed -n '1s/^\([-0-9][-0-9]*\).*/\1/p' ChangeLog`] if test "X${$1}" = X then AC_MSG_ERROR([[not found]]) fi AC_MSG_RESULT(${$1}) AC_MSG_CHECKING([for release in ChangeLog]) $2=[`sed -n '2,/^[0-9]/s/.*Version \(.*\) released\..*/\1/p' ChangeLog`] if test "X${$2}" = X then $2=${$1} AC_MSG_RESULT([not found, using ${$2} instead]) else AC_MSG_RESULT([${$2}]) fi ]) 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 given prefixes. dnl $1 is the variable name we are looking for. dnl $2 is a list of prefixes to try as a list of shell words dnl $3 is a Lisp expression giving a list of directory names dnl those should be be either nil or a relative path like "tex/latex". dnl Those names are tried in turn, and every one of them is matched dnl against the tail of each location in $4. nil matches everything, dnl it is a wildcard. dnl $4 is Lisp expression giving a list of locations where to find names. dnl A location is only considered if it is nonnil, an existing dnl absolute directory, dnl and is a subdirectory of one of the given prefixes. dnl $5,$6,$7 are additional arguments for the elisp call AC_DEFUN(EMACS_EXAMINE_INSTALLATION_DIR, [ for currentprefix in $2 do expprefix="${currentprefix}" AC_FULL_EXPAND(expprefix) EMACS_LISP([$1], [(catch 22 (let (reldir (dirs $4)) (dolist (name $3 \"NONE\") (dolist (dir dirs) (when (and dir (setq dir (directory-file-name dir)) (file-name-absolute-p dir) (file-directory-p dir) (not (string-match \"\\\\\`\\\\.\\\\.\" (setq reldir (file-relative-name dir expanded)))) (not (file-name-absolute-p reldir)) (let ((name name) (dir dir)) (while (and dir name (string= (file-name-nondirectory dir) (file-name-nondirectory name)) (setq dir (file-name-directory dir) name (file-name-directory name)) (if (and dir name) (setq dir (directory-file-name dir) name (directory-file-name name))))) (null name)) (throw 22 (if (string= reldir \".\") (directory-file-name prefix) (concat (file-name-as-directory prefix) reldir)))))))))],[$5], [prefix expanded $6],["${currentprefix}" "${expprefix}" $7]) 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, [['${datadir}/xemacs/xemacs-packages' \ '${libdir}/xemacs/xemacs-packages' \ '${datadir}' '${libdir}' "${emacsprefix}"]], [[(list \"xemacs/site-packages\" \"xemacs/xemacs-packages\" \"site-packages\" \"xemacs-packages\")]], [[(if (boundp 'late-packages) (append late-packages last-packages early-packages) (append late-package-hierarchies last-package-hierarchies early-package-hierarchies))]]) if test "x${packagedir}" = xNONE -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 A place in load-path for Lisp files; most files will be place in a subdirectory.], [[lispdir="${withval}"]]) if test "X${lispdir}" = X; then if test "X${packagedir}" = Xno; then # Test paths relative to prefixes EMACS_EXAMINE_INSTALLATION_DIR(lispdir, [['${datadir}/'${EMACS_FLAVOR} '${libdir}/'${EMACS_FLAVOR} \ "${emacsprefix}/share/${EMACS_FLAVOR}" \ '${datadir}' '${libdir}' "${emacsprefix}"]], [[(list \"${EMACS_FLAVOR}/site-lisp\" \"${EMACS_FLAVOR}/site-packages\" \"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 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, or --without-texmf-dir for runtime config], [ texmfdir="${withval}" ; if test "x${texmfdir}" = xno then previewtexmfdir="${packagedatadir}/latex" previewdocdir="${packagedatadir}/doc" else 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" fi ]) 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 "x${texmfdir}" != xno ; then if test "x${previewtexmfdir}" = x ; then AC_MSG_CHECKING([for prefix from kpsepath]) EMACS_PATH_PREFIX(texprefix,kpsepath) if test "x${texprefix}" != "xNONE" then AC_MSG_RESULT([["${texprefix}"]]) AC_MSG_CHECKING([for TDS-compliant directory]) pathoutput="`kpsepath -n latex tex`" EMACS_EXAMINE_INSTALLATION_DIR(texmfdir, [['${datadir}/texmf' "${texprefix}/share/texmf-local" "${texprefix}/share/texmf" "${texprefix}/texmf-local" "${texprefix}/texmf"]], [[(list nil)]], [[(mapcar (lambda(x) (and (string-match \"\\\\\`!*\\\\(.*\\\\)/tex/latex//+\\\\'\" x) (match-string 1 x))) (append (split-string pathoutput \";\") (split-string pathoutput \":\")))]], [[-no-site-file]], [[pathoutput]],[["${pathoutput}"]]) if test -n "${texmfdir}" -a "${texmfdir}" != "NONE" ; then previewdocdir="${texmfdir}/doc/latex/styles" previewtexmfdir="${texmfdir}/tex/latex/preview" 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, [['${datadir}/texmf' "${texprefix}/share/texmf-local" "${texprefix}/share/texmf" "${texprefix}/texmf-local" "${texprefix}/texmf" '${datadir}' "${texprefix}/share" "${texprefix}"]], [[(list nil)]], [[(mapcar (lambda(x) (and (string-match \"\\\\\`!*\\\\(.*[^/]\\\\)//+\\\\'\" x) (match-string 1 x))) (append (split-string pathoutput \";\") (split-string pathoutput \":\")))]], [[-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, [['${datadir}' "${texprefix}/share" "${texprefix}"]], [[(list nil)]], [[(mapcar (lambda(x) (and (string-match \"\\\\\`!*\\\\(.*[^/]\\\\)/?\\\\'\" x) (match-string 1 x))) (append (split-string pathoutput \";\") (split-string pathoutput \":\")))]], [[-no-site-file]], [[pathoutput]],[["${pathoutput}"]]) if test -n "${texmfdir}" -a "${texmfdir}" != "NONE" ; then previewtexmfdir="${texmfdir}" previewdocdir="${texmfdir}" fi 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}) fi fi 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, [ __ac_tmp_oldprefix__="${prefix}" __ac_tmp_oldexec_prefix__="$exec_prefix" test "x${prefix}" = xNONE && prefix="${ac_default_prefix}" test "x${exec_prefix}" = xNONE && exec_prefix='${prefix}' 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' <