delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/07/11/13:02:26

Date: Fri, 11 Jul 1997 19:01:26 +0200 (MET DST)
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Subject: Revision of DJGPP library building procedure
To: djgpp-workers AT delorie DOT com
Cc: Jude DaShiell <jdashiel AT eagle1 DOT eaglenet DOT com>, dj AT delorie DOT com
Message-id: <Pine.LNX.3.91.970711184035.2909A-100000@axpcl4>
MIME-version: 1.0

Hello DJ, Jude and all the rest of the gang.

As promised (some two weeks ago), here's the new library makefile
setup for DJGPP I made. Sorry for the length of it (38K), and the
time it took to get it done.

(Jude: I send this to you personally as well, as you seemed to
have got involved with rebuilding the lib from sources recently,
and had rather bad experience with the previous machinery).

It comes as a diff file relative to the current official distribution from
SimTel.net. As such, it may also contain some minor changes that are
necessary to get the library through the binutils-2.7 gas. But there
shouldn't be too many of these. 

When applying this diff file using the most-current 'patch' from Eli,
version 2.4, you might want to be additionally cautious, as this patch
file does contain several files that are new, and patch-2.4 sometimes
shows, new, surprising behaviour for this case. 

The beast may not be 100% perfect yet, but it works for building the lib
with DJGPP itself, and it can be made to work using the Linux-to-DJGPP
cross-compiler by just changing some Make variables inside makefile.def. 

One issue I've not yet fully resolved is the LFN problem: the .S<->.s
problem, and the math_private.h in libm need some kind of fixing, I think. 

Whatever you think about this, feel free to mail me (or the list) about
it. 

I'll be in a bit of a time pressure in the next months (diploma thesis to
be written), but I'll try to keep this little effort going nevertheless. 

HBB
(Hans-Bernhard Broeker, Aachen, Germany)

OK, so here's the beast itself:

diff -uwrP orig/src/debug/common/makefile lev3/src/debug/common/makefile
--- orig/src/debug/common/makefile	Wed Jul 24 03:54:54 1996
+++ lev3/src/debug/common/makefile	Fri Jul  4 02:51:22 1997
@@ -13,4 +13,9 @@
 e : $(BIN)/symify.exe
 
 $(BIN)/symify.exe : $C symify.o $(LIB)/libdbg.a $L
-	gcc -s -o $@ symify.o $(LIB)/libdbg.a 
+ifeq ($(DJGPP),)
+	$(CC) -s -o $@ symify.o -L$(LIB) -ldbg
+else
+	$(LINK)
+	$(EXE)
+endif
diff -uwrP orig/src/debug/edebug/makefile lev3/src/debug/edebug/makefile
--- orig/src/debug/edebug/makefile	Wed Jul 24 03:55:46 1996
+++ lev3/src/debug/edebug/makefile	Fri Jul  4 02:54:28 1997
@@ -11,4 +11,9 @@
 e : $(BIN)/edebug32.exe
 
 $(BIN)/edebug32.exe : $C $(EOBJS) $(LIB)/libdbg.a $L
