*** empty log message ***
[h316.git] / lib / iolib / buildlib.sh
1 #!/bin/bash
2
3 # Here we find the recipes for the libraries.
4 RECIPE_DIR=recipe
5
6 # And their file suffix
7 RECIPE_SUFFIX=.recipe
8
9 # Here go the new libraries
10 OUTPUT_DIR=./lib
11
12 # This is needed as end-of-tape block for the loader
13 ENDBLOCK=$H316/snippets/endseq
14
15 # Where to get the original libraries:
16 ORG_LIBDIR=original
17
18 # And where to store the original objects
19 ORG_OBJDIR=org
20
21 # The suffix for library files (in and out)
22 LIB_SUFFIX=.lib
23 #######################################################################
24 IFS="
25 "
26
27 # Clean everything up
28 clean() {
29 rm -rf $OUTPUT_DIR $ORG_OBJDIR
30 }
31
32 # Generate org directory containing the original library objects
33 make_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
43 genlib(){
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
68 case $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 ;;
86 esac
87