| author | wenzelm | 
| Tue, 15 Jan 2013 12:45:19 +0100 | |
| changeset 50900 | 6d80709ab862 | 
| parent 48171 | 28a6d67c93f0 | 
| permissions | -rwxr-xr-x | 
| 10555 | 1  | 
#!/usr/bin/env bash  | 
| 8159 | 2  | 
#  | 
| 9788 | 3  | 
# Author: Markus Wenzel, TU Muenchen  | 
| 8159 | 4  | 
#  | 
5  | 
# DESCRIPTION: prepare logic session directory  | 
|
6  | 
||
7  | 
||
8  | 
## diagnostics  | 
|
9  | 
||
| 10511 | 10  | 
PRG="$(basename "$0")"  | 
| 8159 | 11  | 
|
12  | 
function usage()  | 
|
13  | 
{
 | 
|
14  | 
echo  | 
|
| 28650 | 15  | 
echo "Usage: isabelle $PRG [OPTIONS] [LOGIC] NAME"  | 
| 8159 | 16  | 
echo  | 
17  | 
echo " Options are:"  | 
|
| 8198 | 18  | 
echo " -I FILE alternative IsaMakefile output"  | 
| 8211 | 19  | 
echo " -P include parent logic target"  | 
| 8159 | 20  | 
echo " -b setup build mode (session outputs heap image)"  | 
| 11578 | 21  | 
echo " -q quiet mode"  | 
| 8159 | 22  | 
echo  | 
| 11578 | 23  | 
echo " Prepare session directory, including IsaMakefile and document source"  | 
| 8199 | 24  | 
echo " with parent LOGIC (default ISABELLE_LOGIC=$ISABELLE_LOGIC)"  | 
| 8159 | 25  | 
echo  | 
26  | 
exit 1  | 
|
27  | 
}  | 
|
28  | 
||
29  | 
function fail()  | 
|
30  | 
{
 | 
|
31  | 
echo "$1" >&2  | 
|
32  | 
exit 2  | 
|
33  | 
}  | 
|
34  | 
||
35  | 
||
36  | 
## process command line  | 
|
37  | 
||
38  | 
# options  | 
|
39  | 
||
| 8198 | 40  | 
ISAMAKEFILE="IsaMakefile"  | 
| 8211 | 41  | 
PARENT=""  | 
| 8159 | 42  | 
BUILD=""  | 
| 11578 | 43  | 
QUIET=""  | 
| 8159 | 44  | 
|
| 11578 | 45  | 
while getopts "I:Pbq" OPT  | 
| 8159 | 46  | 
do  | 
47  | 
case "$OPT" in  | 
|
| 8198 | 48  | 
I)  | 
49  | 
ISAMAKEFILE="$OPTARG"  | 
|
50  | 
;;  | 
|
| 8211 | 51  | 
P)  | 
52  | 
PARENT=true  | 
|
53  | 
;;  | 
|
| 8159 | 54  | 
b)  | 
55  | 
BUILD=true  | 
|
56  | 
;;  | 
|
| 11578 | 57  | 
q)  | 
58  | 
QUIET=true  | 
|
| 8159 | 59  | 
;;  | 
60  | 
\?)  | 
|
61  | 
usage  | 
|
62  | 
;;  | 
|
63  | 
esac  | 
|
64  | 
done  | 
|
65  | 
||
66  | 
shift $(($OPTIND - 1))  | 
|
67  | 
||
68  | 
||
69  | 
# args  | 
|
70  | 
||
71  | 
||
| 9788 | 72  | 
if [ "$#" -eq 1 ]; then  | 
| 8194 | 73  | 
LOGIC="$ISABELLE_LOGIC"  | 
| 8685 | 74  | 
DIR_NAME="$1"; shift  | 
| 9788 | 75  | 
elif [ "$#" -eq 2 ]; then  | 
| 8194 | 76  | 
LOGIC="$1"; shift  | 
| 8685 | 77  | 
DIR_NAME="$1"; shift  | 
| 8194 | 78  | 
else  | 
79  | 
usage  | 
|
80  | 
fi  | 
|
| 8159 | 81  | 
|
| 8685 | 82  | 
DIR=$(dirname "$DIR_NAME")  | 
83  | 
NAME=$(basename "$DIR_NAME")  | 
|
| 8159 | 84  | 
|
85  | 
||
86  | 
## main  | 
|
87  | 
||
| 11578 | 88  | 
[ -z "$QUIET" ] && echo "Preparing session \"$NAME\" ..."  | 
89  | 
||
90  | 
||
| 8159 | 91  | 
# IsaMakefile  | 
92  | 
||
| 8685 | 93  | 
mkdir -p "$DIR" || fail "Bad directory: $DIR"  | 
94  | 
cd "$DIR"  | 
|
95  | 
||
| 8244 | 96  | 
DOCUMENT_ROOT=""  | 
| 
11846
 
