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