From fe67c7bef2222497d18eff18f29f69216ca40afe Mon Sep 17 00:00:00 2001
From: hachti <hachti>
Date: Wed, 30 May 2007 02:51:16 +0000
Subject: [PATCH] Changed everything towards LDC2 use. Worked on the
 buildlib.sh. Centralized  buildlib.sh to a new lib/common directory.

---
 Makefile                            |  5 +-
 bin/asm_original                    |  6 +--
 bin/mklink.sh                       |  9 +++-
 bin/rmlink.sh                       |  7 +++
 lib/{fortran => common}/buildlib.sh | 24 +++++-----
 lib/fortran/Makefile                | 10 ++--
 lib/iolib/Makefile                  | 25 ++++++----
 lib/iolib/buildlib.sh               | 72 -----------------------------
 pc-tools/ldc2/src/main.cpp          | 15 ++++--
 pc-tools/ldc2/src/tool.hh           | 11 +++--
 10 files changed, 70 insertions(+), 114 deletions(-)
 rename lib/{fortran => common}/buildlib.sh (64%)
 delete mode 100755 lib/iolib/buildlib.sh

diff --git a/Makefile b/Makefile
index 8480e37..b6da401 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # Toplevel Makefile for Hachti's H316 stuff collection
 
 # First we need the PC side tools. Nothing runs without them!
-SUBDIRS=pc-tools/ldc pc-tools/src-filters  pc-tools/boot-maker 
+SUBDIRS=pc-tools 
 
 # Now we build the libraries which are always rebuild using the original compiler and 
 # assembler tapes
@@ -27,12 +27,13 @@ SUBDIRS+=programs
 # If you want to build the docs, too: Uncomment next line:
 #SUBDIRS+=docs/manual
 
+
 default: 
 	@mklink.sh
 	@$(foreach subdir, $(SUBDIRS), $(MAKE) -C $(subdir)&&) /bin/true
 
 clean:
-	rmlink.sh
+	@rmlink.sh
 	$(foreach subdir, $(SUBDIRS), $(MAKE) -C $(subdir) $@;)
 
 %:
diff --git a/bin/asm_original b/bin/asm_original
index 7e2080d..f6becc4 100755
--- a/bin/asm_original
+++ b/bin/asm_original
@@ -6,7 +6,7 @@ if [ ! $1 ] ; then
     exit 2
 fi
 
-echo "Assembling $1 with original DAP 8K SLST!"
+echo -e "\nAssembler: Translating \"$1\" (Original DAP-16 8K SLST):"
 
 for n in $*; do
   if [ $n == "/v" ]; then
@@ -52,11 +52,11 @@ if cat $name.lst | grep "NO ERRORS IN ABOVE ASSEMBLY">/dev/null 2>&1; then
 		rm -f $name.par
 		rm -f $name.go
 	fi
-	echo "DAP-16 assembly successfull :-)"
+	echo "Assembler: Success."
 	exit 0
 fi
 cat $name.lst
-echo -e "\nDAP-16 assembly FAILED!"
+echo -e "Assembler: Failed."
 rm -f $name.obj
 exit 77
 
diff --git a/bin/mklink.sh b/bin/mklink.sh
index 1a8fd9e..ae9ba4a 100755
--- a/bin/mklink.sh
+++ b/bin/mklink.sh
@@ -35,9 +35,16 @@ ln -s -f $H316/pc-tools/src-filters/paroff $H316/bin
 ln -s -f $H316/pc-tools/src-filters/tab    $H316/bin
 ln -s -f $H316/pc-tools/src-filters/zstrip $H316/bin
 
-ln -s -f $H316/pc-tools/ldc/ldc $H316/bin
+ln -s -f $H316/pc-tools/ldc2/ldc2 $H316/bin/ldc
 ln -s -f $H316/pc-tools/boot-maker/bmaker $H316/bin
 
 ln -s -f $H316/honeywell/lib/iolib35.lib $H316/lib/iolib/original/iolib35.lib
 
 ln -s -f $H316/honeywell/lib/flib{1,2,3}.lib $H316/lib/fortran/original
