1 | #!/bin/bash
2 |
3 | cd fr/
4 | TEXFILE=guide
5 | TEXMAK=pdflatex
6 |
7 | echo
8 | if [ $# -lt 1 ]; then
9 | echo "Usage $0 [-v] [-pdf]|[-ps] [--help] "
10 | echo
11 | LISTE=$*
12 | fi
13 |
14 | VERBOSE=0
15 | for i in $LISTE; do
16 | if [ $i = -v ]; then
17 | VERBOSE=1
18 | LISTE=`echo $LISTE | awk -F \-v '{print $1 $2}'`
19 | elif [ $i = --help ]; then
20 | echo "Usage $0 [-v] [-pdf]|[-ps] [--help] + fichier[.tex] "
21 | echo
22 | echo "--help : affiche l'aide"
23 | echo "-v : affiche la compilation (verbose)"
24 | echo "-pdf : compilation avec pdflatex (defaut)"
25 | echo "-ps : complation avec latex, sortie postscript"
26 | echo
27 | exit 0
28 | elif [ $i = -ps ]; then
29 | TEXMAK=latex
30 | LISTE=`echo $LISTE | awk -F \-ps '{print $1 $2}' | awk -F \-pdf '{print $1 $2}'`
31 | fi
32 | done
33 |
34 | echo "Compilation du fichier $TEXFILE.tex avec $TEXMAK"
35 | echo "----------------------------------------------"
36 | echo "Si erreurs :"
37 | echo " > Type <return> to proceed, S to scroll future error messages,"
38 | echo " > R to run without stopping, Q to run quietly,"
39 | echo " > I to insert something, E to edit your file,"
40 | echo " > 1 or ... or 9 to ignore the next 1 to 9 tokens of input,"
41 | echo " > H for help, X to quit."
42 | echo
43 |
44 |
45 | if [ -f $TEXFILE.aux ]; then
46 | echo "Effacement des fichiers temporaires : " $TEXFILE.aux, TEXFILE.log TEXFILE.out
47 | rm $TEXFILE.aux $TEXFILE.log $TEXFILE.mtc $TEXFILE.out $TEXFILE.lof $TEXFILE.maf $TEXFILE.mtc1 $TEXFILE.toc 2> /dev/null
48 | fi
49 |
50 | if [ $VERBOSE -eq 0 ]; then
51 | echo "-> Compilation 1/3 ..."
52 | $TEXMAK $TEXFILE.tex | grep -C 3 '!\ ' #grep -C 3 'l.[0-9]' #grep -C 3 'LaTeX Error'
53 |
54 | echo " >> Compilation du fichier bibtex 1/2 ..."
55 | bibtex $TEXFILE > /dev/null
56 | echo " >> Compilation du fichier bibtex 2/2..."
57 | bibtex $TEXFILE > /dev/null
58 | echo "-> Compilation 2/3 ..."
59 | $TEXMAK $TEXFILE.tex > /dev/null
60 | echo "-> Compilation 3/3 ..."
61 | echo
62 | $TEXMAK $TEXFILE.tex | grep Warning | grep -v small | grep -v PDFDocEncoded | grep -v minitoc
63 | else
64 | $TEXMAK $TEXFILE.tex
65 | bibtex $TEXFILE
66 | bibtex $TEXFILE
67 | $TEXMAK $TEXFILE.tex
68 | $TEXMAK $TEXFILE.tex
69 | fi
70 | echo
71 | mv -v $TEXFILE.pdf ../PRISSMA-usersguide.pdf
72 | echo
73 | echo "Fait !"
74 | echo
75 | echo
76 |
77 | function nettoie() {
78 |
79 | while [ -n "$1" ] ; do
80 | nom=$1
81 | rm $nom/*.toc 2>/dev/null
82 | rm $nom/*.maf 2>/dev/null
83 | rm $nom/*.mtc* 2>/dev/null
84 | rm $nom/*.ptc* 2>/dev/null
85 | rm $nom/*.dvi 2>/dev/null
86 | rm $nom/*.dvi 2>/dev/null
87 | rm $nom/*.out 2>/dev/null
88 | rm $nom/*.lof 2>/dev/null
89 | rm $nom/*.lot 2>/dev/null
90 | rm $nom/*.aux 2>/dev/null
91 | rm $nom/*.idx 2>/dev/null
92 | rm $nom/*.ilg 2>/dev/null
93 | rm $nom/*.ind 2>/dev/null
94 | rm $nom/*.log 2>/dev/null
95 | rm $nom/*.*# 2>/dev/null
96 | rm $nom/*.tex~ 2>/dev/null
97 | rm $nom/*.bbl 2>/dev/null
98 | rm $nom/*.brf 2>/dev/null
99 | rm $nom/*.bmt 2>/dev/null
100 | rm $nom/*.blg 2>/dev/null
101 | rm $nom/*~ 2>/dev/null
102 | rm $nom/.*~ 2>/dev/null
103 | rm $nom/*.snm 2>/dev/null
104 | rm $nom/*.nav 2>/dev/null
105 | rm core 2>/dev/null
106 | echo -e '\E[34m' "Repertoire : $nom ->" '\E[0m' `ls $nom`
107 | shift
108 | done
109 | }
110 |
111 | nom=`pwd`
112 | echo "Nettoyage des sous-repertoires :"
113 | echo "--------------------------------"
114 | nettoie $nom
115 |
116 | for i in `ls` ; do
117 | if [ -d "$i" ] ; then nettoie $i ; fi
118 | done
119 |
120 | echo
121 | echo Kill des processus $0 precedents ...
122 | killall -9 $0
123 | echo