2ce611f870e0
option -q also excludes -v true in generated stuff;
 
wenzelm 
parents: 
11836 
diff
changeset
 | 
97  | 
VERBOSE=""  | 
| 
 
2ce611f870e0
option -q also excludes -v true in generated stuff;
 
wenzelm 
parents: 
11836 
diff
changeset
 | 
98  | 
[ -z "$QUIET" ] && VERBOSE="-v true "  | 
| 8244 | 99  | 
|
| 8159 | 100  | 
if [ -n "$BUILD" ]; then  | 
101  | 
IMAGES="$NAME"  | 
|
102  | 
TEST=""  | 
|
103  | 
TARGET="\$(OUT)/$NAME"  | 
|
| 8244 | 104  | 
ROOT_ML="ROOT.ML"  | 
| 8579 | 105  | 
SOURCES="*.thy"  | 
| 11578 | 106  | 
DOCUMENT_ROOT="document/root.tex"  | 
| 8194 | 107  | 
USEDIR="\$(USEDIR) -b -P http://isabelle.in.tum.de/library"  | 
| 8159 | 108  | 
else  | 
109  | 
IMAGES=""  | 
|
110  | 
TEST="$NAME"  | 
|
| 8211 | 111  | 
TARGET="\$(LOG)/$LOGIC-$NAME.gz"  | 
| 8244 | 112  | 
ROOT_ML="$NAME/ROOT.ML"  | 
| 8579 | 113  | 
SOURCES="$NAME/*.thy"  | 
| 11578 | 114  | 
DOCUMENT_ROOT="$NAME/document/root.tex"  | 
| 8194 | 115  | 
USEDIR="\$(USEDIR)"  | 
| 8159 | 116  | 
fi  | 
117  | 
||
| 8198 | 118  | 
if [ "$ISAMAKEFILE" != - -a -f "$ISAMAKEFILE" ]; then  | 
| 11578 | 119  | 
echo "keeping $DIR/$ISAMAKEFILE" >&2  | 
| 8159 | 120  | 
else  | 
| 11650 | 121  | 
[ -z "$QUIET" -a -n "$ISAMAKEFILE" -a "$ISAMAKEFILE" != - ] && \  | 
122  | 
echo "creating $DIR/$ISAMAKEFILE" >&2  | 
|
| 8159 | 123  | 
  { echo
 | 
124  | 
echo "## targets"  | 
|
125  | 
echo  | 
|
126  | 
echo "default: $NAME"  | 
|
127  | 
echo "images: $IMAGES"  | 
|
128  | 
echo "test: $TEST"  | 
|
129  | 
echo  | 
|
130  | 
echo "all: images test"  | 
|
131  | 
echo  | 
|
132  | 
echo  | 
|
133  | 
echo "## global settings"  | 
|
134  | 
echo  | 
|
135  | 
echo "SRC = \$(ISABELLE_HOME)/src"  | 
|
136  | 
echo "OUT = \$(ISABELLE_OUTPUT)"  | 
|
137  | 
echo "LOG = \$(OUT)/log"  | 
|
| 11578 | 138  | 
echo  | 
| 28500 | 139  | 
    echo "USEDIR = \$(ISABELLE_TOOL) usedir ${VERBOSE}-i true -d $ISABELLE_DOC_FORMAT  ## -D generated"
 | 
| 8159 | 140  | 
echo  | 
141  | 
echo  | 
|
142  | 
echo "## $NAME"  | 
|
143  | 
echo ""  | 
|
| 8162 | 144  | 
if [ -n "$PARENT" ]; then  | 
145  | 
echo "$NAME: $LOGIC $TARGET"  | 
|
146  | 
echo  | 
|
147  | 
echo "$LOGIC:"  | 
|
| 28500 | 148  | 
echo -e "\t@cd \$(SRC)/$LOGIC; \$(ISABELLE_TOOL) make $LOGIC"  | 
| 8162 | 149  | 
echo  | 
| 13946 | 150  | 
echo "$TARGET: \$(OUT)/$LOGIC $ROOT_ML $DOCUMENT_ROOT ## $SOURCES"  | 
| 8194 | 151  | 
echo -e "\t@$USEDIR \$(OUT)/$LOGIC $NAME"  | 
| 8162 | 152  | 
else  | 
153  | 
echo "$NAME: $TARGET"  | 
|
154  | 
echo  | 
|
| 13946 | 155  | 
echo "$TARGET: ## $ROOT_ML $DOCUMENT_ROOT $SOURCES"  | 
| 8194 | 156  | 
echo -e "\t@$USEDIR $LOGIC $NAME"  | 
| 8162 | 157  | 
fi  | 
| 8159 | 158  | 
echo  | 
159  | 
echo  | 
|
160  | 
echo "## clean"  | 
|
161  | 
echo  | 
|
162  | 
echo "clean:"  | 
|
163  | 
echo -e "\t@rm -f $TARGET"  | 
|
| 8198 | 164  | 
  } | {
 | 
165  | 
if [ -z "$ISAMAKEFILE" -o "$ISAMAKEFILE" = - ]; then  | 
|
166  | 
cat  | 
|
167  | 
else  | 
|
168  | 
cat > "$ISAMAKEFILE"  | 
|
169  | 
fi  | 
|
170  | 
}  | 
|
| 8159 | 171  | 
fi  | 
172  | 
||
173  | 
||
174  | 
# base directory  | 
|
175  | 
||
176  | 
if [ -z "$BUILD" ]; then  | 
|
| 11578 | 177  | 
mkdir -p "$NAME" || fail "Bad directory: $DIR/$NAME"  | 
| 8159 | 178  | 
cd "$NAME"  | 
| 11578 | 179  | 
PREFIX="$DIR/$NAME"  | 
180  | 
else  | 
|
181  | 
PREFIX="$DIR"  | 
|
| 8159 | 182  | 
fi  | 
183  | 
||
184  | 
if [ -f ROOT.ML ]; then  | 
|
| 11578 | 185  | 
echo "keeping $PREFIX/ROOT.ML" >&2  | 
| 8159 | 186  | 
else  | 
| 11650 | 187  | 
[ -z "$QUIET" ] && echo "creating $PREFIX/ROOT.ML" >&2  | 
| 11578 | 188  | 
cat >ROOT.ML <<EOF  | 
189  | 
(*  | 
|
| 32299 | 190  | 
no_document use_thys ["This_Theory1", "This_Theory2"];  | 
191  | 
use_thys ["That_Theory1", "That_Theory2", "That_Theory3"];  | 
|
| 11578 | 192  | 
*)  | 
193  | 
EOF  | 
|
| 8159 | 194  | 
fi  | 
195  | 
||
196  | 
||
197  | 
# document directory  | 
|
198  | 
||
| 11578 | 199  | 
if [ -e document ]; then  | 
200  | 
echo "keeping $PREFIX/document" >&2  | 
|
201  | 
else  | 
|
| 11650 | 202  | 
[ -z "$QUIET" ] && echo "creating $PREFIX/document" >&2  | 
| 11578 | 203  | 
mkdir document || fail "Bad directory: $PREFIX/document"  | 
| 11650 | 204  | 
|
205  | 
[ -z "$QUIET" ] && echo "creating $PREFIX/document/root.tex" >&2  | 
|
| 16482 | 206  | 
TITLE=$(echo "$NAME" | tr _ - | tr -d '\\')  | 
207  | 
AUTHOR=$(echo "By $USER" | tr _ - | tr -d '\\')  | 
|
| 11578 | 208  | 
cat >document/root.tex <<EOF  | 
| 8159 | 209  | 
\documentclass[11pt,a4paper]{article}
 | 
