I'm using lyx (1.1.6fix3) as a front-end to build Linuxdoc SGML. I've had some
problems with users either not using a version of Lyx that supports this, or
who haven't configured Lyx with sgmltools support, so I thought I'd write an
Autoconf macro to check whether Lyx support Linuxdoc.

I thought to query Lyx itself and see, but couldn't find a command line
argument to check (I could just run lyx -e linuxdoc empty.lyx, but I *think*
that on older version of Lyx that'll run the full UI, which would not be
desirable in a configure script).

I noted the textclass.lst file in the Lyx share directory, and thought that if
it answered to:

grep "^\"linuxdoc" "$LYXLIBDIR/textclass.lst

Then I would be OK (I note, however, that textclass.lst in my environment
mentions docbook, but Lyx doesn't support export to DocBook (?)).

The man page for Lyx says: 
The system directory is determined by searching for the  file  "chkconfig.ltx".
       Directories are searched in this order:
       1) -sysdir command line parameter
       2) LYX_DIR_11x environment variable
       3) Maybe <path of binary>/TOP_SRCDIR/lib
       4) <path of binary>/../share/<name of binary>/
       5)    hardcoded    lyx_dir    (usually   /usr/local/share/lyx   on  
UNIX   and
       %X11ROOT%\XFree86\lib\X11\lyx on OS/2 with XFree)

Ack. What's this about TOP_SRCDIR??? Anyhow, my strategy is to search for
chkconfig.ltx following the above search (but ignoring OS/2, alas), and then,
in that dir, do the above mentioned grep to search for linuxdoc support.

Attached is what I came up with for an Autoconf macro -- am I remotely on the
right track? Is there a better way of doing this? (And if you have some
comments on the macro, please fire away!)

Thanks in advance,
Arien Malec

AC_DEFUN(CK_CHECK_PROG_LYX_LINUXDOC,
[AC_MSG_CHECKING([for lyx with linuxdoc])
LYXCHKCONFIG="chkconfig.ltx"

LYXENVDIR="$LYX_DIR_11x"

LYX=`which lyx`
if test -n "$LYX"; then
        LYXPATH=`dirname $LYX`
fi
LYXHARDDIR='/usr/local/share/lyx'
LYXLDIR="$LYXPATH/../lib"
LYXSDIR="$LYXPATH/../share/lyx"
for lyxpath in "$LYXENVDIR" "$LYXLDIR" "$LYXSDIR" "$LYXHARDDIR"; do
        if test -n "$lyxpath" -a -e "$lyxpath/$LYXCHKCONFIG" ; then
                LYXLIBDIR="$lyxpath"
                break
        fi
done

if grep "^\"linuxdoc" "$LYXLIBDIR/textclass.lst" &> /dev/null; then
        AC_MSG_RESULT([yes])
        [$1]
else
        AC_MSG_RESULT([no])
        AC_MSG_WARN([couldn't find lyx with linuxdoc, not building docs])
        [$2]
fi])

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Reply via email to