]> git.lyx.org Git - lyx.git/blob - lib/build-listerrors
More small fixes
[lyx.git] / lib / build-listerrors
1 #!/bin/sh
2 #
3 # Attempt to build listerrors (see examples/Literate.lyx) at build-time
4 #
5 # Author: Kayvan Sylvan <kayvan@sylvan.com>
6
7 fakeprogram()
8 {
9     L=listerrors
10     echo "#!/bin/sh" > $L
11     echo 'echo "This is NOT the listerrors program."' >> $L
12     echo 'echo ""' >> $L
13     echo 'echo "Here was the problem when we tried to build listerrors:"' >> $L
14     echo echo "$1" >> $L
15     chmod +x $L
16     exit 0
17 }
18
19 mywhich()
20 {
21     arg=$1
22     for i in `echo $PATH | sed 's/:/ /g'`
23     do
24         if [ -x $i/$arg ]
25         then
26             echo $i/$arg
27         fi
28     done
29 }
30
31 if [ -r ../src/lyx ]
32 then
33     lyx=../src/lyx
34 else
35     lyx=`mywhich lyx`
36 fi
37
38 if [ -z "$lyx" ]
39 then
40     echo "You must build lyx first to build listerrors."
41     exit 1
42 fi
43
44 notangle=`mywhich notangle`
45
46 if [ -z "$notangle" ]
47 then
48     fakeprogram "The NOWEB notangle was not found."
49 fi
50
51 vncserver=`mywhich vncserver`
52 if [ -z "$vncserver" ]
53 then
54     # See if DISPLAY is set
55     #
56     if [ -z "$DISPLAY" ]
57     then
58         fakeprogram "Could not export Literate.nw. Export needs GUI, fix lyx!"
59     else
60         $lyx --export tex examples/Literate.lyx
61     fi
62 else
63     # Use the vncserver to make a silent export
64     if [ -r $HOME/.vnc/passwd ]
65     then
66         had_vnc_passwd=1
67     else
68         mkdir $HOME/.vnc > /dev/null 2>&1
69         had_vnc_passwd=0
70         touch $HOME/.vnc/passwd; chmod 700 $HOME/.vnc/passwd
71     fi
72     $vncserver :10 -depth 16
73     DISPLAY=:10
74     export DISPLAY
75     $lyx --export tex examples/Literate.lyx
76     $vncserver -kill :10
77     if [ $had_vnc_passwd -eq 0 ]
78     then
79         rm $HOME/.vnc/passwd
80     fi
81 fi
82 mv examples/Literate.tex Literate.nw
83 $notangle -Rbuild-script Literate.nw | sh