author | berghofe |
Tue, 24 Jun 2003 10:41:13 +0200 | |
changeset 14068 | d743b3b8f06e |
parent 13948 | 8d5de16583ef |
child 14936 | a13d5118f628 |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
8159 | 2 |
# |
3 |
# $Id$ |
|
9788 | 4 |
# Author: Markus Wenzel, TU Muenchen |
5 |
# License: GPL (GNU GENERAL PUBLIC LICENSE) |
|
8159 | 6 |
# |
7 |
# DESCRIPTION: prepare logic session directory |
|
8 |
||
9 |
||
10 |
## diagnostics |
|
11 |
||
10511 | 12 |
PRG="$(basename "$0")" |
8159 | 13 |
|
14 |
function usage() |
|
15 |
{ |
|
16 |
echo |
|
9237 | 17 |
echo "Usage: $PRG [OPTIONS] [LOGIC] NAME" |
8159 | 18 |
echo |
19 |
echo " Options are:" |
|
8198 | 20 |
echo " -I FILE alternative IsaMakefile output" |
8211 | 21 |
echo " -P include parent logic target" |
8159 | 22 |
echo " -b setup build mode (session outputs heap image)" |
11578 | 23 |
echo " -q quiet mode" |
8159 | 24 |
echo |
11578 | 25 |
echo " Prepare session directory, including IsaMakefile and document source" |
8199 | 26 |
echo " with parent LOGIC (default ISABELLE_LOGIC=$ISABELLE_LOGIC)" |
8159 | 27 |
echo |
28 |
exit 1 |
|
29 |
} |
|
30 |
||
31 |
function fail() |
|
32 |
{ |
|
33 |
echo "$1" >&2 |
|
34 |
exit 2 |
|
35 |
} |
|
36 |
||
37 |
||
38 |
## process command line |
|
39 |
||
40 |
# options |
|
41 |
||
8198 | 42 |
ISAMAKEFILE="IsaMakefile" |
8211 | 43 |
PARENT="" |
8159 | 44 |
BUILD="" |
11578 | 45 |
QUIET="" |
8159 | 46 |
|
11578 | 47 |
while getopts "I:Pbq" OPT |
8159 | 48 |
do |
49 |
case "$OPT" in |
|
8198 | 50 |
I) |
51 |
ISAMAKEFILE="$OPTARG" |
|
52 |
;; |
|
8211 | 53 |
P) |
54 |
PARENT=true |
|
55 |
;; |
|
8159 | 56 |
b) |
57 |
BUILD=true |
|
58 |
;; |
|
11578 | 59 |
q) |
60 |
QUIET=true |
|
8159 | 61 |
;; |
62 |
\?) |
|
63 |
usage |
|
64 |
;; |
|
65 |
esac |
|
66 |
done |
|
67 |
||
68 |
shift $(($OPTIND - 1)) |
|
69 |
||
70 |
||
71 |
# args |
|
72 |
||
73 |
||
9788 | 74 |
if [ "$#" -eq 1 ]; then |
8194 | 75 |
LOGIC="$ISABELLE_LOGIC" |
8685 | 76 |
DIR_NAME="$1"; shift |
9788 | 77 |
elif [ "$#" -eq 2 ]; then |
8194 | 78 |
LOGIC="$1"; shift |
8685 | 79 |
DIR_NAME="$1"; shift |
8194 | 80 |
else |
81 |
usage |
|
82 |
fi |
|
8159 | 83 |
|
8685 | 84 |
DIR=$(dirname "$DIR_NAME") |
85 |
NAME=$(basename "$DIR_NAME") |
|
8159 | 86 |
|
87 |
||
88 |
## main |
|
89 |
||
11578 | 90 |
[ -z "$QUIET" ] && echo "Preparing session \"$NAME\" ..." |
91 |
||
92 |
||
8159 | 93 |
# IsaMakefile |
94 |
||
8685 | 95 |
mkdir -p "$DIR" || fail "Bad directory: $DIR" |
96 |
cd "$DIR" |
|
97 |
||
8244 | 98 |
DOCUMENT_ROOT="" |
11846
2ce611f870e0
option -q also excludes -v true in generated stuff;
wenzelm
parents:
11836
diff
changeset
|
99 |
VERBOSE="" |
2ce611f870e0
option -q also excludes -v true in generated stuff;
wenzelm
parents:
11836
diff
changeset
|
100 |
[ -z "$QUIET" ] && VERBOSE="-v true " |
8244 | 101 |
|
8159 | 102 |
if [ -n "$BUILD" ]; then |
103 |
IMAGES="$NAME" |
|
104 |
TEST="" |
|
105 |
TARGET="\$(OUT)/$NAME" |
|
8244 | 106 |
ROOT_ML="ROOT.ML" |
8579 | 107 |
SOURCES="*.thy" |
11578 | 108 |
DOCUMENT_ROOT="document/root.tex" |
8194 | 109 |
USEDIR="\$(USEDIR) -b -P http://isabelle.in.tum.de/library" |
8159 | 110 |
else |
111 |
IMAGES="" |
|
112 |
TEST="$NAME" |
|
8211 | 113 |
TARGET="\$(LOG)/$LOGIC-$NAME.gz" |
8244 | 114 |
ROOT_ML="$NAME/ROOT.ML" |
8579 | 115 |
SOURCES="$NAME/*.thy" |
11578 | 116 |
DOCUMENT_ROOT="$NAME/document/root.tex" |
8194 | 117 |
USEDIR="\$(USEDIR)" |
8159 | 118 |
fi |
119 |
||
8198 | 120 |
if [ "$ISAMAKEFILE" != - -a -f "$ISAMAKEFILE" ]; then |
11578 | 121 |
echo "keeping $DIR/$ISAMAKEFILE" >&2 |
8159 | 122 |
else |
11650 | 123 |
[ -z "$QUIET" -a -n "$ISAMAKEFILE" -a "$ISAMAKEFILE" != - ] && \ |
124 |
echo "creating $DIR/$ISAMAKEFILE" >&2 |
|
8159 | 125 |
{ echo |
126 |
echo "## targets" |
|
127 |
echo |
|
128 |
echo "default: $NAME" |
|
129 |
echo "images: $IMAGES" |
|
130 |
echo "test: $TEST" |
|
131 |
echo |
|
132 |
echo "all: images test" |
|
133 |
echo |
|
134 |
echo |
|
135 |
echo "## global settings" |
|
136 |
echo |
|
137 |
echo "SRC = \$(ISABELLE_HOME)/src" |
|
138 |
echo "OUT = \$(ISABELLE_OUTPUT)" |
|
139 |
echo "LOG = \$(OUT)/log" |
|
11578 | 140 |
echo |
12477
8f5e0a335ca7
option "-d pdf" by default (accomodates pdf bias of Mac OS X);
wenzelm
parents:
12336
diff
changeset
|
141 |
echo "USEDIR = \$(ISATOOL) usedir ${VERBOSE}-i true -d pdf ## -D generated" |
8159 | 142 |
echo |
143 |
echo |
|
144 |
echo "## $NAME" |
|
145 |
echo "" |
|
8162 | 146 |
if [ -n "$PARENT" ]; then |
147 |
echo "$NAME: $LOGIC $TARGET" |
|
148 |
echo |
|
149 |
echo "$LOGIC:" |
|
150 |
echo -e "\t@cd \$(SRC)/$LOGIC; \$(ISATOOL) make $LOGIC" |
|
151 |
echo |
|
13946 | 152 |
echo "$TARGET: \$(OUT)/$LOGIC $ROOT_ML $DOCUMENT_ROOT ## $SOURCES" |
8194 | 153 |
echo -e "\t@$USEDIR \$(OUT)/$LOGIC $NAME" |
8162 | 154 |
else |
155 |
echo "$NAME: $TARGET" |
|
156 |
echo |
|
13946 | 157 |
echo "$TARGET: ## $ROOT_ML $DOCUMENT_ROOT $SOURCES" |
8194 | 158 |
echo -e "\t@$USEDIR $LOGIC $NAME" |
8162 | 159 |
fi |
8159 | 160 |
echo |
161 |
echo |
|
162 |
echo "## clean" |
|
163 |
echo |
|
164 |
echo "clean:" |
|
165 |
echo -e "\t@rm -f $TARGET" |
|
8198 | 166 |
} | { |
167 |
if [ -z "$ISAMAKEFILE" -o "$ISAMAKEFILE" = - ]; then |
|
168 |
cat |
|
169 |
else |
|
170 |
cat > "$ISAMAKEFILE" |
|
171 |
fi |
|
172 |
} |
|
8159 | 173 |
fi |
174 |
||
175 |
||
176 |
# base directory |
|
177 |
||
178 |
if [ -z "$BUILD" ]; then |
|
11578 | 179 |
mkdir -p "$NAME" || fail "Bad directory: $DIR/$NAME" |
8159 | 180 |
cd "$NAME" |
11578 | 181 |
PREFIX="$DIR/$NAME" |
182 |
else |
|
183 |
PREFIX="$DIR" |
|
8159 | 184 |
fi |
185 |
||
186 |
if [ -f ROOT.ML ]; then |
|
11578 | 187 |
echo "keeping $PREFIX/ROOT.ML" >&2 |
8159 | 188 |
else |
11650 | 189 |
[ -z "$QUIET" ] && echo "creating $PREFIX/ROOT.ML" >&2 |
11578 | 190 |
cat >ROOT.ML <<EOF |
191 |
(* |
|
192 |
no_document use_thy "ThisTheory"; |
|
193 |
use_thy "ThatTheory"; |
|
194 |
*) |
|
195 |
EOF |
|
8159 | 196 |
fi |
197 |
||
198 |
||
199 |
# document directory |
|
200 |
||
11578 | 201 |
#set by configure |
202 |
AUTO_PERL=perl |
|
203 |
||
204 |
if [ -e document ]; then |
|
205 |
echo "keeping $PREFIX/document" >&2 |
|
206 |
else |
|
11650 | 207 |
[ -z "$QUIET" ] && echo "creating $PREFIX/document" >&2 |
11578 | 208 |
mkdir document || fail "Bad directory: $PREFIX/document" |
11650 | 209 |
|
210 |
[ -z "$QUIET" ] && echo "creating $PREFIX/document/root.tex" >&2 |
|
11578 | 211 |
TITLE=$(echo "$NAME" | tr _ -) |
12477
8f5e0a335ca7
option "-d pdf" by default (accomodates pdf bias of Mac OS X);
wenzelm
parents:
12336
diff
changeset
|
212 |
AUTHOR=$("$AUTO_PERL" -e "@pw = getpwnam(\"$USER\"); print @pw[6]" | tr _ -) |
11578 | 213 |
cat >document/root.tex <<EOF |
8159 | 214 |
\documentclass[11pt,a4paper]{article} |
11578 | 215 |
\usepackage{isabelle,isabellesym} |
8159 | 216 |
|
11578 | 217 |
% further packages required for unusual symbols (see also isabellesym.sty) |
13946 | 218 |
% use only when needed |
13948 | 219 |
%\usepackage{amssymb} % for \<leadsto>, \<box>, \<diamond>, |
13946 | 220 |
% \<sqsupset>, \<mho>, \<Join>, |
13948 | 221 |
% \<lhd>, \<lesssim>, \<greatersim>, |
13946 | 222 |
% \<lessapprox>, \<greaterapprox>, |
223 |
% \<triangleq>, \<yen>, \<lozenge> |
|
13948 | 224 |
%\usepackage[greek,english]{babel} % greek for \<euro>, |
225 |
% english for \<guillemotleft>, |
|
226 |
% \<guillemotright> |
|
227 |
% default language = last |
|
13946 | 228 |
%\usepackage[latin1]{inputenc} % for \<onesuperior>, \<onequarter>, |
229 |
% \<twosuperior>, \<onehalf>, |
|
230 |
% \<threesuperior>, \<threequarters>, |
|
231 |
% \<degree> |
|
232 |
%\usepackage[only,bigsqcap]{stmaryrd} % for \<Sqinter> |
|
233 |
%\usepackage{eufrak} % for \<AA> ... \<ZZ>, \<aa> ... \<zz> |
|
13948 | 234 |
% (only needed if amssymb not used) |
235 |
%\usepackage{textcomp} % 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 |
|
11578 | 244 |
|
8159 | 245 |
\begin{document} |
10353 | 246 |
|
11578 | 247 |
\title{$TITLE} |
248 |
\author{$AUTHOR} |
|
249 |
\maketitle |
|
250 |
||
10308 | 251 |
\tableofcontents |
10353 | 252 |
|
253 |
\parindent 0pt\parskip 0.5ex |
|
11578 | 254 |
|
255 |
% include generated text of all theories |
|
8159 | 256 |
\input{session} |
10353 | 257 |
|
12104 | 258 |
%\bibliographystyle{abbrv} |
10353 | 259 |
%\bibliography{root} |
260 |
||
8159 | 261 |
\end{document} |
262 |
EOF |
|
263 |
fi |
|
11578 | 264 |
|
265 |
||
266 |
# notes |
|
267 |
||
268 |
if [ -z "$QUIET" ]; then |
|
11650 | 269 |
cat >&2 <<EOF |
11578 | 270 |
|
271 |
Notes: |
|
272 |
||
273 |
* 'isatool make' processes the session (including document preparation) |
|
274 |
||
11650 | 275 |
* $DIR/IsaMakefile contains compilation options and file dependencies |
276 |
||
11846
2ce611f870e0
option -q also excludes -v true in generated stuff;
wenzelm
parents:
11836
diff
changeset
|
277 |
* $PREFIX/document/root.tex contains the LaTeX master document setup |
11578 | 278 |
|
11846
2ce611f870e0
option -q also excludes -v true in generated stuff;
wenzelm
parents:
11836
diff
changeset
|
279 |
* $PREFIX/ROOT.ML needs to contain ML code to load all theories |
11578 | 280 |
|
281 |
EOF |
|
282 |
fi |