-# Skript, das die neue Bibliothek zusammenbauen soll
+# Skript, das die neue Bibliothek zusammenbauen soll (01.01.06)
-OWN = o$$al o$$la o$$pl o$$pb i$$pa
-OWN_1=$(foreach obj, $(OWN),$(obj).asm)
-OWN_2=$(OWN_1:.asm=.obj)
-OWN_3=$(shell echo $(subst $$,\$$,$(OWN)) | dd conv=ucase 2>/dev/null)
+SRC_DIR = src
+OBJ_DIR = obj
+LIB_DIR = lib
-ORG_USE=I$$AB I$$AI O$$AI O$$AB
-
-ASM=$H316/bin/asm
+MODULES = o$$al o$$la o$$pl o$$pb i$$pa
-##########################################
+FRTN_COMMAND = frtn
+ASM_COMMAND = asm
+LDC_COMMAND = ldc
-all: io.lib
+SRC_FILES = $(foreach obj, $(MODULES),$(obj).asm)
+OBJ_FILES = $(SRC_FILES:.asm=.obj)
+OBJ_FILES_FULL = $(foreach file, $(OBJ_FILES),$(OBJ_DIR)/$(file))
-io.lib: $(foreach org, $(ORG_USE), original/$(org)) $(OWN_3)
- @echo Baue Bibliothek endgültig zusammen.
- cat $(subst $$,\$$,\
- $(OWN_3)\
- $(foreach og, $(ORG_USE),original/$(og))\
- )\
- $(H316)/snippets/endseq \
- > io.lib || rm io.lib
+##########################################
-obj object objects : $(OWN_2)
+libs : $(OBJ_FILES_FULL)
+ buildlib.sh
-$(OWN_3): $(OWN_2)
- cat $(subst $$,\$$,$(OWN_2)) | ldc -s -l
+obj : $(OBJ_FILES_FULL)
-$(OWN_2):%.obj:src/%.asm
- asm $(subst $$,\$$,$^)
+$(OBJ_FILES_FULL):$(OBJ_DIR)/%.obj:$(SRC_DIR)/%.asm
+ @echo Building: $(subst $$,\$$,$@)
+ @if [ ! -d $(OBJ_DIR) ]; then mkdir $(OBJ_DIR); fi
+ @ rm -f $@
+ @ cd $(OBJ_DIR) && $(ASM_COMMAND) ../$(subst $$,\$$,$^)
+ @ cd $(OBJ_DIR) && ldc -s -l $(notdir $(subst $$,\$$,$@))
clean:
- @rm -f *.obj $(subst $$,\$$,$(OWN_3) $(foreach obj,$(OWN_2),src/$(obj))) io.lib *.lst
+ @echo Cleaning up.
+ @rm -rf $(OBJ_DIR) $(LIB_DIR) *.lst *.go
+ @buildlib.sh clean
+org:
+ ./makeorg.sh
+
+.PHONY: clean all org obj libs
-###########
-.PHONY: clean all obj object objects
-
--- /dev/null
+#!/bin/bash
+
+# Here we find the recipes for the libraries.
+RECIPE_DIR=recipe
+
+# 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
+}
+
+# Generate org directory containing the original library objects
+make_org() {
+ if [ ! -d "$ORG_OBJDIR" ]; then
+ mkdir $ORG_OBJDIR
+ fi
+ tdir=$PWD
+ cd $ORG_OBJDIR
+ 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!"
+ fi
+
+
+
+ RECIPE_LIST=`ls $RECIPE_DIR/*$RECIPE_SUFFIX`
+ for recipe in $RECIPE_LIST; do
+ lib=$OUTPUT_DIR/`basename $recipe $RECIPE_SUFFIX`$LIB_SUFFIX
+ echo "Building $lib:"
+ rm -f $lib
+ for item in `cat $recipe`; do
+ if ! echo $item | egrep -q " *#"; then
+ echo "appending $item."
+ cat $item >> $lib || (echo "Error! could not find:$item")
+ fi
+ done
+ cat $ENDBLOCK >> $lib
+ done
+}
+
+
+case $1 in
+ clean)
+ echo "Clean!"
+ clean
+ ;;
+ makeorg)
+ echo "Make org!"
+ make_org
+ ;;
+ lib)
+ echo "Build Lib!"
+ genlib
+ ;;
+ *)
+ clean
+ make_org
+ genlib
+ ;;
+esac
+