mkdir: prepare logic session directory;
authorwenzelm
Fri Jan 28 14:42:46 2000 +0100 (2000-01-28)
changeset 815964c272504383
parent 8158 b4700243eb9c
child 8160 837a6b515005
mkdir: prepare logic session directory;
lib/Tools/mkdir
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/lib/Tools/mkdir	Fri Jan 28 14:42:46 2000 +0100
     1.3 @@ -0,0 +1,158 @@
     1.4 +#!/bin/bash
     1.5 +#
     1.6 +# $Id$
     1.7 +#
     1.8 +# DESCRIPTION: prepare logic session directory
     1.9 +
    1.10 +
    1.11 +## diagnostics
    1.12 +
    1.13 +PRG=$(basename $0)
    1.14 +
    1.15 +function usage()
    1.16 +{
    1.17 +  echo
    1.18 +  echo "Usage: $PRG LOGIC NAME"
    1.19 +  echo
    1.20 +  echo "  Options are:"
    1.21 +  echo "    -b           setup build mode (session outputs heap image)"
    1.22 +  echo "    -d           setup document"
    1.23 +  echo
    1.24 +  echo "  Prepare logic session directory, including IsaMakefile, document etc."
    1.25 +  echo
    1.26 +  exit 1
    1.27 +}
    1.28 +
    1.29 +function fail()
    1.30 +{
    1.31 +  echo "$1" >&2
    1.32 +  exit 2
    1.33 +}
    1.34 +
    1.35 +
    1.36 +## process command line
    1.37 +
    1.38 +# options
    1.39 +
    1.40 +BUILD=""
    1.41 +DOCUMENT=""
    1.42 +
    1.43 +while getopts "bd" OPT
    1.44 +do
    1.45 +  case "$OPT" in
    1.46 +    b)
    1.47 +      BUILD=true
    1.48 +      ;;
    1.49 +    d)
    1.50 +      DOCUMENT=true
    1.51 +      ;;
    1.52 +    \?)
    1.53 +      usage
    1.54 +      ;;
    1.55 +  esac
    1.56 +done
    1.57 +
    1.58 +shift $(($OPTIND - 1))
    1.59 +
    1.60 +
    1.61 +# args
    1.62 +
    1.63 +[ $# -ne 2 ] && usage
    1.64 +
    1.65 +LOGIC="$1"; shift
    1.66 +NAME="$1"; shift
    1.67 +
    1.68 +[ -z "$SESSION" ] && SESSION=$(basename $NAME)
    1.69 +
    1.70 +
    1.71 +
    1.72 +## main
    1.73 +
    1.74 +# IsaMakefile
    1.75 +
    1.76 +if [ -n "$BUILD" ]; then
    1.77 +  IMAGES="$NAME"
    1.78 +  TEST=""
    1.79 +  TARGET="\$(OUT)/$NAME"
    1.80 +  USEDIR="usedir -b"
    1.81 +else
    1.82 +  IMAGES=""
    1.83 +  TEST="$NAME"
    1.84 +  TARGET="\$(LOG)/$NAME.gz"
    1.85 +  USEDIR="usedir"
    1.86 +fi
    1.87 +
    1.88 +if [ -f IsaMakefile ]; then
    1.89 +  echo "keeping $PWD/IsaMakefile" >&2
    1.90 +else
    1.91 +  { echo
    1.92 +    echo "## targets"
    1.93 +    echo
    1.94 +    echo "default: $NAME"
    1.95 +    echo "images: $IMAGES"
    1.96 +    echo "test: $TEST"
    1.97 +    echo
    1.98 +    echo "all: images test"
    1.99 +    echo
   1.100 +    echo
   1.101 +    echo "## global settings"
   1.102 +    echo
   1.103 +    echo "SRC = \$(ISABELLE_HOME)/src"
   1.104 +    echo "OUT = \$(ISABELLE_OUTPUT)"
   1.105 +    echo "LOG = \$(OUT)/log"
   1.106 +    echo "INFO = \$(ISABELLE_BROWSER_INFO)"
   1.107 +    echo
   1.108 +    echo
   1.109 +    echo "## $NAME"
   1.110 +    echo ""
   1.111 +    echo "$NAME: $LOGIC $TARGET"
   1.112 +    echo
   1.113 +    echo "$LOGIC:"
   1.114 +    echo -e "\t@cd \$(SRC)/$LOGIC; \$(ISATOOL) make $LOGIC"
   1.115 +    echo
   1.116 +    echo "$TARGET: \$(OUT)/$LOGIC     ## add $NAME sources here"
   1.117 +    echo -e "\t@\$(ISATOOL) $USEDIR \$(OUT)/$LOGIC $NAME"
   1.118 +    echo
   1.119 +    echo
   1.120 +    echo "## clean"
   1.121 +    echo
   1.122 +    echo "clean:"
   1.123 +    echo -e "\t@rm -f $TARGET"
   1.124 +    echo
   1.125 +  } >IsaMakefile
   1.126 +fi
   1.127 +
   1.128 +
   1.129 +# base directory
   1.130 +
   1.131 +if [ -z "$BUILD" ]; then
   1.132 +  mkdir -p "$NAME" || fail "Bad directory: $PWD/$NAME"
   1.133 +  cd "$NAME"
   1.134 +fi
   1.135 +
   1.136 +if [ -f ROOT.ML ]; then
   1.137 +  echo "keeping $PWD/ROOT.ML" >&2
   1.138 +else
   1.139 +  echo -e "\n(* use_thy \"YourTheory\"; *)\n" >ROOT.ML
   1.140 +fi
   1.141 +
   1.142 +
   1.143 +# document directory
   1.144 +
   1.145 +if [ -n "$DOCUMENT" ]; then
   1.146 +  if [ -e document ]; then
   1.147 +    echo "keeping $PWD/document" >&2
   1.148 +  else
   1.149 +    mkdir document || fail "Bad directory: $PWD/document"
   1.150 +    cat >document/root.tex <<EOF
   1.151 +
   1.152 +\documentclass[11pt,a4paper]{article}
   1.153 +\usepackage{isabelle,isabellesym,pdfsetup}
   1.154 +
   1.155 +\begin{document}
   1.156 +\input{session}
   1.157 +\end{document}
   1.158 +
   1.159 +EOF
   1.160 +  fi
   1.161 +fi