author | wenzelm |
Sat, 01 Dec 2001 18:51:11 +0100 | |
changeset 12336 | 2d4561866642 |
parent 12104 | c058fd42b5fc |
child 12477 | 8f5e0a335ca7 |
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 |
11878 | 141 |
echo "USEDIR = \$(ISATOOL) usedir ${VERBOSE}-i true -d dvi ## -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 |
|
11836 | 152 |
echo "${NAME}.deps: ## $SOURCES" |
153 |
echo |
|
154 |
echo "$TARGET: \$(OUT)/$LOGIC $ROOT_ML $DOCUMENT_ROOT ${NAME}.deps" |
|
8194 | 155 |
echo -e "\t@$USEDIR \$(OUT)/$LOGIC $NAME" |
8162 | 156 |
else |
157 |
echo "$NAME: $TARGET" |
|
158 |
echo |
|
11836 | 159 |
echo "${NAME}.deps: ## $ROOT_ML $DOCUMENT_ROOT $SOURCES" |
160 |
echo |
|
161 |
echo "$TARGET: ${NAME}.deps" |
|
8194 | 162 |
echo -e "\t@$USEDIR $LOGIC $NAME" |
8162 | 163 |
fi |
8159 | 164 |
echo |
165 |
echo |
|
166 |
echo "## clean" |
|
167 |
echo |
|
168 |
echo "clean:" |
|
169 |
echo -e "\t@rm -f $TARGET" |
|
8198 | 170 |
} | { |
171 |
if [ -z "$ISAMAKEFILE" -o "$ISAMAKEFILE" = - ]; then |
|
172 |
cat |
|
173 |
else |
|
174 |
cat > "$ISAMAKEFILE" |
|
175 |
fi |
|
176 |
} |
|
8159 | 177 |
fi |
178 |
||
179 |
||
180 |
# base directory |
|
181 |
||
182 |
if [ -z "$BUILD" ]; then |
|
11578 | 183 |
mkdir -p "$NAME" || fail "Bad directory: $DIR/$NAME" |
8159 | 184 |
cd "$NAME" |
11578 | 185 |
PREFIX="$DIR/$NAME" |
186 |
else |
|
187 |
PREFIX="$DIR" |
|
8159 | 188 |
fi |
189 |
||
190 |
if [ -f ROOT.ML ]; then |
|
11578 | 191 |
echo "keeping $PREFIX/ROOT.ML" >&2 |
8159 | 192 |
else |
11650 | 193 |
[ -z "$QUIET" ] && echo "creating $PREFIX/ROOT.ML" >&2 |
11578 | 194 |
cat >ROOT.ML <<EOF |
195 |
(* |
|
196 |
no_document use_thy "ThisTheory"; |
|
197 |
use_thy "ThatTheory"; |
|
198 |
*) |
|
199 |
EOF |
|
8159 | 200 |
fi |
201 |
||
202 |
||
203 |
# document directory |
|
204 |
||
11578 | 205 |
#set by configure |
206 |
AUTO_PERL=perl |
|
207 |
||
208 |
if [ -e document ]; then |
|
209 |
echo "keeping $PREFIX/document" >&2 |
|
210 |
else |
|
11650 | 211 |
[ -z "$QUIET" ] && echo "creating $PREFIX/document" >&2 |
11578 | 212 |
mkdir document || fail "Bad directory: $PREFIX/document" |
11650 | 213 |
|
214 |
[ -z "$QUIET" ] && echo "creating $PREFIX/document/root.tex" >&2 |
|
11578 | 215 |
TITLE=$(echo "$NAME" | tr _ -) |
11650 | 216 |
AUTHOR=$("$AUTO_PERL" -e "@pw = getpwnam(\"$USER\"); print @pw[-3]" | tr _ -) |
11578 | 217 |
cat >document/root.tex <<EOF |
8159 | 218 |
|
219 |
\documentclass[11pt,a4paper]{article} |
|
11578 | 220 |
\usepackage{isabelle,isabellesym} |
8159 | 221 |
|
11578 | 222 |
% further packages required for unusual symbols (see also isabellesym.sty) |
223 |
%\usepackage{latexsym} |
|
224 |
%\usepackage{amssymb} |
|
225 |
%\usepackage[english]{babel} |
|
226 |
%\usepackage[latin1]{inputenc} |
|
227 |
%\usepackage[only,bigsqcap]{stmaryrd} |
|
228 |
%\usepackage{wasysym} |
|
229 |
%\usepackage{eufrak} |
|
12336 | 230 |
%\usepackage{textcomp} |
231 |
%\usepackage{marvosym} |
|
11578 | 232 |
|
233 |
% this should be the last package used |
|
234 |
\usepackage{pdfsetup} |
|
235 |
||
236 |
% proper setup for best-style documents |
|
10021 | 237 |
\urlstyle{rm} |
238 |
\isabellestyle{it} |
|
9656 | 239 |
|
11578 | 240 |
|
8159 | 241 |
\begin{document} |
10353 | 242 |
|
11578 | 243 |
\title{$TITLE} |
244 |
\author{$AUTHOR} |
|
245 |
\maketitle |
|
246 |
||
10308 | 247 |
\tableofcontents |
10353 | 248 |
|
249 |
\parindent 0pt\parskip 0.5ex |
|
11578 | 250 |
|
251 |
% include generated text of all theories |
|
8159 | 252 |
\input{session} |
10353 | 253 |
|
12104 | 254 |
%\bibliographystyle{abbrv} |
10353 | 255 |
%\bibliography{root} |
256 |
||
8159 | 257 |
\end{document} |
258 |
EOF |
|
259 |
fi |
|
11578 | 260 |
|
261 |
||
262 |
# notes |
|
263 |
||
264 |
if [ -z "$QUIET" ]; then |
|
11650 | 265 |
cat >&2 <<EOF |
11578 | 266 |
|
267 |
Notes: |
|
268 |
||
269 |
* 'isatool make' processes the session (including document preparation) |
|
270 |
||
11650 | 271 |
* $DIR/IsaMakefile contains compilation options and file dependencies |
272 |
||
11846
2ce611f870e0
option -q also excludes -v true in generated stuff;
wenzelm
parents:
11836
diff
changeset
|
273 |
* $PREFIX/document/root.tex contains the LaTeX master document setup |
11578 | 274 |
|
11846
2ce611f870e0
option -q also excludes -v true in generated stuff;
wenzelm
parents:
11836
diff
changeset
|
275 |
* $PREFIX/ROOT.ML needs to contain ML code to load all theories |
11578 | 276 |
|
277 |
EOF |
|
278 |
fi |