| 11578 | 210  | 
\usepackage{isabelle,isabellesym}
 | 
| 8159 | 211  | 
|
| 16482 | 212  | 
% further packages required for unusual symbols (see also  | 
213  | 
% isabellesym.sty), use only when needed  | 
|
214  | 
||
215  | 
%\usepackage{amssymb}
 | 
|
216  | 
%for \<leadsto>, \<box>, \<diamond>, \<sqsupset>, \<mho>, \<Join>,  | 
|
217  | 
%\<lhd>, \<lesssim>, \<greatersim>, \<lessapprox>, \<greaterapprox>,  | 
|
218  | 
%\<triangleq>, \<yen>, \<lozenge>  | 
|
219  | 
||
| 
48171
 
28a6d67c93f0
default for \<euro> is now based on eurosym package, instead of slightly exotic babel/greek (which causes problems with the Gentoo installation on lxbroy2);
 
wenzelm 
parents: 
40895 
diff
changeset
 | 
220  | 
%\usepackage{eurosym}
 | 
| 
 
28a6d67c93f0
default for \<euro> is now based on eurosym package, instead of slightly exotic babel/greek (which causes problems with the Gentoo installation on lxbroy2);
 
wenzelm 
parents: 
40895 
diff
changeset
 | 
221  | 
%for \<euro>  | 
| 16482 | 222  | 
|
223  | 
%\usepackage[only,bigsqcap]{stmaryrd}
 | 