-	gcc -s -o $@ $(EOBJS) $(LIB)/libdbg.a
+ifeq ($(DJGPP),)
+	$(CC) -s -o $@ $(EOBJS) -L$(LIB) -ldbg
+else
+	$(LINK)
+	$(EXE)
+endif
diff -uwrP orig/src/debug/fsdb/fullscr.c lev3/src/debug/fsdb/fullscr.c
--- orig/src/debug/fsdb/fullscr.c	Thu Jan 25 02:53:42 1996
+++ lev3/src/debug/fsdb/fullscr.c	Sat Jan 18 02:52:24 1997
@@ -395,7 +395,7 @@
   asm ("inb	$0xa0, %%al
 	testb	$0x20, %%al
 	jz	1f
-	xorl	%%al, %%al
+        xorb    %%al, %%al
 	outb	%%al, $0xf0
 	movb	$0x20, %%al
 	outb	%%al, $0xa0
diff -uwrP orig/src/debug/fsdb/makefile lev3/src/debug/fsdb/makefile
--- orig/src/debug/fsdb/makefile	Wed Jul 24 03:56:24 1996
+++ lev3/src/debug/fsdb/makefile	Fri Jul  4 02:55:16 1997
@@ -1,7 +1,6 @@
 # Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details
 # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
 TOP=..
-CFLAGS = -DFULLSCR -O2
 
 EOBJS += ed.o
 EOBJS += expr.o
@@ -11,9 +10,14 @@
 
 include $(TOP)/../makefile.inc
 
-GCC = gcc -I. -I- -I$(TOP)/../../include $(CFLAGS) -c $<
+CFLAGS += -DFULLSCR -Wno-error
 
 e : $(BIN)/fsdb.exe
 
 $(BIN)/fsdb.exe : $C $(EOBJS) $(LIB)/libdbg.a $L
-	gcc -s -o $@ $(EOBJS) $(LIB)/libdbg.a
+ifeq ($(DJGPP),)
+	gcc -s -o $@ $(EOBJS) -L$(LIB) -ldbg
+else
+	$(LINK)
+	$(EXE)
+endif
diff -uwrP orig/src/debug/makefile lev3/src/debug/makefile
--- orig/src/debug/makefile	Sun Nov 12 18:02:34 1995
+++ lev3/src/debug/makefile	Tue Jul  1 01:12:52 1997
@@ -5,5 +5,12 @@
 
 include $(TOP)/../makefile.lib
 
+#If the HOST is not DJGPP, it doesn't make much sense to build the
+# debuggers.
+all ::
+ifneq ($(DJGPP),)
+	../make.sh PLATFORM=$(PLATFORM) e
+endif
+
 e:
 	@rem
Only in orig/src/debug: makefile.oi
Only in orig/src/debug: makefile.rf
diff -uwrP orig/src/dxe/dxegen.c lev3/src/dxe/dxegen.c
--- orig/src/dxe/dxegen.c	Sat Apr 22 23:22:06 1995
+++ lev3/src/dxe/dxegen.c	Fri Jul  4 06:40:06 1997
@@ -45,7 +45,11 @@
     char command[1024];
     fclose(input_f);
 
-    strcpy(command,"ld -X -S -r -o dxe__tmp.o -L");
+#ifndef DJGPP_CROSSLINKER
+#define DJGPP_CROSSLINKER "ld"
+#endif
+    strcpy(command,DJGPP_CROSSLINKER);
+    strcat(command," -X -S -r -o dxe__tmp.o -L");
     strcat(command,getenv("DJDIR"));
     strcat(command,"/lib ");
     for(i=3;argv[i];i++) {
diff -uwrP orig/src/dxe/makefile lev3/src/dxe/makefile
--- orig/src/dxe/makefile	Sat Apr 22 06:05:34 1995
+++ lev3/src/dxe/makefile	Thu Jul 10 00:41:50 1997
@@ -1,9 +1,26 @@
 # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
-BIN=../../bin
-CFLAGS=-O2 -nostdinc -I../../include
-LIBRARY_PATH := ../../lib
-PATH := $(PATH);$(BIN)
-export
+#BIN=../bin
+#CFLAGS=-O2 -nostdinc -I../include -I$(DJDIR)/include
+#LIBRARY_PATH := ../../lib
+#PATH := $(PATH);$(BIN)
+#export
+
+TOP=.
+
+SRC += dxegen.c
+
+include $(TOP)/../makefile.prg
+
+ifneq ($(DJGPP_CROSSLINKER),)
+CFLAGS += -DDJGPP_CROSSLINKER=\"$(DJGPP_CROSSLINKER)\"
+endif
+
+# if PLATFORM is not DJGPP itself, then old .o files must be deleted!
+# (they may well be for a totally different platform!)
+ifeq ($(DJGPP),)
+all :: \
+	clean
+endif
 
 all :: \
 	$(BIN)/dxegen.exe \
@@ -12,9 +29,7 @@
 $(BIN)/% : %
 	cp $< $@
 
-dxegen.exe : dxegen
-	strip dxegen
-	stubify dxegen
+dxegen.exe : dxegen.o
 
 clean ::
 	-rm -f dxegen *.exe *.o
diff -uwrP orig/src/libc/crt0/gcrt0.s lev3/src/libc/crt0/gcrt0.s
--- orig/src/libc/crt0/gcrt0.s	Sat Jul 15 14:33:18 1995
+++ lev3/src/libc/crt0/gcrt0.s	Fri Jul  4 05:31:22 1997
@@ -1,3 +1,3 @@
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 #define IN_GCRT0
-#include "crt0.s"
+#include "crt0.S"
diff -uwrP orig/src/libc/makefile lev3/src/libc/makefile
--- orig/src/libc/makefile	Sun Aug 27 07:22:58 1995
+++ lev3/src/libc/makefile	Tue Jul  1 01:10:34 1997
@@ -8,20 +8,26 @@
 
 include $(TOP)/../makefile.lib
 
-.PHONY: all info tex texinfo doc libc2.tex
+.PHONY: all info tex texinfo doc # libc2.tex
 
-MKDOC = ../../bin/mkdoc
+MKDOC = $(TOP)/../bin/mkdoc.exe
 
-all : info
+all :: info
 
-libc2.tex :
+libc2.tex : $(TXHS)
 	$(MKDOC) . libc2.tex
 
-info doc : libc.tex libc2.tex
-	makeinfo --no-split libc.tex
+info doc : $(INFO)/libc.inf
+
+$(INFO)/libc.inf : libc.tex libc2.tex
+	makeinfo --no-split -o $(INFO)/libc.inf libc.tex
 
 dvi : libc.tex libc2.tex
 	texi2dvi libc.tex
 
 ps : libc.tex libc2.tex
 	texi2ps -v libc.tex
+
+clean ::
+	make -C stubs $@
+	rm -f $(INFO)/libc.inf libc2.tex
Only in orig/src/libc: makefile.oi
Only in orig/src/libc: makefile.rf
diff -uwrP orig/src/libc/posix/regex/makefile lev3/src/libc/posix/regex/makefile
--- orig/src/libc/posix/regex/makefile	Tue Jun 13 04:37:06 1995
+++ lev3/src/libc/posix/regex/makefile	Fri Jul  4 01:07:32 1997
@@ -9,3 +9,5 @@
 include $(TOP)/../makefile.inc
 
 GCC = gcc -O2 -I. -I- -I$(TOP)/../../include $(CFLAGS) -c $<
+
+CFLAGS += -Wno-error
diff -uwrP orig/src/libc/stubs/makefile lev3/src/libc/stubs/makefile
--- orig/src/libc/stubs/makefile	Sun Nov 19 06:31:06 1995
+++ lev3/src/libc/stubs/makefile	Fri Jul  4 05:53:36 1997
@@ -3,14 +3,16 @@
 
 TOP = ..
 
+include $(TOP)/../makefile.def
+
 all : makefile.oh
-	@rem.com
+	$(NO_OP)
 
-makefile.oh : $(TOP)/../../include/libc/stubs.h gen.exe makefile
-	gen.exe $<
+makefile.oh : $(DJDIR)/include/libc/stubs.h gen.exe makefile
+	./gen.exe $<
 
 gen.exe : gen.c
 	gcc -s gen.c -o gen.exe
 
 clean :
-	-rm -f *.o makefile.oh
+	-rm -f *.o makefile.oh gen.exe
diff -uwrP orig/src/libemu/makefile lev3/src/libemu/makefile
--- orig/src/libemu/makefile	Wed Jan 24 03:08:36 1996
+++ lev3/src/libemu/makefile	Fri Jul  4 06:44:02 1997
@@ -1,7 +1,11 @@
 # Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details
 # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
-LIB=../../lib
-BIN=../../bin
+TOP=.
+
+include $(TOP)/../makefile.inc
+
+LIB=../lib
+BIN=../hostbin
 CFLAGS=-O2
 
 all :: \
@@ -9,24 +13,34 @@
 	$(BIN)/emu387.dxe \
 	$E
 
+sub-all: all
+
 $(LIB)/% : %
 	cp $< $@
 
+$(BIN)/% : %
+	cp $< $@
+
 emu387.o: emu387.cc
+ifeq (1,0)
 	gcc $(CFLAGS) -c $< -o $@
+endif
 
 emudummy.o: emudummy.c
+ifeq (1,0)
 	gcc $(CFLAGS) -c $< -o $@
+endif
 
 libemu.a : emu387.o npxsetup.o ../ident.c
-	gcc -c -DLIB=libemu ../ident.c -o id_emu.o
-	ar rs libemu.a emu387.o npxsetup.o id_emu.o
+	$(CC) -c -DLIB=libemu ../ident.c -o id_emu.o
+	$(AR) rs libemu.a emu387.o npxsetup.o id_emu.o
 
 npxsetup.o : ../libc/emu387/npxsetup.c
-	gcc $(CFLAGS) -c -DIMBED_EMU387 ../libc/emu387/npxsetup.c -o npxsetup.o
+	$(CC) $(CFLAGS) -c -DIMBED_EMU387 ../libc/emu387/npxsetup.c -o npxsetup.o
 
-emu387.dxe : emu387.o emudummy.o
-	../../bin/dxegen emu387.dxe __emu_entry emu387.o id_emu.o emudummy.o -L../../lib -lgcc -lc
+emu387.dxe : emu387.o emudummy.o ../bin/dxegen.exe
+	DJDIR=$(DJDIR) ../bin/dxegen.exe emu387.dxe __emu_entry emu387.o id_emu.o emudummy.o -L$(LIB) -L$(DJDIR)/lib  -lgcc -lc
 
-clean ::
+sub-clean clean ::
 	-rm -f emu387.dxe *.o libemu.a
+	-rm -f makefile.oi makefile.ti makefile.rf
diff -uwrP orig/src/libm/log lev3/src/libm/log
--- orig/src/libm/log	Thu Jan  1 01:00:00 1970
+++ lev3/src/libm/log	Fri Jul  4 06:06:24 1997
@@ -0,0 +1,86 @@
+
+HERE=$PWD
++ HERE=/usr/local/src/djlsr-201.hbb-lev2/src/libm
+
+if [ "$1" = "-q" ]
+then
+  shift
+else
+  case " $* " in
+    *\ -k\ *) kflag=y ;;
+    *) kflag= ;;
+  esac
+  error=
+  for mf in `find . -name makefile -print | sed -n -e 's@./@@' -e '/\// p' | sort`
+  do
+    echo ----------------------------- Making $* in ${mf%/*}
+    cd $HERE/${mf%/*}
+    if [ "$kflag" ]
+    then
+      make --no-print-directory $* || error=y
+    else
+      make --no-print-directory $* || exit 1
+    fi
+  done
+  test "$error" && exit 1
+fi
++ [ PLATFORM=TARGET = -q ]
++ kflag=
++ error=
+find . -name makefile -print | sed -n -e 's@./@@' -e '/\// p' | sort
+++ find . -name makefile -print
+++ sed -n -e s@./@@ -e /\// p
+++ sort
++ echo ----------------------------- Making PLATFORM=TARGET in src
+----------------------------- Making PLATFORM=TARGET in src
++ cd /usr/local/src/djlsr-201.hbb-lev2/src/libm/src
++ [  ]
++ make --no-print-directory PLATFORM=TARGET
++ test 
+
+cd $HERE
++ cd /usr/local/src/djlsr-201.hbb-lev2/src/libm
+echo --------------------------------- Making $* for library
++ echo --------------------------------- Making PLATFORM=TARGET for library
+--------------------------------- Making PLATFORM=TARGET for library
+
+echo > makefile.oi
++ echo
+echo > makefile.rf2
++ echo
+for oh in `find . -name makefile.oh -print | sed 's/^.\///' | sort`
+do
+  prefix=${oh%/*}
+  sed -e "s/^/OBJS += /" -e "s?&/?$prefix/?g" $oh >> makefile.oi
+  sed -e "s?&/?$prefix/?g" $oh >> makefile.rf2
+done
+find . -name makefile.oh -print | sed 's/^.\///' | sort
+++ find . -name makefile.oh -print
+++ sed s/^.\///
+++ sort
++ prefix=src
++ sed -e s/^/OBJS += / -e s?&/?src/?g src/makefile.oh
++ sed -e s?&/?src/?g src/makefile.oh
+
+cmp makefile.rf2 makefile.rf || cp -p makefile.rf2 makefile.rf
++ cmp makefile.rf2 makefile.rf
+rm makefile.rf2
++ rm makefile.rf2
+
+echo > makefile.ti
++ echo
+for th in `find . -name makefile.th -print | sed 's/^.\///' | sort`
+do
+  prefix=${th%/*}
+  sed -e "s/^/TXHS += /" -e "s?&/?$prefix/?g" $th >> makefile.ti
+done
+find . -name makefile.th -print | sed 's/^.\///' | sort
+++ find . -name makefile.th -print
+++ sed s/^.\///
+++ sort
++ prefix=src
++ sed -e s/^/TXHS += / -e s?&/?src/?g src/makefile.th
+
+make $*
++ make PLATFORM=TARGET
+make: Nothing to be done for `all'.
diff -uwrP orig/src/libm/makefile lev3/src/libm/makefile
--- orig/src/libm/makefile	Sat Aug 26 23:39:20 1995
+++ lev3/src/libm/makefile	Thu Jun 26 04:08:50 1997
@@ -4,3 +4,4 @@
 LIBNAME=m
 
 include $(TOP)/../makefile.lib
+
Only in orig/src/libm: makefile.oi
Only in orig/src/libm: makefile.rf
diff -uwrP orig/src/libm/src/makefile lev3/src/libm/src/makefile
--- orig/src/libm/src/makefile	Sat Nov 18 21:26:14 1995
+++ lev3/src/libm/src/makefile	Fri Jul  4 06:00:42 1997
@@ -1,8 +1,6 @@
 # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
 TOP=..
 
-CFLAGS = -Wno-error -Wno-strict-prototypes -D_USE_LIBM_MATH_H
-
 SRC += e_acos.S
 SRC += e_acosh.c
 SRC += e_asin.S
@@ -167,4 +165,12 @@
 SRC += wrf_gamm.c
 SRC += wrf_lgam.c
 
+all :: math_private.h
+
 include $(TOP)/../makefile.inc
+
+CFLAGS += -Wno-error -Wno-strict-prototypes -D_USE_LIBM_MATH_H
+
+math_private.h: math_pri.h
+	@echo "copying math_pri.h to its real name: "
+	-cp -v $< $@
diff -uwrP orig/src/libm/src/s_finite.s lev3/src/libm/src/s_finite.s
--- orig/src/libm/src/s_finite.s	Mon Sep 26 03:09:48 1994
+++ lev3/src/libm/src/s_finite.s	Sat Jan 18 02:38:22 1997
@@ -42,6 +42,6 @@
 	movl	8(%esp),%eax
 	andl	$0x7ff00000, %eax
 	cmpl	$0x7ff00000, %eax
-	setnel	%al
+	setneb	%al
 	andl	$0x000000ff, %eax
 	ret
diff -uwrP orig/src/libm/src/sf_finit.s lev3/src/libm/src/sf_finit.s
--- orig/src/libm/src/sf_finit.s	Mon Sep 26 03:09:54 1994
+++ lev3/src/libm/src/sf_finit.s	Sat Jan 18 02:38:56 1997
@@ -42,6 +42,6 @@
 	movl	4(%esp),%eax
 	andl	$0x7ff00000, %eax
 	cmpl	$0x7ff00000, %eax
-	setnel	%al
+	setneb	%al
 	andl	$0x000000ff, %eax
 	ret
diff -uwrP orig/src/make.sh lev3/src/make.sh
--- orig/src/make.sh	Mon Jul 17 09:02:02 1995
+++ lev3/src/make.sh	Fri Jul  4 06:12:12 1997
@@ -1,7 +1,8 @@
-#!/bin/ksh
+#! /bin/bash
 
 HERE=$PWD
 
+echo ------ Starting Auto-recursing make in ${HERE}
 if [ "$1" = "-q" ]
 then
   shift
@@ -13,20 +14,20 @@
   error=
   for mf in `find . -name makefile -print | sed -n -e 's@./@@' -e '/\// p' | sort`
   do
-    echo --------------------------------------- Making $* in ${mf%/*}
+    echo ----------------------------- Making $* in ${mf%/*}
     cd $HERE/${mf%/*}
     if [ "$kflag" ]
     then
-      make $* || error=y
+      make --no-print-directory $* || error=y
     else
-      make $* || exit 1
+      make --no-print-directory $* || exit 1
     fi
   done
   test "$error" && exit 1
 fi
 
 cd $HERE
-echo --------------------------------------- Making \"$*\" for library
+echo --------------------------------- Making $* for library
 
 echo > makefile.oi
 echo > makefile.rf2
@@ -37,7 +38,14 @@
   sed -e "s?&/?$prefix/?g" $oh >> makefile.rf2
 done
 
-update makefile.rf2 makefile.rf
+cmp makefile.rf2 makefile.rf || cp -p makefile.rf2 makefile.rf
 rm makefile.rf2
 
-make.exe $*
+echo > makefile.ti
+for th in `find . -name makefile.th -print | sed 's/^.\///' | sort`
+do
+  prefix=${th%/*}
+  sed -e "s/^/TXHS += /" -e "s?&/?$prefix/?g" $th >> makefile.ti
+done
+
+make $*
diff -uwrP orig/src/makefile lev3/src/makefile
--- orig/src/makefile	Tue Dec 26 18:44:24 1995
+++ lev3/src/makefile	Thu Jul 10 02:03:02 1997
@@ -1,8 +1,93 @@
 # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
-all : rmake.exe copyrite.exe
 
-rmake.exe : rmake.cc
-	gcc -O2 rmake.cc -o rmake.exe
+srcdir=.
+CC=gcc
+YACC=bison -y
+LN=ln
+MAKEINFO=makeinfo
+SHELL=/bin/sh
 
-copyrite.exe : copyrite.cc
-	gcc -O2 copyrite.cc -o copyrite.exe
+# You may want do redefine (some of) these directories. They're
+# the ones where 'make install' will copy things to. These
+# directories must all exist when 'make install' is called!
+ifneq ($(DJGPP),)
+prefix=$(DJDIR)
+binprefix=
+else
+prefix=/usr/local
+binprefix=i386-go32-
+endif
+bindir=$(prefix)/bin
+libdir=$(prefix)/info
+includedir=$(prefix)/include
+infodir=$(prefix)/info
+
+
+# directories to put things in during the build:
+BUILDTIME_DIRECTORIES=./bin ./hostbin ./lib ./include ./info
+# directories where library sources are:
+LIBDIRS=libc libm debug libemu
+# directories with utilities needed at build time:
+BUILDUTILDIRS=utils stub dxe mkdoc
+# directories with utilities to be compiled for the host:
+HOSTUTILDIRS=stub utils dxe # mkdoc <-- mkdoc shouldn't be necessary
+
+.PHONY: all preliminaries build-utils libraries host-utils additional-infos
+
+all : preliminaries build-utils libraries host-utils additional-infos
+
+preliminaries: $(BUILDTIME_DIRECTORIES)
+
+build-utils : preliminaries
+	@echo Building utilities for the build platform:
+	set -e ; \
+	for dir in $(BUILDUTILDIRS) ; do \
+	  $(MAKE) -C $$dir PLATFORM=BUILD ; \
+	done
+
+host-utils : preliminaries
+	@echo Building utilities for the host platform:
+	set -e ; \
+	for dir in $(HOSTUTILDIRS) ; do \
+	  $(MAKE) -C $$dir PLATFORM=HOST ; \
+	done
+
+libraries : preliminaries
+	+set -e ; \
+	for dir in $(LIBDIRS) ; do \
+	  ( cd $$dir ; \
+	    ../make.sh $(MFLAGS) PLATFORM=TARGET all \
+	  ) ; \
+	done
+
+additional-infos : preliminaries
+	( cd docs/kb ; \
+	  $(MAKEINFO) kb.txi -o ../../info/kb.info \
+	)
+
+$(BUILDTIME_DIRECTORIES):
+	-@mkdir $@
+
+.PHONY : install
+install : all
+	strip hostbin/*.exe
+	( cd hostbin ; \\
+	  for $$file in *.exe; do \\
+	    cp -p $$file $(bindir)/$(binprefix)`basename $$file .exe` ; \\
+	  done )
+#	cp -p hostbin/* $(bindir)
+	cp -p lib/* $(libdir)
+	cp -p include/* $(includedir)
+	cp -p info/* $(infodir)
+
+.PHONY : clean
+clean :
+	for dir in $(LIBDIRS) ; do \
+	  echo > $$dir/makefile.oi ; \
+	  echo > $$dir/makefile.ti ; \
+	  $(MAKE) -C $$dir $@ ; \
+	done
+	for dir in $(BUILDUTILDIRS); do \
+	  $(MAKE) -C $$dir $@ ; \
+	done
+	rm -rf $(BUILDTIME_DIRECTORIES)
diff -uwrP orig/src/makefile.def lev3/src/makefile.def
--- orig/src/makefile.def	Thu Jan  1 01:00:00 1970
+++ lev3/src/makefile.def	Fri Jul 11 11:19:46 1997
@@ -0,0 +1,52 @@
+#In the makefile lines below, you might have to edit several things,
+# depending on what exactly you're trying to build, i.e. on what
+# platform a) you're building this, and b) want the built tools to run
+# on.
+
+#Uncomment and change this line iff your platform is not DJGPP itself:
+#DJDIR = /dosc/gpp
+
+ifeq ($(PLATFORM),BUILD)
+
+# Compiler for programs to be run as part of the building process:
+CC = gcc
+CFLAGS = -g -O2 
+CPPFLAGS = -I. -I$(TOP)/../include # -I/usr/src/djdev200-linux/include
+# This compiler normally shouldn't need a 'stubify' (even if it
+# is DJGPP), because the programs compiled by it will not be
+# copied anywhere else.
+STUBIFY = true
+YACC = bison -y
+#if this isn't DJGPP, you'll have to specify the name of the cross linker
+#targetting DJGPP. This is called by 'dxegen'. Defaults to 'ld'.
+#DJGPP_CROSSLINKER=i386-go32-ld
+
+else # BUILD?
+ifeq ($(PLATFORM),TARGET)
+
+# Compiler for anything that will be used only for actually running
+# DJGPP-compiled programs (i.e. the libraries and the emu387.dxe
+# module). The given setting is for a native compile. You'll have
+# to change it if your BUILD platform is not DJGPP.
+CC = gcc
+CXX = gcc
+CPPFLAGS = -I. -I- -I$(TOP)/../include -I$(DJDIR)/include
+CFLAGS = `cat $(TOP)/../gcc.opt`
+STUBIFY = $(TOP)/../bin/stubify.exe
+
+else # so this must be PLATFORM==HOST
+
+# Compiler for all programs that will run on the HOST platform. I.e. for
+# building a cross-compiler from system 'foo' to DJGPP, this compile
+# should generate binaries to run on 'foo'. The given setting
+# is meant for building native DJGPP tools.
+CC = gcc
+CPPFLAGS = -I. -I- -I$(TOP)/../include # -I/usr/src/djdev200-linux/include
+CFLAGS = -g -O3 -Wall -W
+STUBIFY = $(TOP)/../bin/stubify.exe
+YACC = bison -y
+
+endif # TARGET?
+endif # BUILD?
+
+
diff -uwrP orig/src/makefile.inc lev3/src/makefile.inc
--- orig/src/makefile.inc	Sun Sep  1 23:39:06 1996
+++ lev3/src/makefile.inc	Fri Jul 11 10:56:56 1997
@@ -1,14 +1,24 @@
+.SUFFIXES: .o .i .c .cc .S
 
-.SUFFIXES: .o .i .c .cc .s
+SHELL=/bin/sh
 
-GCC = gcc @$(TOP)/../gcc.opt -I. -I- -I$(TOP)/../../include $(CFLAGS) -c $<
+include $(TOP)/../makefile.def
 
+############# end of configuration. 'No user serviceable parts below'
+
+GCC = $(CC) $(CPPFLAGS) $(CFLAGS) -c $<
+
+ifneq (0,0)  # for the time being, I do *not* want these:
 %.o : %.c
 	$(GCC)
 %.o : %.cc
 	$(GCC)
+endif
+
 %.o : %.S
 	$(GCC)
+%.o : %.s
+	$(CC) -x assembler-with-cpp $(CPPFLAGS) $(CFLAGS) -c $<
 
 %.i : %.c
 	$(GCC) -E > $@
@@ -22,13 +32,24 @@
 %.ss : %.cc
 	$(GCC) -S > $@
 
-LINK = ld $(LDFLAGS) $(filter %.o,$^) $(filter-out %.o,$^) -o $@ ${LIB}/libgcc.a -T ${TOP}/../../lib/djgpp.djl
-EXE = ${TOP}/../../bin/stubify.exe $@
+LINK = ld $(LDFLAGS) $(filter %.o,$^) $(DJDIR)/lib/libgcc.a $(filter-out %.o,$^) -o $@ $(DJDIR)/lib/libgcc.a -T $(DJDIR)/lib/djgpp.djl
+EXE = $(STUBIFY) $@
 
-LIB=$(TOP)/../../lib
-BIN=$(TOP)/../../bin
-INC=$(TOP)/../../include
-INFO=$(TOP)/../../info
+ifneq ($(DJGPP),)
+NO_OP = @rem.com
+else
+NO_OP = @true
+endif
+
+ifeq ($(PLATFORM),BUILD)
+BIN=$(TOP)/../bin
+else
+BIN=$(TOP)/../hostbin
+endif
+
+LIB=$(TOP)/../lib
+INC=$(TOP)/../include
+INFO=$(TOP)/../info
 
 C = $(LIB)/crt0.o
 L = $(LIB)/libc.a
@@ -38,21 +59,36 @@
 
 .PRECIOUS: %.exe %.out %.err
 
-$(INFO)/%.inf : %.tex
-	makeinfo --no-split $<
+$(INFO)/%.info : %.tex
+	makeinfo --no-split -o $@ $<
 
+ifeq ($(DJGPP),)
+$(BIN)/%.exe : %.o
+	$(CC) -o $@ $(LDFLAGS) $^
+$(BIN)/% : %.o
+	$(CC) -o $@ $(LDFLAGS) $^
+else
+ifeq ($(PLATFORM),BUILD)
+$(BIN)/%.exe : %.o
+	$(CC) -o $@ $(LDFLAGS) $^
+else
 $(BIN)/%.exe : $C %.o $L
 	$(LINK)
 	$(EXE)
+endif
+endif
 
-all :: $(OBJS) $(EXTRA_OBJS) makefile.oh
-	@rem.com
+all :: $(OBJS) $(EXTRA_OBJS) makefile.oh makefile.th
+	$(NO_OP)
 
 makefile.oh : makefile
-	@echo.exe -o makefile.oh $(addprefix &/,$(OBJS))
+	@echo $(addprefix \&/,$(OBJS)) >$@
+
+makefile.th : makefile
+	@echo $(addprefix \&/,$(wildcard *.txh)) >$@
 
 clean ::
-	-rm -f *.o *.d *.i makefile.oh
+	-rm -f *.o *.d *.i makefile.oh makefile.th
 
 DEPS := $(wildcard *.d)
 ifneq ($(DEPS),)
diff -uwrP orig/src/makefile.lib lev3/src/makefile.lib
--- orig/src/makefile.lib	Sun Nov 12 19:47:38 1995
+++ lev3/src/makefile.lib	Fri Jul  4 06:06:08 1997
@@ -1,14 +1,22 @@
 OBJS :=
+TXHS :=
 
-LIB = $(TOP)/../../lib
+LIB = $(TOP)/../lib
+INFO = $(TOP)/../info
 
 include makefile.oi
+include makefile.ti
+
+all :: $(LIB)/lib$(LIBNAME).a
 
 $(LIB)/lib$(LIBNAME).a : $(OBJS) makefile.rf $(TOP)/../ident.c
 	gcc -c -DLIB=lib$(LIBNAME) $(TOP)/../ident.c -o id_$(LIBNAME).o
-	@-rm -f $@
-	ar q $(LIB)/lib$(LIBNAME).a @makefile.rf id_$(LIBNAME).o
+	rm -f $@
+	ar q $(LIB)/lib$(LIBNAME).a `cat makefile.rf` id_$(LIBNAME).o
 	ar s $(LIB)/lib$(LIBNAME).a
 
-clean :
-	@-rm -f $(LIB)/lib$(LIBNAME).a makefile.oi makefile.rf
+clean sub-clean::
+	-find . -name '*.[oid]' -print | xargs rm -f
+	-find . -name 'makefile.oh' -print | xargs rm -f
+	-find . -name 'makefile.th' -print | xargs rm -f
+	-rm -f $(LIB)/lib$(LIBNAME).a id_$(LIBNAME).o makefile.oi makefile.ti makefile.rf
Only in orig/src: makefile.oi
diff -uwrP orig/src/makefile.prg lev3/src/makefile.prg
--- orig/src/makefile.prg	Sun Aug 27 02:17:00 1995
+++ lev3/src/makefile.prg	Thu Jul 10 01:43:28 1997
@@ -1,5 +1,5 @@
 
-alle : _alle
+alle :: _alle
 
 include $(TOP)/../makefile.inc
 
diff -uwrP orig/src/mkdoc/makefile lev3/src/mkdoc/makefile
--- orig/src/mkdoc/makefile	Sun Sep  1 23:38:54 1996
+++ lev3/src/mkdoc/makefile	Wed Jun 25 00:34:38 1997
@@ -1,7 +1,16 @@
 # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
-../../bin/mkdoc.exe : mkdoc.o
-	ld ../../lib/crt0.o $^ -L../../lib/ -lgcc -lc -o ../../bin/mkdoc.exe -T ../../lib/djgpp.djl
-	../../bin/stubify -v ../../bin/mkdoc.exe
+TOP=.
+
+SRC += mkdoc.cc
+
+include $(TOP)/../makefile.prg
+
+
+../bin/mkdoc.exe : mkdoc.o
+#	ld ../../lib/crt0.o $^ -L../../lib/ -lgcc -lc -o ../../bin/mkdoc.exe -T ../../lib/djgpp.djl
+#	../../bin/stubify -v ../../bin/mkdoc.exe
+
+
 
 mkdoc.o : mkdoc.cc
-	gcc -nostdinc -I../../include -c mkdoc.cc
+#	gcc -nostdinc -I../../include -c mkdoc.cc
diff -uwrP orig/src/readme lev3/src/readme
--- orig/src/readme	Thu Jan  1 01:00:00 1970
+++ lev3/src/readme	Fri Jul 11 11:44:46 1997
@@ -0,0 +1,49 @@
+This is the revamped DJGPP libc build machinery, done in June/July 1997
+by Hans-Bernhard Br"oker. Do with it whatever you please (as long as you
+don't stop someone else from doing the same for free).
+
+How to build it:
+
+1) Unzip djlsr201.zip somewhere (can be relative to the main DJGPP
+   dir, but that's not really necessary any longer). Reading this,
+   you seem to have done that already. NB: be sure to preserve
+   the directory structure.
+2) Check the settings in 'makefile.def'. As distributed, they should
+   normally work ok, but it never hurts to check nevertheless.
+3) Prepare yourself for quite a long coffee-break, and call
+      make
+4) Some 20 minutes later (on my P100, your timing may differ), it should
+   be ready. You may now want to call 'make install' and/or run the
+   tests from djtst201.zip.
+5) Have fun.
+
+Benefits of this new setup:
+
+1) Builds from scratch with one single call of 'make'.
+2) Can be unpacked and built in a directory on its own, i.e. separate
+   from the main DJGPP directory structure.
+3) You can build the library using the Linux-to-DJGPP cross compiler as
+   found on Sunsite, with only some minor, obvious changes to
+   makefile.def.
+
+One major difference to the DJ's original method is that the newly
+built files won't immediately overwrite the binaries and libs in
+the DJGPP tree. This is triggered by a separate command.
+
+Things to watch out for in case of problems:
+
+1) There's one file with a long file name: math_private.h
+   If you unzipped this on an LFN-aware system, be sure that
+   the name of this file is correct.
+
+2) You'll need the following set of tools to build the library, in
+   addition to the basic DJGPP setup (maybe even more, I haven't really
+   checked). For all of them, the DJGPP ports should be used.
+
+   find, Bash, fileutils, textutils, sed, make, bison
+
+If you can't get this to work no matter how hard you try, just ask me:
+
+broeker AT physik DOT rwth-aachen DOT de
+
+Hans-Bernhard Br"oker, Aachen, Germany
diff -uwrP orig/src/readme.cro lev3/src/readme.cro
--- orig/src/readme.cro	Thu Jan  1 01:00:00 1970
+++ lev3/src/readme.cro	Fri Jul  4 05:51:38 1997
@@ -0,0 +1,11 @@
+Important hints for cross-compiling the libc:
+
+* You'll need a cross compiler, of course...
+
+* You'll need a directory containing *some* of the DJGPP includes
+  (*not* all of them!). So far, these are:
+	coff.h
+
+* You'll have to edit makefile.def to fill in the name of your
+  cross compiler, and the absolute path of DJDIR (either the
+  original one, or the one used by the cross compiler).
diff -uwrP orig/src/stub/djasm.y lev3/src/stub/djasm.y
--- orig/src/stub/djasm.y	Tue Aug 13 02:43:10 1996
+++ lev3/src/stub/djasm.y	Fri Jul  4 04:24:52 1997
@@ -1930,6 +1930,9 @@
   int textbase, database, bssbase, delta;
   char smallname[9];
 
+#ifndef O_BINARY  /* this will allow cross-compilation of djasm */
+#define O_BINARY 0
+#endif
   f = open (filename, O_RDONLY | O_BINARY);
   if (f < 0)
     {
diff -uwrP orig/src/stub/exe2coff.c lev3/src/stub/exe2coff.c
--- orig/src/stub/exe2coff.c	Wed Jul 12 09:28:40 1995
+++ lev3/src/stub/exe2coff.c	Thu Jul 10 00:21:12 1997
@@ -4,8 +4,14 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <string.h>
+#ifdef __DJGPP__
 #include <io.h>
+#endif
+#include <unistd.h>
 
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
 
 static void
 exe2aout(char *fname)
diff -uwrP orig/src/stub/makefile lev3/src/stub/makefile
--- orig/src/stub/makefile	Tue Jan 16 02:10:50 1996
+++ lev3/src/stub/makefile	Thu Jul 10 00:42:46 1997
@@ -1,57 +1,123 @@
 # Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details
 # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
-BIN=../../bin
-INC=../../include
-CFLAGS=-O3 -MD
-STUBIFY=../../bin/stubify.exe
-C_INCLUDE_PATH := ../../include
-LIBRARY_PATH := ../../lib
+
+TOP=.
+
+include $(TOP)/../makefile.inc
+
+ifeq ($(PLATFORM),BUILD)
+
+ifneq ($(DJGPP),)
+STUBIFY=$(BIN)/stubify.exe
+STUBEDIT=$(BIN)/stubedit.exe
+STRUPR=
+else
+STUBIFY=$(BIN)/stubify.sh
+STUBEDIT=
+STRUPR=strupr.o
+endif
+
+else # PLATFORM != BUILD, assume it's HOST:
+
+ifneq ($(DJGPP),)
+STUBIFY=$(TOP)/../bin/stubify.exe
+STRUPR=
+else
+STUBIFY=$(TOP)/../bin/stubify.sh
+STRUPR=strupr.o
+endif
+
+endif
+
+ifneq ($(DJGPP),)
+# I'm not sure if these are useful at all. On Linux, they
+# prevent building host-utils...
+INC=../include
+C_INCLUDE_PATH := ../include
+LIBRARY_PATH := ../lib
 export
+endif
+
+# FIXME: let presence of $DJGPP decide on wether this is DOS...
+ifneq ($(DJGPP),)
 PATH := $(PATH);$(BIN)
+else
+PATH := $(PATH):$(BIN)
+endif
+
+# if PLATFORM is not DJGPP itself, then old .o files must be deleted!
+# (they may well be for a totally different platform!)
+ifeq ($(DJGPP),)
+all :: \
+	clean
+endif
+
+ifeq ($(PLATFORM),BUILD)
+all :: \
+	$(BIN)/djasm.exe \
+	$(STUBIFY) \
+	stubinfo.tim \
+	$(STUBEDIT) \
+	$E
+
+else
 
 all :: \
 	$(BIN)/djasm.exe \
-	$(BIN)/go32-v2.exe \
+	stubinfo.tim \
 	$(BIN)/stubedit.exe \
 	$(BIN)/stubify.exe \
 	$(BIN)/exe2coff.exe \
-	$(INC)/stubinfo.h \
 	$E
+# if PLATFORM is DJGPP, then build go32-v2.exe as well:
+ifneq ($(DJGPP),)
+all :: \
+	$(BIN)/go32-v2.exe
+endif
 
-$(BIN)/% : %
-	cp $< $@
+endif
 
-sbrk16.ah : sbrk16.asm djasm.exe
-	../bin/djasm.exe sbrk16.asm sbrk16.ah
+%.exe : %
+ifneq ($(DJGPP),)
+	stubify $<
+else
+	cp $< $@
+endif
 
-stubify.exe : stubify
-	$(STUBIFY) stubify
+$(BIN)/% : %
+	cp $< $@
 
-exe2coff.exe : exe2coff
-	$(STUBIFY) exe2coff
+.PHONY: $(BIN)/stubify.sh
+$(BIN)/stubify.sh : stubify.sh
+	@cp $< $@
+	@chmod +x $@
 
 stubify.o : stub.h
 
-$(INC)/stubinfo.h : stub.asm stub.map stub2inc.exe
-	stub2inc stub.map stub.asm $(INC)/stubinfo.h
+stub2inc : stub2inc.o $(STRUPR)
+
+strupr.o : strupr.c
 
-stub.h stub.map : stub.asm $(BIN)/djasm.exe
-	$(BIN)/djasm.exe stub.asm stub.h stub.map
+stubinfo.tim : stubinfo.h 
+	../bin/update.exe $< $(INC)/stubinfo.h && \
+	echo "Timestamp for update of $(INC)/stubinfo.h" > $@
 
-djasm.exe : djasm
-	$(STUBIFY) djasm
+stubinfo.h : stub.asm stub.map stub2inc
+	./stub2inc stub.map stub.asm $@ 
 
-$(BIN)/go32-v2.exe : go32-v2.c
-	gcc -s $(CFLAGS) go32-v2.c -o $(BIN)/go32-v2.exe -ldbg
+stub.h stub.map : stub.asm $(TOP)/../bin/djasm.exe
+	$(TOP)/../bin/djasm.exe stub.asm stub.h stub.map
 
-stub2inc.exe : stub2inc
-	$(STUBIFY) stub2inc
+$(BIN)/go32-v2.exe : go32-v2.c $(LIB)/libdbg.a
+	$(CC) -s $(CFLAGS) go32-v2.c -o $@ -L$(LIB) -ldbg
+	$(EXE)
 
-stubedit.exe : stubedit $(INC)/stubinfo.h
-	$(STUBIFY) stubedit
+stubedit.o : stubinfo.tim
 
 clean ::
 	-rm -f *.exe djasm stub.h stub.map stubedit stubify *.o stub2inc *.d
+	-rm -f exe2coff djasm.c stubinfo.h stubinfo.tim
+	-rm -f *.s
 
 DEPS := $(wildcard *.d)
 ifneq ($(DEPS),)
diff -uwrP orig/src/stub/strupr.c lev3/src/stub/strupr.c
--- orig/src/stub/strupr.c	Thu Jan  1 01:00:00 1970
+++ lev3/src/stub/strupr.c	Thu Apr 11 22:10:34 1996
@@ -0,0 +1,15 @@
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+#include <ctype.h>
+#include <string.h>
+
+char *
+strupr(char *_s)
+{
+  char *rv = _s;
+  while (*_s)
+  {
+    *_s = toupper(*_s);
+    _s++;
+  }
+  return rv;
+}
Only in orig/src/stub: stub.map
diff -uwrP orig/src/stub/stubedit.c lev3/src/stub/stubedit.c
--- orig/src/stub/stubedit.c	Sat Oct 26 14:09:48 1996
+++ lev3/src/stub/stubedit.c	Thu Jul 10 00:15:28 1997
@@ -9,7 +9,7 @@
 #include <io.h>
 #endif
 
-#include "../../include/stubinfo.h"
+#include "../include/stubinfo.h"
 
 unsigned long size_of_stubinfo = 0;
 char *client_stub_info;
diff -uwrP orig/src/stub/stubify.sh lev3/src/stub/stubify.sh
--- orig/src/stub/stubify.sh	Thu Jan  1 01:00:00 1970
+++ lev3/src/stub/stubify.sh	Tue Jun 24 01:54:04 1997
@@ -0,0 +1,10 @@
+#! /bin/sh
+# 'fake' stubify, for BUILD platforms other than DJGPP
+if [ ! -f $1.exe ] ; then
+  if [ -f $1 ] ; then
+    ln $1 $1.exe
+  else
+    echo "\aError! stubify.sh called for nonexisting file $1"
+    exit
+  fi
+fi
diff -uwrP orig/src/utils/bin2h.c lev3/src/utils/bin2h.c
--- orig/src/utils/bin2h.c	Sun Aug 27 03:14:30 1995
+++ lev3/src/utils/bin2h.c	Thu Jul 10 01:47:30 1997
@@ -4,6 +4,10 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+#ifndef O_BINARY
+#define O_BINARY
+#endif
+
 int
 main(int argc, char **argv)
 {
diff -uwrP orig/src/utils/djtar/makefile lev3/src/utils/djtar/makefile
--- orig/src/utils/djtar/makefile	Fri Nov 17 01:10:28 1995
+++ lev3/src/utils/djtar/makefile	Tue Jul  1 02:31:58 1997
@@ -1,6 +1,7 @@
 # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
 TOP = ..
 
+CFLAGS = -Wno-error
 LDFLAGS = -s
 
 SRC += djtar.c
@@ -12,10 +13,18 @@
 $(BIN)/djtar.exe : oread.o unzip.o unlzw.o unlzh.o unpack.o inflate.o \
 	crypt.o util.o zmethod.o
 
-$(BIN)/djtarx.exe : $(BIN)/stubify.exe
-	stubify -g $(BIN)/djtarx.exe
-	stubedit $(BIN)/djtarx.exe runfile=djtar
+$(BIN)/djtart.exe :
+ifeq ($(DJGPP),)
+	cd $(BIN) ; ln -s djtar djtart
+else
+	$(TOP)/../bin/stubify.exe -g $(BIN)/djtart.exe
+	$(TOP)/../bin/stubedit.exe $(BIN)/djtart.exe runfile=djtar
+endif
 
-$(BIN)/djtart.exe : $(BIN)/stubify.exe
-	stubify -g $(BIN)/djtart.exe
-	stubedit $(BIN)/djtart.exe runfile=djtar
+$(BIN)/djtarx.exe :
+ifeq ($(DJGPP),)
+	cd $(BIN) ; ln -s djtar djtarx
+else
+	$(TOP)/../bin/stubify.exe -g $(BIN)/djtarx.exe
+	$(TOP)/../bin/stubedit.exe $(BIN)/djtarx.exe runfile=djtar
+endif
diff -uwrP orig/src/utils/gxx.c lev3/src/utils/gxx.c
--- orig/src/utils/gxx.c	Fri Apr 26 23:02:50 1996
+++ lev3/src/utils/gxx.c	Thu Jul 10 02:01:20 1997
@@ -1,6 +1,6 @@
 /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
 #include <stdio.h>
-#include <process.h>
+#include <unistd.h>
 #include <stdlib.h>
 
 char lgpp[] = "-lgpp";
@@ -20,5 +20,9 @@
   newargs[i++] = lm;
   newargs[i++] = 0;
 
+#ifdef __DJGPP__
   return execvp("gcc.exe", newargs);
+#else
+  return execvp("gcc", newargs);
+#endif
 }
diff -uwrP orig/src/utils/makefile lev3/src/utils/makefile
--- orig/src/utils/makefile	Wed Jan 24 03:15:58 1996
+++ lev3/src/utils/makefile	Thu Jul 10 02:10:14 1997
@@ -2,32 +2,63 @@
 # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
 TOP=.
 
+# on the build platform, we won't need all of the utilities.
+ifeq ($(PLATFORM),BUILD)
+build: _all_for_build
+endif
+
 LDFLAGS = -s
 
+SRC += update.c
+ifneq ($(PLATFORM),BUILD)
 SRC += bin2h.c
-SRC += dtou.c
-SRC += echo.c
 SRC += gxx.c
+ifneq ($(DJGPP),)
+#these sources won't work anywhere but on DJGPP itself,
+# or don't make much sense for other platforms:
+SRC += echo.c
+SRC += dtou.c
+SRC += utod.c
 SRC += merge.c
 SRC += redir.c
 SRC += split.c
-SRC += update.c
-SRC += utod.c
+endif # DJGPP
+endif # PLATFORM!=BUILD
 
-EXTRA_FILES += $(INFO)/utils.inf
+EXTRA_FILES += $(INFO)/utils.info
+ifneq ($(DJGPP),)
 EXTRA_FILES += $(BIN)/rem.com
-EXTRA_FILES += phony_texi2ps
-EXTRA_FILES += phony_djtar
+endif
+EXTRA_FILES += sub-texi2ps
+
+# 'djtar' only makes sense on DJGPP as a HOST platform
+# (and it won't build on many other platforms either)
+ifneq ($(DJGPP),)
+EXTRA_FILES += sub-djtar
+endif
+
+alle :: maybe_clean_update
 
 include $(TOP)/../makefile.prg
 
 $(BIN)/rem.com : rem.asm
 	djasm $^ $@
 
-.PHONY: phony_texi2ps
-phony_texi2ps:
-	@$(MAKE) --no-print-directory -C texi2ps
-
-.PHONY: phony_djtar
-phony_djtar:
-	@$(MAKE) --no-print-directory -C djtar
+_all_for_build:: maybe_clean_update $(BIN)/update.exe
+
+# If platform is not DJGPP, then update will have to be
+# recompiled from scratch for different PLATFORMs. 
+# Deleting the old one should give us that:
+maybe_clean_update:
+ifeq ($(DJGPP),)
+	rm -f update.o update update.exe
+endif
+
+.PHONY: sub-texi2ps sub-djtar
+sub-texi2ps sub-djtar:
+	@$(MAKE) -C $(patsubst sub-%,%,$@)
+
+clean ::
+	for dir in texi2ps djtar ; do  \
+	  $(MAKE) -C $$dir clean ; \
+	done
Only in orig/src/utils: makefile.oi
diff -uwrP orig/src/utils/texi2ps/makefile lev3/src/utils/texi2ps/makefile
--- orig/src/utils/texi2ps/makefile	Sun Oct  8 19:37:52 1995
+++ lev3/src/utils/texi2ps/makefile	Thu Jul 10 02:13:36 1997
@@ -1,23 +1,27 @@
 # Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details
-CFLAGS = -O2 -Wimplicit
-LDFLAGS = -s
+TOP = ..
 
-OBJS = \
-	fileio.o \
-	ps.o \
-	screenio.o \
-	texi2ps.o \
-	word.o \
-	ifset.o \
+SRC = \
+	fileio.c \
+	ps.c \
+	screenio.c \
+	texi2ps.c \
+	word.c \
+	ifset.c \
 	$E
 
-../../../bin/texi2ps.exe: $(OBJS)
-	gcc $(LDFLAGS) -o $@ $(OBJS)
+include $(TOP)/../makefile.inc
 
-%.o: %.c
-	gcc -MMD -c $(CFLAGS) $<
+CFLAGS += -Wno-error
+ifneq ($(DJGPP),)
+LDFLAGS += -L$(LIB)
+endif
 
-clean:
+all :: $(BIN)/texi2ps.exe
+
+$(BIN)/texi2ps.exe: $(OBJS)
+
+clean ::
 	-rm -f *.o *.exe *.d
 
 DEPS := $(wildcard *.d)
diff -uwrP orig/src/utils/update.c lev3/src/utils/update.c
--- orig/src/utils/update.c	Wed Jul 12 09:27:14 1995
+++ lev3/src/utils/update.c	Tue Jun 24 01:30:02 1997
@@ -1,10 +1,10 @@
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 /* This file is intended to be compiled with Turbo-C */
-
+/* HBB: that's no longer true. I ported it to "ANSI-as-ANSI-can-be"
+ * It may now even be a bit over-paranoid here and there :-)
+ */
 #include <stdio.h>
 #include <fcntl.h>
-#include <unistd.h>
-#include <io.h>
 
 static void
 fatal(const char *s)
@@ -16,10 +16,8 @@
 int
 main(int argc, char **argv)
 {
-  int f1;
-  int f2;
-  char buf1[512];
-  char buf2[512];
+  FILE *f1, *f2;
+  char buf1[512], buf2[512];
   int len1, len2;
   
   if (argc < 3)
@@ -29,44 +27,48 @@
     exit(1);
   }
 
-  f1 = _open(argv[1], O_RDONLY);
-  if (f1 < 0)
+  f1 = fopen(argv[1], "rb");
+  if (!f1)
     fatal("Cannot open src file\n");
 
-  f2 = _open(argv[2], O_RDONLY);
+  f2 = fopen(argv[2], "rb");
 
-  if (f2 >= 0)
+  if (f2)
     while (1)
     {
-      len1 = _read(f1, buf1, 512);
-      len2 = _read(f2, buf2, 512);
+      len1 = fread(buf1, sizeof(char), 512, f1);
+      len2 = fread(buf2, sizeof(char), 512, f2);
       if (len1 != len2)
         break;
-      if (memcmp(buf1, buf2, len1))
+      if (memcmp(buf1, buf2, len1*sizeof(char)))
         break;
-      if (len1)
+      if (len1>0)
         continue;
       exit(0);
     }
 
-  if (f2 >= 0)
+  if (len1<0)
+    fatal("Failed to read from src file\n");
+
+  if (f2)
   {
     printf("File `%s' updated\n", argv[2]);
-    _close(f2);
+    fclose(f2);
   }
   else
     printf("File `%s' created\n", argv[2]);
 
-  lseek(f1, 0L, 0);
-  f2 = _creat(argv[2], 0);
+  fseek(f1, 0L, SEEK_SET);
+
+  f2 = fopen(argv[2], "wb");
   while (1)
   {
-    len1 = _read(f1, buf1, 512);
+    len1 = fread(buf1, 1, 512, f1);
     if (len1 == 0)
       break;
-    len2 = _write(f2, buf1, len1);
+    len2 = fwrite(buf1, 1, len1, f2);
   }
-  _close(f1);
-  _close(f2);
+  fclose(f1);
+  fclose(f2);
   exit(0);
 }

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019