+
+for nb in `ls $H316/lib/common | grep -v CVS`; do
+	n=`basename "$nb"`
+	ln -s -f "$H316/lib/common/$n" $H316/lib/fortran
+	ln -s -f "$H316/lib/common/$n" $H316/lib/iolib
+done
+		
\ No newline at end of file
diff --git a/bin/rmlink.sh b/bin/rmlink.sh
index a9d1e50..0cf9315 100755
--- a/bin/rmlink.sh
+++ b/bin/rmlink.sh
@@ -37,3 +37,10 @@ rm -f $H316/bin/bmaker
 rm -f $H316/lib/iolib/original/iolib35.lib
 
 rm -f $H316/lib/fortran/original/flib{1,2,3}.lib
+
+for nb in `ls $H316/lib/common | grep -v CVS`; do 
+	n=`basename "$nb"`
+	rm -f "$H316/lib/fortran/$n"
+	rm -f "$H316/lib/iolib/$n"
+done	
+
diff --git a/lib/fortran/buildlib.sh b/lib/common/buildlib.sh
similarity index 64%
rename from lib/fortran/buildlib.sh
rename to lib/common/buildlib.sh
index 5362e87..b5de533 100755
--- a/lib/fortran/buildlib.sh
+++ b/lib/common/buildlib.sh
@@ -20,47 +20,45 @@ clean() {
 # Generate org directory containing the original library objects
 make_org() {
     if [ ! -d "$ORG_OBJDIR" ]; then
-	mkdir  $ORG_OBJDIR
+	echo "Buildlib: Creating directory $ORG_OBJDIR."
+    	mkdir  $ORG_OBJDIR
     fi
     tdir=$PWD
     cd $ORG_OBJDIR
-    cat $tdir/$ORG_LIBDIR/*$LIB_SUFFIX | ldc -s -l
+    cat $tdir/$ORG_LIBDIR/*$LIB_SUFFIX | ldc -saq
     cd $tdir
+    touch $ORG_OBJDIR/lastrun
 }
 
 genlib(){
-    echo "Library Builder start."
     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
     recipe=$1
     lib=$LIB_DIR/`basename $recipe $RECIPE_SUFFIX`$LIB_SUFFIX
-	echo "Building $lib:"
+	echo -e "\nBuildlib: Building library \"$lib\" using recipe \"$1\":"
 	rm -f $lib
 	for item in `cat $recipe| egrep -v '^[[:space:]]*(#.*)*$'`; do
-	    echo "appending $item."
-	    cat `echo $item| egrep -o '[^[:space:]].*[^[:space:]]'` >> $lib || (echo "Error! could not find:$item")
+	    iname=`echo $item | egrep -o '[^[:space:]].*[^[:space:]]' |sed 's/.obj$//g'`
+	    echo "Buildlib: Appending \"$iname"\"
+	    cat $iname >> $lib || (echo "Error! could not find:$item";exit 3)
         done	
 	    cat $ENDBLOCK >> $lib
-    #done
+    	echo "Buildlib: Done."
 }
     
-
 case $1 in
     clean)
-	echo "Clean!"
 	clean
+	echo "Buildlib: Cleaning up."
     ;;
     makeorg)
-	echo "Make org!"
+	echo "Buildlib: Splitting original libraries."
 	make_org
     ;;
     genlib)
-	echo "Build Lib!"
 	genlib  $2
     ;;
     *)
diff --git a/lib/fortran/Makefile b/lib/fortran/Makefile
index 9fb1c4f..3767ecd 100644
--- a/lib/fortran/Makefile
+++ b/lib/fortran/Makefile
@@ -15,7 +15,7 @@ MODULES = uc f$$w4 f$$w1 pchar fpatch lpchar reboot vpunch font
 
 FRTN_COMMAND = frtn_original
 ASM_COMMAND  = asm_original
-LDC_COMMAND  = ldc
+LDC_COMMAND  = ldc -saq
 
 #############
 
@@ -46,22 +46,22 @@ SOURCE_FILES=$(foreach obj, $(MODULES), $(SRC_DIR)/$(obj).asm)
 all: $(LIBS)
 
 $(ORG_OBJECTS): $(ORG_LIBDIR)/*
-	./buildlib.sh makeorg
+	@./buildlib.sh makeorg
 
 $(OBJECTS): $(OBJECT_FILES)
 
 $(OBJECT_FILES) : $(OBJ_DIR)/%.obj : $(SRC_DIR)/%.asm
-	@echo Building: $(subst 	$$,\$$,$@)
+#	@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 $$,\$$,$@))
+	@ cd $(OBJ_DIR) && $(LDC_COMMAND) $(notdir $(subst $$,\$$,$@))
 
 $(LIBS):$(LIB_DIR)/%.lib: $(RECIPE_DIR)/%$(RECIPE_SUFFIX) $(ORG_OBJECTS) $(OBJECTS) 
 	./buildlib.sh genlib $(RECIPE_DIR)/$(basename $(notdir $@))$(RECIPE_SUFFIX)
 
 clean:
-	@echo Cleaning up.
+#	@echo Cleaning up.
 	@rm -rf $(OBJ_DIR) $(LIB_DIR) src/font.asm  *.lst *.go 
 	@$(MAKE) -C vpunch-help clean
 	@./buildlib.sh clean
diff --git a/lib/iolib/Makefile b/lib/iolib/Makefile
index 5a2d883..91d0299 100644
--- a/lib/iolib/Makefile
+++ b/lib/iolib/Makefile
@@ -15,7 +15,7 @@ MODULES = o$$al  o$$la o$$pl o$$pb i$$pa pl$$u pl$$mv
 
 FRTN_COMMAND = frtn_original
 ASM_COMMAND  = asm_original
-LDC_COMMAND  = ldc
+LDC_COMMAND  = ldc -saq
 
 #############
 
@@ -32,8 +32,8 @@ RECIPES=$(foreach recipe,$(shell ls $(RECIPE_DIR) | egrep "recipe$$" | grep -v C
 
 LIBS=$(foreach lib,$(basename $(notdir $(RECIPES))),$(LIB_DIR)/$(lib).lib)
 
-ORG_OBJECTS=$(shell cat $(RECIPES)|egrep -v '^[[:space:]]*(\#.*)*$$'|\
-                   grep $(ORG_OBJDIR)|sort -u)	
+#ORG_OBJECTS=$(shell cat $(RECIPES)|egrep -v '^[[:space:]]*(\#.*)*$$'|\
+#                   grep $(ORG_OBJDIR)|sort -u)	
 
 OBJECTS=$(shell cat $(RECIPES)|egrep -v '^[[:space:]]*(\#.*)*$$'|\
                    grep $(OBJ_DIR)|sort -u)
@@ -45,27 +45,32 @@ SOURCE_FILES=$(foreach obj, $(MODULES), $(SRC_DIR)/$(obj).asm)
 
 all: $(LIBS)
 
-$(ORG_OBJECTS): $(ORG_LIBDIR)/*
-	./buildlib.sh makeorg
+
+$(ORG_OBJDIR)/lastrun: $(ORG_LIBDIR)/*
+	@./buildlib.sh makeorg
+
+#$(ORG_OBJECTS): $(ORG_LIBDIR)/*
+#	
+#	@echo '$(ORG_OBJECTS)'
 
 $(OBJECTS): $(OBJECT_FILES)
 
 $(OBJECT_FILES) : $(OBJ_DIR)/%.obj : $(SRC_DIR)/%.asm
-	@echo Building: $(subst 	$$,\$$,$@)
+#	@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 $$,\$$,$@))
+	@ cd $(OBJ_DIR) && $(LDC_COMMAND) $(notdir $(subst $$,\$$,$@))
 
-$(LIBS):$(LIB_DIR)/%.lib: $(RECIPE_DIR)/%$(RECIPE_SUFFIX) $(ORG_OBJECTS) $(OBJECTS) 
-	./buildlib.sh genlib $(RECIPE_DIR)/$(basename $(notdir $@))$(RECIPE_SUFFIX)
+$(LIBS):$(LIB_DIR)/%.lib: $(RECIPE_DIR)/%$(RECIPE_SUFFIX) $(ORG_OBJDIR)/lastrun $(OBJECTS) 
+	@./buildlib.sh genlib $(RECIPE_DIR)/$(basename $(notdir $@))$(RECIPE_SUFFIX)
 
 
 clean:
-	@echo Cleaning up.
 	@rm -rf $(OBJ_DIR) $(LIB_DIR)  *.lst *.go 
 	@./buildlib.sh clean
 
 .PHONY: clean all
 
+.PRECIOUS: org/lastrun
 
diff --git a/lib/iolib/buildlib.sh b/lib/iolib/buildlib.sh
deleted file mode 100755
index 7486ba5..0000000
--- a/lib/iolib/buildlib.sh
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/bash
-
-if [ ! "$MAKE" ]; then
-    echo "Not run from within Makefile!"
-    exit 4
-fi
-
-
-# The suffix for library files (in and out)
-LIB_SUFFIX=.lib
-#######################################################################
-IFS="
-"
-
-# Clean everything up
-clean() {
-    rm -rf $LIB_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 "$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
-    recipe=$1
-    lib=$LIB_DIR/`basename $recipe $RECIPE_SUFFIX`$LIB_SUFFIX
-	echo "Building $lib:"
-	rm -f $lib
-	for item in `cat $recipe| egrep -v '^[[:space:]]*(#.*)*$'`; do
-	    echo "appending $item."
-	    cat $item >> $lib || (echo "Error! could not find:$item")
-        done	
-	    cat $ENDBLOCK >> $lib
-    #done
-}
-    
-
-case $1 in
-    clean)
-	echo "Clean!"
-	clean
-    ;;
-    makeorg)
-	echo "Make org!"
-	make_org
-    ;;
-    genlib)
-	echo "Build Lib!"
-	genlib  $2
-    ;;
-    *)
-	clean
-	make_org
-	genlib
-    ;;
-esac
-
diff --git a/pc-tools/ldc2/src/main.cpp b/pc-tools/ldc2/src/main.cpp
index 35f4ce6..d2270b6 100644
--- a/pc-tools/ldc2/src/main.cpp
+++ b/pc-tools/ldc2/src/main.cpp
@@ -2,11 +2,16 @@
  * 
  * LDC2 source code
  *
- * $Date: 2007/03/26 03:20:31 $
+ * $Date: 2007/05/30 02:51:16 $
  * $Author: hachti $
  *
  * $Log: main.cpp,v $
- * Revision 2.2  2007/03/26 03:20:31  hachti
+ * Revision 2.3  2007/05/30 02:51:16  hachti
+ * Changed everything towards LDC2 use.
+ * Worked on the buildlib.sh.
+ * Centralized  buildlib.sh to a new lib/common directory.
+ *
+ * Revision 2.2  2007-03-26 03:20:31  hachti
  * *** empty log message ***
  *
  * Revision 2.1  2007-03-26 01:15:21  hachti
@@ -273,9 +278,9 @@ void process_tape(){
       
       // Open file for split objects
       if (cfg_split_objects && (block->get_type()!=tape_block::TBT_EOT)){
-	if (objname=="UNKNOWN")snprintf(filename,99,"UNKNOWN%02i.obj",
+	if (objname=="UNKNOWN")snprintf(filename,99,"UNKNOWN%02i",
 					unknown_count);
-	else snprintf(filename,99,"%s.obj",objname.c_str());
+	else snprintf(filename,99,"%s",objname.c_str());
 	if (fd>-1) close (fd);
 	if (cfg_verbose) fprintf(stdwarn,"Writing file: %s\n",filename);
 	fd=open(filename,O_WRONLY|O_CREAT|O_TRUNC,0666);
@@ -289,7 +294,7 @@ void process_tape(){
       }
 
       // Open file for split objects numbered
-      snprintf(filename_numbered,99,"%03i0-%s.obj",obj_no,objname.c_str());
+      snprintf(filename_numbered,99,"%03i0-%s",obj_no,objname.c_str());
       if (cfg_split_objects_numbered){
 	close (fd_numbered);
 	if (cfg_verbose) fprintf(stdwarn,"Writing file: %s\n",filename_numbered);
diff --git a/pc-tools/ldc2/src/tool.hh b/pc-tools/ldc2/src/tool.hh
index 4919b65..1f5008b 100644
--- a/pc-tools/ldc2/src/tool.hh
+++ b/pc-tools/ldc2/src/tool.hh
@@ -2,11 +2,16 @@
  * 
  * LDC2 source code
  *
- * $Date: 2007/03/26 01:00:40 $
+ * $Date: 2007/05/30 02:51:16 $
  * $Author: hachti $
  *
  * $Log: tool.hh,v $
- * Revision 2.0  2007/03/26 01:00:40  hachti
+ * Revision 2.1  2007/05/30 02:51:16  hachti
+ * Changed everything towards LDC2 use.
+ * Worked on the buildlib.sh.
+ * Centralized  buildlib.sh to a new lib/common directory.
+ *
+ * Revision 2.0  2007-03-26 01:00:40  hachti
  * *** empty log message ***
  *
  *
@@ -39,7 +44,7 @@ void merge_vector_unique(vector<T> &target, const vector<T> & source){
 	already_present=true;
 	break;
       }
-    if (!already_present) target.insert(target.end(),source[isource]);
+    if (!already_present) target.insert(target.begin(),source[isource]);
   }
 }
 
-- 
2.32.0