author | wenzelm |
Thu, 29 Apr 2010 11:00:32 +0200 | |
changeset 36502 | 586af36cf3cc |
parent 32299 | 5f33ce0ed21f |
child 40895 | c3f68ea97495 |
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 |
||
220 |
%\usepackage[greek,english]{babel} |
|
221 |
%option greek for \<euro> |
|
222 |
%option english (default language) for \<guillemotleft>, \<guillemotright> |
|
223 |
||
224 |
%\usepackage[latin1]{inputenc} |
|
225 |
%for \<onesuperior>, \<onequarter>, \<twosuperior>, \<onehalf>, |
|
226 |
%\<threesuperior>, \<threequarters>, \<degree> |
|
227 |
||
228 |
%\usepackage[only,bigsqcap]{stmaryrd} |
|
229 |
%for \<Sqinter> |
|
230 |
||
231 |
%\usepackage{eufrak} |
|
232 |
%for \<AA> ... \<ZZ>, \<aa> ... \<zz> (also included in amssymb) |
|
233 |
||
234 |
%\usepackage{textcomp} |
|
235 |
%for \<cent>, \<currency> |
|
11578 | 236 |
|
237 |
% this should be the last package used |
|
238 |
\usepackage{pdfsetup} |
|
239 |
||
13946 | 240 |
% urls in roman style, theory text in math-similar italics |
10021 | 241 |
\urlstyle{rm} |
242 |
\isabellestyle{it} |
|
9656 | 243 |
|
28180 | 244 |
% for uniform font size |
245 |
%\renewcommand{\isastyle}{\isastyleminor} |
|
246 |
||
11578 | 247 |
|
8159 | 248 |
\begin{document} |
10353 | 249 |
|
11578 | 250 |
\title{$TITLE} |
251 |
\author{$AUTHOR} |
|
252 |
\maketitle |
|
253 |
||
10308 | 254 |
\tableofcontents |
10353 | 255 |
|
25172 | 256 |
% sane default for proof documents |
25410
0ba2d51bcb42
reactivated default paragraph formatting for ``proof documents'';
wenzelm
parents:
25172
diff
changeset
|
257 |
\parindent 0pt\parskip 0.5ex |
11578 | 258 |
|
14936 | 259 |
% generated text of all theories |
8159 | 260 |
\input{session} |
10353 | 261 |
|
14936 | 262 |
% optional bibliography |
12104 | 263 |
%\bibliographystyle{abbrv} |
10353 | 264 |
%\bibliography{root} |
265 |
||
8159 | 266 |
\end{document} |
14936 | 267 |
|
268 |
%%% Local Variables: |
|
269 |
%%% mode: latex |
|
270 |
%%% TeX-master: t |
|
271 |
%%% End: |
|
8159 | 272 |
EOF |
273 |
fi |
|
11578 | 274 |
|
275 |
||
276 |
# notes |
|
277 |
||
278 |
if [ -z "$QUIET" ]; then |
|
11650 | 279 |
cat >&2 <<EOF |
11578 | 280 |
|
281 |
Notes: |
|
282 |
||
28504
7ad7d7d6df47
simplified main Isabelle executables: removed Isabelle and isabelle (replaced by isabelle-process), renamed isatool to isabelle;
wenzelm
parents:
28500
diff
changeset
|
283 |
* 'isabelle make' processes the session (including document preparation) |
11578 | 284 |
|
11650 | 285 |
* $DIR/IsaMakefile contains compilation options and file dependencies |
286 |
||
11846
2ce611f870e0
option -q also excludes -v true in generated stuff;
wenzelm
parents:
11836
diff
changeset
|
287 |
* $PREFIX/document/root.tex contains the LaTeX master document setup |
11578 | 288 |
|
11846
2ce611f870e0
option -q also excludes -v true in generated stuff;
wenzelm
parents:
11836
diff
changeset
|
289 |
* $PREFIX/ROOT.ML needs to contain ML code to load all theories |
11578 | 290 |
|
291 |
EOF |
|
292 |
fi |