8159
|
1 |
#!/bin/bash
|
|
2 |
#
|
|
3 |
# $Id$
|
|
4 |
#
|
|
5 |
# DESCRIPTION: prepare logic session directory
|
|
6 |
|
|
7 |
|
|
8 |
## diagnostics
|
|
9 |
|
|
10 |
PRG=$(basename $0)
|
|
11 |
|
|
12 |
function usage()
|
|
13 |
{
|
|
14 |
echo
|
|
15 |
echo "Usage: $PRG LOGIC NAME"
|
|
16 |
echo
|
|
17 |
echo " Options are:"
|
|
18 |
echo " -b setup build mode (session outputs heap image)"
|
|
19 |
echo " -d setup document"
|
8162
|
20 |
echo " -p include parent logic target"
|
8159
|
21 |
echo
|
|
22 |
echo " Prepare logic session directory, including IsaMakefile, document etc."
|
|
23 |
echo
|
|
24 |
exit 1
|
|
25 |
}
|
|
26 |
|
|
27 |
function fail()
|
|
28 |
{
|
|
29 |
echo "$1" >&2
|
|
30 |
exit 2
|
|
31 |
}
|
|
32 |
|
|
33 |
|
|
34 |
## process command line
|
|
35 |
|
|
36 |
# options
|
|
37 |
|
|
38 |
BUILD=""
|
|
39 |
DOCUMENT=""
|
8162
|
40 |
PARENT=""
|
8159
|
41 |
|
8162
|
42 |
while getopts "bdp" OPT
|
8159
|
43 |
do
|
|
44 |
case "$OPT" in
|
|
45 |
b)
|
|
46 |
BUILD=true
|
|
47 |
;;
|
|
48 |
d)
|
|
49 |
DOCUMENT=true
|
|
50 |
;;
|
8162
|
51 |
p)
|
|
52 |
PARENT=true
|
|
53 |
;;
|
8159
|
54 |
\?)
|
|
55 |
usage
|
|
56 |
;;
|
|
57 |
esac
|
|
58 |
done
|
|
59 |
|
|
60 |
shift $(($OPTIND - 1))
|
|
61 |
|
|
62 |
|
|
63 |
# args
|
|
64 |
|
|
65 |
[ $# -ne 2 ] && usage
|
|
66 |
|
|
67 |
LOGIC="$1"; shift
|
|
68 |
NAME="$1"; shift
|
|
69 |
|
|
70 |
[ -z "$SESSION" ] && SESSION=$(basename $NAME)
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
## main
|
|
75 |
|
|
76 |
# IsaMakefile
|
|
77 |
|
|
78 |
if [ -n "$BUILD" ]; then
|
|
79 |
IMAGES="$NAME"
|
|
80 |
TEST=""
|
|
81 |
TARGET="\$(OUT)/$NAME"
|
|
82 |
USEDIR="usedir -b"
|
|
83 |
else
|
|
84 |
IMAGES=""
|
|
85 |
TEST="$NAME"
|
|
86 |
TARGET="\$(LOG)/$NAME.gz"
|
|
87 |
USEDIR="usedir"
|
|
88 |
fi
|
|
89 |
|
|
90 |
if [ -f IsaMakefile ]; then
|
|
91 |
echo "keeping $PWD/IsaMakefile" >&2
|
|
92 |
else
|
|
93 |
{ echo
|
|
94 |
echo "## targets"
|
|
95 |
echo
|
|
96 |
echo "default: $NAME"
|
|
97 |
echo "images: $IMAGES"
|
|
98 |
echo "test: $TEST"
|
|
99 |
echo
|
|
100 |
echo "all: images test"
|
|
101 |
echo
|
|
102 |
echo
|
|
103 |
echo "## global settings"
|
|
104 |
echo
|
|
105 |
echo "SRC = \$(ISABELLE_HOME)/src"
|
|
106 |
echo "OUT = \$(ISABELLE_OUTPUT)"
|
|
107 |
echo "LOG = \$(OUT)/log"
|
|
108 |
echo "INFO = \$(ISABELLE_BROWSER_INFO)"
|
|
109 |
echo
|
|
110 |
echo
|
|
111 |
echo "## $NAME"
|
|
112 |
echo ""
|
8162
|
113 |
if [ -n "$PARENT" ]; then
|
|
114 |
echo "$NAME: $LOGIC $TARGET"
|
|
115 |
echo
|
|
116 |
echo "$LOGIC:"
|
|
117 |
echo -e "\t@cd \$(SRC)/$LOGIC; \$(ISATOOL) make $LOGIC"
|
|
118 |
echo
|
|
119 |
echo "$TARGET: \$(OUT)/$LOGIC ## add $NAME sources here"
|
|
120 |
echo -e "\t@\$(ISATOOL) $USEDIR \$(OUT)/$LOGIC $NAME"
|
|
121 |
else
|
|
122 |
echo "$NAME: $TARGET"
|
|
123 |
echo
|
|
124 |
echo "$TARGET: ## add $NAME sources here"
|
|
125 |
echo -e "\t@\$(ISATOOL) $USEDIR $LOGIC $NAME"
|
|
126 |
fi
|
8159
|
127 |
echo
|
|
128 |
echo
|
|
129 |
echo "## clean"
|
|
130 |
echo
|
|
131 |
echo "clean:"
|
|
132 |
echo -e "\t@rm -f $TARGET"
|
|
133 |
echo
|
|
134 |
} >IsaMakefile
|
|
135 |
fi
|
|
136 |
|
|
137 |
|
|
138 |
# base directory
|
|
139 |
|
|
140 |
if [ -z "$BUILD" ]; then
|
|
141 |
mkdir -p "$NAME" || fail "Bad directory: $PWD/$NAME"
|
|
142 |
cd "$NAME"
|
|
143 |
fi
|
|
144 |
|
|
145 |
if [ -f ROOT.ML ]; then
|
|
146 |
echo "keeping $PWD/ROOT.ML" >&2
|
|
147 |
else
|
|
148 |
echo -e "\n(* use_thy \"YourTheory\"; *)\n" >ROOT.ML
|
|
149 |
fi
|
|
150 |
|
|
151 |
|
|
152 |
# document directory
|
|
153 |
|
|
154 |
if [ -n "$DOCUMENT" ]; then
|
|
155 |
if [ -e document ]; then
|
|
156 |
echo "keeping $PWD/document" >&2
|
|
157 |
else
|
|
158 |
mkdir document || fail "Bad directory: $PWD/document"
|
|
159 |
cat >document/root.tex <<EOF
|
|
160 |
|
|
161 |
\documentclass[11pt,a4paper]{article}
|
|
162 |
\usepackage{isabelle,isabellesym,pdfsetup}
|
|
163 |
|
|
164 |
\begin{document}
|
|
165 |
\input{session}
|
|
166 |
\end{document}
|
|
167 |
|
|
168 |
EOF
|
|
169 |
fi
|
|
170 |
fi
|