|
224  | 
%for \<Sqinter>  | 
|
225  | 
||
226  | 
%\usepackage{eufrak}
 | 
|
227  | 
%for \<AA> ... \<ZZ>, \<aa> ... \<zz> (also included in amssymb)  | 
|
228  | 
||
229  | 
%\usepackage{textcomp}
 | 
|
| 40895 | 230  | 
%for \<onequarter>, \<onehalf>, \<threequarters>, \<degree>, \<cent>,  | 
231  | 
%\<currency>  | 
|
| 11578 | 232  | 
|
233  | 
% this should be the last package used  | 
|
234  | 
\usepackage{pdfsetup}
 | 
|
235  | 
||
| 13946 | 236  | 
% urls in roman style, theory text in math-similar italics  | 
| 10021 | 237  | 
\urlstyle{rm}
 | 
238  | 
\isabellestyle{it}
 | 
|
| 9656 | 239  | 
|
| 28180 | 240  | 
% for uniform font size  | 
241  | 
%\renewcommand{\isastyle}{\isastyleminor}
 | 
|
242  | 
||
| 11578 | 243  | 
|
| 8159 | 244  | 
\begin{document}
 | 
| 10353 | 245  | 
|
| 11578 | 246  | 
\title{$TITLE}
 | 
247  | 
\author{$AUTHOR}
 | 
|
248  | 
\maketitle  | 
|
249  | 
||
| 10308 | 250  | 
\tableofcontents  | 
| 10353 | 251  | 
|
| 25172 | 252  | 
% sane default for proof documents  | 
| 
25410
 
0ba2d51bcb42
reactivated default paragraph formatting for ``proof documents'';
 
wenzelm 
parents: 
25172 
diff
changeset
 | 
253  | 
\parindent 0pt\parskip 0.5ex  | 
| 11578 | 254  | 
|
| 14936 | 255  | 
% generated text of all theories  | 
| 8159 | 256  | 
\input{session}
 | 
| 10353 | 257  | 
|
| 14936 | 258  | 
% optional bibliography  | 
| 12104 | 259  | 
%\bibliographystyle{abbrv}
 | 
| 10353 | 260  | 
%\bibliography{root}
 | 
261  | 
||
| 8159 | 262  | 
\end{document}
 | 
| 14936 | 263  | 
|
264  | 
%%% Local Variables:  | 
|
265  | 
%%% mode: latex  | 
|
266  | 
%%% TeX-master: t  | 
|
267  | 
%%% End:  | 
|
| 8159 | 268  | 
EOF  | 
269  | 
fi  | 
|
| 11578 | 270  | 
|
271  | 
||
272  | 
# notes  | 
|
273  | 
||
274  | 
if [ -z "$QUIET" ]; then  | 
|
| 11650 | 275  | 
cat >&2 <<EOF  | 
| 11578 | 276  | 
|
277  | 
Notes:  | 
|
278  | 
||
| 
28504
 
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
 
wenzelm 
parents: 
28500 
diff
changeset
 | 
279  | 
* 'isabelle make' processes the session (including document preparation)  | 
| 11578 | 280  | 
|
| 11650 | 281  | 
* $DIR/IsaMakefile contains compilation options and file dependencies  | 
282  | 
||
| 
11846
 
2ce611f870e0
option -q also excludes -v true in generated stuff;
 
wenzelm 
parents: 
11836 
diff
changeset
 | 
283  | 
* $PREFIX/document/root.tex contains the LaTeX master document setup  | 
| 11578 | 284  | 
|
| 
11846
 
2ce611f870e0
option -q also excludes -v true in generated stuff;
 
wenzelm 
parents: 
11836 
diff
changeset
 | 
285  | 
* $PREFIX/ROOT.ML needs to contain ML code to load all theories  | 
| 11578 | 286  | 
|
287  | 
EOF  | 
|
288  | 
fi  |