# Attempt to build listerrors (see examples/Literate.lyx) at build-time
#
# Author: Kayvan Sylvan <kayvan@sylvan.com>
+#
+# Assume notangle is on the path
-fakeprogram()
-{
- L=listerrors
- echo "#!/bin/sh" > $L
- echo 'echo "This is NOT the listerrors program."' >> $L
- echo 'echo ""' >> $L
- echo 'echo "Here was the problem when we tried to build listerrors:"' >> $L
- echo echo "$1" >> $L
- chmod +x $L
- exit 0
-}
-
-mywhich()
-{
- arg=$1
- for i in `echo $PATH | sed 's/:/ /g'`
- do
- if [ -x $i/$arg ]
- then
- echo $i/$arg
- fi
- done
-}
-
-if [ -r ../src/lyx ]
+if [ $# -eq 1 ]
then
- lyx=../src/lyx
+ dir=$1
else
- lyx=`mywhich lyx`
+ dir=.
fi
-if [ -z "$lyx" ]
+if [ -r ../src/lyx ]
then
- echo "You must build lyx first to build listerrors."
- exit 1
+ lyx=../src/lyx
+else
+ # Assumed to be on the path
+ lyx=lyx
fi
-notangle=`mywhich notangle`
-
-if [ -z "$notangle" ]
+if [ -z "`grep literate-article textclass.lst`" ]
then
- fakeprogram "The NOWEB notangle was not found."
+ touch listerrors
+ exit 0
fi
-vncserver=`mywhich vncserver`
-if [ -z "$vncserver" ]
+$lyx --export literate $dir/examples/Literate.lyx
+# if no literate support stuff is installed nothing will be output
+if [ -f $dir/examples/Literate.nw ]
then
- # See if DISPLAY is set
- #
- if [ -z "$DISPLAY" ]
- then
- fakeprogram "Could not export Literate.nw. Export needs GUI, fix lyx!"
- else
- $lyx --export tex examples/Literate.lyx
- fi
+ mv $dir/examples/Literate.nw Literate.nw
+ which notangle 2>/dev/null && notangle -Rbuild-script Literate.nw | sh
else
- # Use the vncserver to make a silent export
- if [ -r $HOME/.vnc/passwd ]
- then
- had_vnc_passwd=1
- else
- mkdir $HOME/.vnc > /dev/null 2>&1
- had_vnc_passwd=0
- touch $HOME/.vnc/passwd; chmod 700 $HOME/.vnc/passwd
- fi
- $vncserver :10 -depth 16
- DISPLAY=:10
- export DISPLAY
- $lyx --export tex examples/Literate.lyx
- $vncserver -kill :10
- if [ $had_vnc_passwd -eq 0 ]
- then
- rm $HOME/.vnc/passwd
- fi
+ # you don't have noweb installed so we'll produce a dummy file
+ # just so make doesn't keep trying to output it.
+ touch listerrors
+ # tell the user nothing bad happened
+ echo
+ echo "LyX did not detect NoWeb support. Proceeding normally."
fi
-mv examples/Literate.tex Literate.nw
-$notangle -Rbuild-script Literate.nw | sh
+
+exit 0