*** empty log message ***
[h316.git] / lib / fortran / buildlib.sh
index 034169123045f1436c9bacd16d50eb2092c6ecbd..5362e8779bc001d22ac0094cb5d55723a8d5c52e 100755 (executable)
@@ -1,31 +1,20 @@
 #!/bin/bash
 
-# Here we find the recipes for the libraries.
-RECIPE_DIR=recipe
+if [ ! "$MAKE" ]; then
+    echo "Not run from within Makefile!"
+    exit 4
+fi
 
-# And their file suffix
-RECIPE_SUFFIX=.recipe
-
-# Here go the new libraries
-OUTPUT_DIR=./lib
-
-# This is needed as end-of-tape block for the loader
-ENDBLOCK=$H316/snippets/endseq
-
-# Where to get the original libraries:
-ORG_LIBDIR=original
-
-# And where to store the original objects
-ORG_OBJDIR=org
 
 # The suffix for library files (in and out)
 LIB_SUFFIX=.lib
 #######################################################################
-
+IFS="
+"
 
 # Clean everything up
 clean() {
-    rm -rf $OUTPUT_DIR $ORG_OBJDIR
+    rm -rf $LIB_DIR $ORG_OBJDIR
 }
 
 # Generate org directory containing the original library objects
@@ -35,30 +24,29 @@ make_org() {
     fi
     tdir=$PWD
     cd $ORG_OBJDIR
-    cat $tdir/$ORG_LIBDIR/*$LIB_SUFFIX | ldc -s
+    cat $tdir/$ORG_LIBDIR/*$LIB_SUFFIX | ldc -s -l
     cd $tdir
 }
 
 genlib(){
     echo "Library Builder start."
-    if [ ! -d "$OUTPUT_DIR" ]; then
-       echo -n "Creating $OUTPUT_DIR:"
-       mkdir  $OUTPUT_DIR && echo "Ok." || echo "FAILED!"
+    if [ ! -d "$LIB_DIR" ]; then
+       echo -n "Creating $LIB_DIR:"
+       mkdir  $LIB_DIR && echo "Ok." || echo "FAILED!"
     fi
     
-    
-    
-    RECIPE_LIST=`ls $RECIPE_DIR/*$RECIPE_SUFFIX`
-    for recipe in $RECIPE_LIST; do
-       lib=$OUTPUT_DIR/`basename $recipe $RECIPE_SUFFIX`$LIB_SUFFIX
+   # RECIPE_LIST=`ls $RECIPE_DIR/*$RECIPE_SUFFIX`
+   # for recipe in $RECIPE_LIST; do
+    recipe=$1
+    lib=$LIB_DIR/`basename $recipe $RECIPE_SUFFIX`$LIB_SUFFIX
        echo "Building $lib:"
        rm -f $lib
-       for item in `cat $recipe`; do
+       for item in `cat $recipe| egrep -v '^[[:space:]]*(#.*)*$'`; do
            echo "appending $item."
-           cat $item >> $lib || (echo "Error! could not find:$item")
+           cat `echo $item| egrep -o '[^[:space:]].*[^[:space:]]'` >> $lib || (echo "Error! could not find:$item")
         done   
            cat $ENDBLOCK >> $lib
-    done
+    #done
 }
     
 
@@ -71,9 +59,9 @@ case $1 in
        echo "Make org!"
        make_org
     ;;
-    lib)
+    genlib)
        echo "Build Lib!"
-       genlib
+       genlib  $2
     ;;
     *)
        clean