*** empty log message ***
[h316.git] / lib / iolib / buildlib.sh
CommitLineData
6c33b62d 1#!/bin/bash
2
3# Here we find the recipes for the libraries.
4RECIPE_DIR=recipe
5
6# And their file suffix
7RECIPE_SUFFIX=.recipe
8
9# Here go the new libraries
10OUTPUT_DIR=./lib
11
12# This is needed as end-of-tape block for the loader
13ENDBLOCK=$H316/snippets/endseq
14
15# Where to get the original libraries:
16ORG_LIBDIR=original
17
18# And where to store the original objects
19ORG_OBJDIR=org
20
21# The suffix for library files (in and out)
22LIB_SUFFIX=.lib
23#######################################################################
24IFS="
25"
26
27# Clean everything up
28clean() {
29 rm -rf $OUTPUT_DIR $ORG_OBJDIR
30}
31
32# Generate org directory containing the original library objects
33make_org() {
34 if [ ! -d "$ORG_OBJDIR" ]; then
35 mkdir $ORG_OBJDIR
36 fi
37 tdir=$PWD
38 cd $ORG_OBJDIR
39 cat $tdir/$ORG_LIBDIR/*$LIB_SUFFIX | ldc -s -l
40 cd $tdir
41}
42
43genlib(){
44 echo "Library Builder start."
45 if [ ! -d "$OUTPUT_DIR" ]; then
46 echo -n "Creating $OUTPUT_DIR:"
47 mkdir $OUTPUT_DIR && echo "Ok." || echo "FAILED!"
48 fi
49
50
51
52 RECIPE_LIST=`ls $RECIPE_DIR/*$RECIPE_SUFFIX`
53 for recipe in $RECIPE_LIST; do
54 lib=$OUTPUT_DIR/`basename $recipe $RECIPE_SUFFIX`$LIB_SUFFIX
55 echo "Building $lib:"
56 rm -f $lib
57 for item in `cat $recipe`; do
58 if ! echo $item | egrep -q " *#"; then
59 echo "appending $item."
60 cat $item >> $lib || (echo "Error! could not find:$item")
61 fi
62 done
63 cat $ENDBLOCK >> $lib
64 done
65}
66
67
68case $1 in
69 clean)
70 echo "Clean!"
71 clean
72 ;;
73 makeorg)
74 echo "Make org!"
75 make_org
76 ;;
77 lib)
78 echo "Build Lib!"
79 genlib
80 ;;
81 *)
82 clean
83 make_org
84 genlib
85 ;;
86esac
87