diff -u -r grx246.orig/configure grx246/configure
--- grx246.orig/configure	Wed Oct 16 22:39:58 2002
+++ grx246/configure	Mon Apr 26 04:02:04 2004
@@ -6,9 +6,10 @@
 #       to do with it, just ignore it and follow the normal install
 #       instructions.
 #
-# Copyright (C) 2001-2002 Frank Heckenbach <frank@pascal.gnu.de>
+# Copyright (C) 2001-2002,2004 Frank Heckenbach <frank@pascal.gnu.de>
+#                              Peter Gerwinski <peter@gerwinski.de>
 #
-# Parts copied from GCC's configure script,
+# Parts copied from some version of GCC's configure script,
 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
@@ -48,6 +49,7 @@
 HAVE_LIBPNG=n
 NEED_ZLIB=n
 HAVE_LIBTIFF=n
+HAVE_UNIX_TOOLS=n
 INCLUDE_BMP_CODE=y
 INCLUDE_PRINTING_CODE=y
 INCLUDE_GPC_SUPPORT=n
@@ -146,7 +148,8 @@
   --silent                  silent operation
   --prefix=PREFIX           install files in PREFIX [$default_prefix]
   --target=TARGET           configure for TARGET [$default_target]
-                            possible values: DJGPP, X11, svgalib
+                            possible values: DJGPP, X11, svgalib, w32
+                            or GCC-style ("i386-mingw32") for cross-compiling
   --enable-jpeg             include JPEG support [no]
   --enable-png              include PNG support [no]
   --enable-z or             use zlib [no]
@@ -192,12 +195,23 @@
 done
 
 case "`echo "$target" | tr A-Z a-z`" in
-  djgpp)   cfgsection=GRXVDJ2; target_makefile=makefile.dj2;;
-  x | x11) cfgsection=GRXVX11; target_makefile=makefile.x11;;
-  svgalib) cfgsection=GRXVLNX; target_makefile=makefile.lnx;;
-  *)       echo "$0: invalid target" >&2; exit 1;;
+  *djgpp*)        cfgsection=GRXVDJ2; target_makefile=makefile.dj2;;
+  x | x11)        cfgsection=GRXVX11; target_makefile=makefile.x11;;
+  svgalib)        cfgsection=GRXVLNX; target_makefile=makefile.lnx;;
+  *w32 | *mingw*) cfgsection=GRXVW32; target_makefile=makefile.w32;;
+  *)              echo "$0: invalid target" >&2; exit 1;;
 esac
 
+if echo "$target" | tr A-Z a-z | grep "[a-z0-9]-[a-z0-9]" > /dev/null; then
+  CROSS_PLATFORM="`echo "$target" | tr A-Z a-z`-"
+  installdir="$prefix/$target"
+  # Cross-compiling is usually done from a Unix-like platform.
+  HAVE_UNIX_TOOLS=y
+else
+  CROSS_PLATFORM=""
+  installdir="$prefix"
+fi
+
 if [ $USE_SVGALIB_DRIVER != y ] && [ $USE_FRAMEBUFFER_DRIVER != y ]; then
   echo "$0: either \`--enable-svgalib' or \`--enable-framebuffer' must be set" >&2
   exit 1
@@ -245,19 +259,21 @@
 if sed -e "/^HAVE_LIBTIFF=/s/=.*/=$HAVE_LIBTIFF/;
            /^HAVE_LIBJPEG=/s/=.*/=$HAVE_LIBJPEG/;
            /^HAVE_LIBPNG=/s/=.*/=$HAVE_LIBPNG/;
+           /^HAVE_UNIX_TOOLS=/s/=.*/=$HAVE_UNIX_TOOLS/;
            /^NEED_ZLIB=/s/=.*/=$NEED_ZLIB/;
            /^INCLUDE_PRINTING_CODE=/s/=.*/=$INCLUDE_PRINTING_CODE/;
            /^INCLUDE_BMP_CODE=/s/=.*/=$INCLUDE_BMP_CODE/;
            /^INCLUDE_GPC_SUPPORT=/s/=.*/=$INCLUDE_GPC_SUPPORT/;
            /^INCLUDE_SHARED_SUPPORT=/s/=.*/=$INCLUDE_SHARED_SUPPORT/;
            /^INCLUDE_BGI_SUPPORT=/s/=.*/=$INCLUDE_BGI_SUPPORT/;
+           /^CROSS_PLATFORM=/s/=.*/=$CROSS_PLATFORM/;
            /^USE_DIRECT_MOUSE_DRIVER=/s/=.*/=$USE_DIRECT_MOUSE_DRIVER/;
            /^USE_SVGALIB_DRIVER=/s/=.*/=$USE_SVGALIB_DRIVER/;
            /^USE_FRAMEBUFFER_DRIVER=/s/=.*/=$USE_FRAMEBUFFER_DRIVER/;
            /^SET_SUIDROOT=/s/=.*/=$SET_SUIDROOT/;
            /^USE_INOUTP_FRAMEDRIVERS=/s/=.*/=$USE_INOUTP_FRAMEDRIVERS/;
            /^ifdef $cfgsection\$/,/^endif\$/{
-             /^INSTALLDIR=/s|=.*|=$prefix|;
+             /^INSTALLDIR=/s|=.*|=$installdir|;
              /^X11BASE=/s|=.*|=$x11base|;
              $subst_fontpath;
              /^X11LIBS=/s/\$/$lsocket/;
diff -u -r grx246.orig/makedefs.grx grx246/makedefs.grx
--- grx246.orig/makedefs.grx	Wed Jul 16 04:09:42 2003
+++ grx246/makedefs.grx	Mon Apr 26 03:58:39 2004
@@ -36,12 +36,19 @@
 # Specify if you want to include BGI support
 INCLUDE_BGI_SUPPORT=y
 
+# For cross-compiling, specify prefix for tools including the trailing dash
+# (e.g. "i386-mingw32-" for using i386-mingw32-gcc instead of just gcc)
+CROSS_PLATFORM=""
+
+# Specify if you want to use Unix tools on DOS-like platforms
+HAVE_UNIX_TOOLS=n
+
 ### SYSTEM SETTINGS ##################################################
 
-CC     = gcc
-AR     = ar
-RANLIB = ranlib
-STRIP  = strip
+CC     = $(CROSS_PLATFORM)gcc
+AR     = $(CROSS_PLATFORM)ar
+RANLIB = $(CROSS_PLATFORM)ranlib
+STRIP  = $(CROSS_PLATFORM)strip
 
 # Different systems / setups may generate .o files
 # this tag files will show what version is present
@@ -85,7 +92,7 @@
 # place libgrx20.a and libgrx20.so in lib/unix
 GRX_LIB_SUBDIR=unix
 
-# Set here the default destination dir for install and uninstall targets
+# Set here the destination dir for install and uninstall targets
 INSTALLDIR=/usr/local
 
 # Set the default GRX font path
@@ -154,6 +161,9 @@
 # Put libgrx20.a to lib/dj2
 GRX_LIB_SUBDIR=dj2
 
+# Set here the destination dir for install and uninstall targets
+INSTALLDIR=$(DJDIR)
+
 # If you want to use 'upx.exe' compressor
 # disable the echo line and enable upx line.
 EXE_COMPRESS = -echo
@@ -184,8 +194,8 @@
 # Put libgrx20.a to lib/win32
 GRX_LIB_SUBDIR=win32
 
-# Set here your MINGW dir for install and uninstall targets
-MINGWDIR=C:\MINGW
+# Set here the destination dir for install and uninstall targets
+INSTALLDIR=C:\MINGW
 
 # Set the default GRX font path
 #GRX_DEFAULT_FONT_PATH=c:/grxfonts
diff -u -r grx246.orig/pascal/bgi/makefile.dj2 grx246/pascal/bgi/makefile.dj2
--- grx246.orig/pascal/bgi/makefile.dj2	Sun Dec 23 02:29:08 2001
+++ grx246/pascal/bgi/makefile.dj2	Mon Apr 26 03:58:47 2004
@@ -32,9 +32,11 @@
 	$(COMPILER) $(CCOPT) -o $*.exe $*.pas $(UNITPATH) $(LIBS)
 
 clean:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f *.o *.exe *.gpi *.gpm
+else
 	if exist *.o del *.o
 	if exist *.exe del *.exe
 	if exist *.gpi del *.gpi
 	if exist *.gpm del *.gpm
-
-
+endif
diff -u -r grx246.orig/pascal/bgi/makefile.w32 grx246/pascal/bgi/makefile.w32
--- grx246.orig/pascal/bgi/makefile.w32	Sun Dec 23 02:30:18 2001
+++ grx246/pascal/bgi/makefile.w32	Mon Apr 26 03:58:47 2004
@@ -33,9 +33,11 @@
 	$(COMPILER) $(CCOPT) -o $*.exe $*.pas $(UNITPATH) $(LIBS)
 
 clean:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f *.o *.exe *.gpi *.gpm
+else
 	if exist *.o del *.o
 	if exist *.exe del *.exe
 	if exist *.gpi del *.gpi
 	if exist *.gpm del *.gpm
-
-
+endif
diff -u -r grx246.orig/pascal/makefile.dj2 grx246/pascal/makefile.dj2
--- grx246.orig/pascal/makefile.dj2	Wed Jun 11 00:21:24 2003
+++ grx246/pascal/makefile.dj2	Mon Apr 26 03:58:47 2004
@@ -35,9 +35,11 @@
 	$(COMPILER) $(CCOPT) -o $*.exe $*.pas $(LIBS)
 
 clean:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f *.o *.exe *.gpi *.gpm
+else
 	if exist *.o del *.o
 	if exist *.exe del *.exe
 	if exist *.gpi del *.gpi
 	if exist *.gpm del *.gpm
-
-
+endif
diff -u -r grx246.orig/pascal/makefile.w32 grx246/pascal/makefile.w32
--- grx246.orig/pascal/makefile.w32	Wed Jun 11 00:21:24 2003
+++ grx246/pascal/makefile.w32	Mon Apr 26 03:58:47 2004
@@ -35,9 +35,11 @@
 	$(COMPILER) $(CCOPT) -o $*.exe $*.pas $(LIBS)
 
 clean:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f *.o *.exe *.gpi *.gpm
+else
 	if exist *.o del *.o
 	if exist *.exe del *.exe
 	if exist *.gpi del *.gpi
 	if exist *.gpm del *.gpm
-
-
+endif
diff -u -r grx246.orig/src/makefile.dj2 grx246/src/makefile.dj2
--- grx246.orig/src/makefile.dj2	Wed Jul 31 22:34:34 2002
+++ grx246/src/makefile.dj2	Mon Apr 26 04:11:02 2004
@@ -20,8 +20,13 @@
 
 GRX20ln    = libgrx20.a
 GRX20ST    = ../lib/$(GRX_LIB_SUBDIR)/$(GRX20ln)
+ifeq ($(HAVE_UNIX_TOOLS),y)
+GRX20STdos = $(GRX20ST)
+INSTALLDIRdos   = $(INSTALLDIR)
+else
 GRX20STdos = $(subst /,\,$(GRX20ST))
-DJDIRdos   = $(subst /,\,$(DJDIR))
+INSTALLDIRdos   = $(subst /,\,$(INSTALLDIR))
+endif
 
 OX=.o
 OP=
@@ -120,6 +125,9 @@
 all:    $(GRX20ST) $(UTILP)
 
 clean:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f */*.o ../addons/*.o ../addons/*/*.o $(TAG)
+else
 	if exist bgi\*.o      del bgi\*.o
 	if exist draw\*.o     del draw\*.o
 	if exist fdrivers\*.o del fdrivers\*.o
@@ -141,79 +149,153 @@
 	if exist ..\addons\print\*.o del ..\addons\print\*.o
 	if exist ..\addons\bmp\*.o   del ..\addons\bmp\*.o
 	if exist $(TAG)       del $(TAG)
+endif
 
 cleanall: clean
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f $(GRX20STdos) ../bin/*.exe
+else
 	if exist $(GRX20STdos) del $(GRX20STdos)
 	if exist ..\bin\*.exe del ..\bin\*.exe
+endif
 
 install: $(GRX20ST)
-	copy $(GRX20STdos) $(DJDIRdos)\lib
-	copy ..\include\grx20.h $(DJDIRdos)\include
-	copy ..\include\grxkeys.h $(DJDIRdos)\include
-	copy ..\include\libbcc.h $(DJDIRdos)\include
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	cp $(GRX20STdos) $(INSTALLDIRdos)/lib
+	cp ../include/grx20.h ../include/grxkeys.h \
+	   ../include/libbcc.h $(INSTALLDIRdos)/include
+ifeq ($(INCLUDE_PRINTING_CODE),y)
+	cp ../addons/print/grxprint.h $(INSTALLDIRdos)/include
+endif
+ifeq ($(INCLUDE_GPC_SUPPORT),y)
+	mkdir -p $(INSTALLDIRdos)/units
+	cp ../pascal/grx.pas ../pascal/bgi/graph.pas $(INSTALLDIRdos/units
+endif
+else
+	copy $(GRX20STdos) $(INSTALLDIRdos)\lib
+	copy ..\include\grx20.h $(INSTALLDIRdos)\include
+	copy ..\include\grxkeys.h $(INSTALLDIRdos)\include
+	copy ..\include\libbcc.h $(INSTALLDIRdos)\include
 ifeq ($(INCLUDE_PRINTING_CODE),y)
-	copy ..\addons\print\grxprint.h $(DJDIRdos)\include
+	copy ..\addons\print\grxprint.h $(INSTALLDIRdos)\include
 endif
 ifeq ($(INCLUDE_GPC_SUPPORT),y)
-	if not exist $(DJDIRdos)\units\nul mkdir $(DJDIRdos)\units
-	copy ..\pascal\grx.pas $(DJDIRdos)\units
-	copy ..\pascal\bgi\graph.pas $(DJDIRdos)\units
+	if not exist $(INSTALLDIRdos)\units\nul mkdir $(INSTALLDIRdos)\units
+	copy ..\pascal\grx.pas $(INSTALLDIRdos)\units
+	copy ..\pascal\bgi\graph.pas $(INSTALLDIRdos)\units
+endif
 endif
 
 uninstall:
-	if exist $(DJDIRdos)\lib\$(GRX20ln)    del $(DJDIRdos)\lib\$(GRX20ln)
-	if exist $(DJDIRdos)\include\grx20.h   del $(DJDIRdos)\include\grx20.h
-	if exist $(DJDIRdos)\include\grxkeys.h del $(DJDIRdos)\include\grxkeys.h
-	if exist $(DJDIRdos)\include\libbcc.h del $(DJDIRdos)\include\libbcc.h
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f $(INSTALLDIRdos)/lib/$(GRX20ln) $(INSTALLDIRdos)/include/grx20.h \
+	      $(INSTALLDIRdos)/include/grxkeys.h $(INSTALLDIRdos)/include/libbcc.h
+ifeq ($(INCLUDE_PRINTING_CODE),y)
+	rm -f $(INSTALLDIRdos)/include/grxprint.h
+endif
+ifeq ($(INCLUDE_GPC_SUPPORT),y)
+	rm -f $(INSTALLDIRdos)/units/grx.pas $(INSTALLDIRdos)/units/graph.pas
+endif
+else
+	if exist $(INSTALLDIRdos)\lib\$(GRX20ln)    del $(INSTALLDIRdos)\lib\$(GRX20ln)
+	if exist $(INSTALLDIRdos)\include\grx20.h   del $(INSTALLDIRdos)\include\grx20.h
+	if exist $(INSTALLDIRdos)\include\grxkeys.h del $(INSTALLDIRdos)\include\grxkeys.h
+	if exist $(INSTALLDIRdos)\include\libbcc.h del $(INSTALLDIRdos)\include\libbcc.h
 ifeq ($(INCLUDE_PRINTING_CODE),y)
-	if exist $(DJDIRdos)\include\grxprint.h del $(DJDIRdos)\include\grxprint.h
+	if exist $(INSTALLDIRdos)\include\grxprint.h del $(INSTALLDIRdos)\include\grxprint.h
 endif
 ifeq ($(INCLUDE_GPC_SUPPORT),y)
-	if exist $(DJDIRdos)\units\grx.pas del $(DJDIRdos)\units\grx.pas
-	if exist $(DJDIRdos)\units\graph.pas del $(DJDIRdos)\units\graph.pas
+	if exist $(INSTALLDIRdos)\units\grx.pas del $(INSTALLDIRdos)\units\grx.pas
+	if exist $(INSTALLDIRdos)\units\graph.pas del $(INSTALLDIRdos)\units\graph.pas
+endif
 endif
 
 install-info:
-	copy ..\doc\grx*um.inf $(DJDIRdos)\info\grx.inf
-	install-info $(DJDIRdos)\info\grx.inf $(DJDIRdos)\info\dir
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	cp ../doc/grx*um.inf $(INSTALLDIRdos)/info/grx.inf
+	install-info $(INSTALLDIRdos)/info/grx.inf $(INSTALLDIRdos)/info/dir
+else
+	copy ..\doc\grx*um.inf $(INSTALLDIRdos)\info\grx.inf
+	install-info $(INSTALLDIRdos)\info\grx.inf $(INSTALLDIRdos)\info\dir
+endif
 
 uninstall-info:
-	if exist $(DJDIRdos)\info\grx.inf del $(DJDIRdos)\info\grx.inf
-	install-info -r $(DJDIRdos)\info\grx.inf $(DJDIRdos)\info\dir
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f $(INSTALLDIRdos)/info/grx.inf
+	install-info -r $(INSTALLDIRdos)/info/grx.inf $(INSTALLDIRdos)/info/dir
+else
+	if exist $(INSTALLDIRdos)\info\grx.inf del $(INSTALLDIRdos)\info\grx.inf
+	install-info -r $(INSTALLDIRdos)\info\grx.inf $(INSTALLDIRdos)\info\dir
+endif
 
 install-bin: $(UTILP)
-	copy ..\bin\bin2c.exe $(DJDIRdos)\bin
-	copy ..\bin\fnt2c.exe $(DJDIRdos)\bin
-	copy ..\bin\vesainfo.exe $(DJDIRdos)\bin
-	copy ..\bin\modetest.exe $(DJDIRdos)\bin
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	cp ../bin/bin2c.exe ../bin/fnt2c.exe ../bin/vesainfo.exe \
+	   ../bin/modetest.exe $(INSTALLDIRdos)/bin
+else
+	copy ..\bin\bin2c.exe $(INSTALLDIRdos)\bin
+	copy ..\bin\fnt2c.exe $(INSTALLDIRdos)\bin
+	copy ..\bin\vesainfo.exe $(INSTALLDIRdos)\bin
+	copy ..\bin\modetest.exe $(INSTALLDIRdos)\bin
+endif
 
 uninstall-bin:
-	if exist $(DJDIRdos)\bin\bin2c.exe del $(DJDIRdos)\bin\bin2c.exe
-	if exist $(DJDIRdos)\bin\fnt2c.exe del $(DJDIRdos)\bin\fnt2c.exe
-	if exist $(DJDIRdos)\bin\vesainfo.exe del $(DJDIRdos)\bin\vesainfo.exe
-	if exist $(DJDIRdos)\bin\modetest.exe del $(DJDIRdos)\bin\modetest.exe
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f $(INSTALLDIRdos)/bin/bin2c.exe $(INSTALLDIRdos)/bin/fnt2c.exe \
+	      $(INSTALLDIRdos)/bin/vesainfo.exe $(INSTALLDIRdos)/bin/modetest.exe
+else
+	if exist $(INSTALLDIRdos)\bin\bin2c.exe del $(INSTALLDIRdos)\bin\bin2c.exe
+	if exist $(INSTALLDIRdos)\bin\fnt2c.exe del $(INSTALLDIRdos)\bin\fnt2c.exe
+	if exist $(INSTALLDIRdos)\bin\vesainfo.exe del $(INSTALLDIRdos)\bin\vesainfo.exe
+	if exist $(INSTALLDIRdos)\bin\modetest.exe del $(INSTALLDIRdos)\bin\modetest.exe
+endif
 
 ifdef GRX_DEFAULT_FONT_PATH
+ifeq ($(HAVE_UNIX_TOOLS),y)
+FONTPATHdos = $(GRX_DEFAULT_FONT_PATH)
+else
 FONTPATHdos = $(subst /,\,$(GRX_DEFAULT_FONT_PATH))
+endif
 install-fonts:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	mkdir -p $(FONTPATHdos)
+	cp ../fonts/* $(FONTPATHdos)
+else
 	if not exist $(FONTPATHdos)\nul mkdir $(FONTPATHdos)
 	copy ..\fonts\*.* $(FONTPATHdos)
+endif
 uninstall-fonts:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f $(FONTPATHdos)/*
+else
 	del $(FONTPATHdos)\*.*
 endif
+endif
                         
 dep:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f depend.tmp
+else
 	if exist depend.tmp del depend.tmp
+endif
 	gcc -MM $(CCOPT) $(INCDIR) $(ALL_O:.o=.c) >depend.tmp
 	sed 's#^.*: \(.*\)\.c#\1.o: \1.c#g'   <depend.tmp >depend.dj2
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f depend.tmp
+else
 	if exist depend.tmp del depend.tmp
+endif
 
 depend.b: depend.new
 	sed "s#\.o:#.obj:#g" <depend.new >depend.b
 	sed "s#\.o:#.asm:#g" <depend.new >>depend.b
 
 $(GRX20ST): $(TAG) $(ALL_O)
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f $(GRX20STdos)
+else
 	if exist $(GRX20STdos) del $(GRX20STdos)
+endif
 	$(AR) -r $(GRX20ST) $(STD_Oa)
 	$(AR) -r $(GRX20ST) $(STD_Ob)
 ifeq ($(INCLUDE_BGI_SUPPORT),y)
@@ -229,7 +311,11 @@
 
 $(DOS_DJGPP_V2):
 	$(MAKE) -f makefile.dj2 clean
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	if [ ! -r $(DOS-DJGPP_V2) ]; then rm -f $(SYSTEM_TAG_PREFIX).*; fi
+else
 	if not exist $(DOS_DJGPP_V2) del $(SYSTEM_TAG_PREFIX).*
+endif
 	echo DOS_DJGPP_V2_TARGET > $(DOS_DJGPP_V2)
 
 $(ALL_O): $(TAG)
diff -u -r grx246.orig/src/makefile.w32 grx246/src/makefile.w32
--- grx246.orig/src/makefile.w32	Sat Mar 22 00:14:14 2003
+++ grx246/src/makefile.w32	Mon Apr 26 04:10:58 2004
@@ -19,7 +19,11 @@
 
 GRX20ln    = libgrx20.a
 GRX20ST    = ../lib/$(GRX_LIB_SUBDIR)/$(GRX20ln)
+ifeq ($(HAVE_UNIX_TOOLS), y)
+GRX20STdos = $(GRX20ST)
+else
 GRX20STdos = $(subst /,\,$(GRX20ST))
+endif
 
 OX=.o
 OP=
@@ -96,6 +100,9 @@
 all:    $(GRX20ST) $(UTILPC) $(UTILPW)
 
 clean:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f */*.o ../addons/*.o ../addons/*/*.o $(TAG)
+else
 	if exist bgi\*.o      del bgi\*.o
 	if exist draw\*.o     del draw\*.o
 	if exist fdrivers\*.o del fdrivers\*.o
@@ -117,69 +124,133 @@
 	if exist ..\addons\print\*.o del ..\addons\print\*.o
 	if exist ..\addons\bmp\*.o   del ..\addons\bmp\*.o
 	if exist $(TAG)       del $(TAG)
+endif
 
 cleanall: clean
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f $(GRX20STdos) ../bin/*.exe
+else
 	if exist $(GRX20STdos) del $(GRX20STdos)
 	if exist ..\bin\*.exe del ..\bin\*.exe
+endif
 
 install: $(GRX20ST)
-	copy $(GRX20STdos) $(MINGWDIR)\lib
-	copy ..\include\grx20.h $(MINGWDIR)\include
-	copy ..\include\grxkeys.h $(MINGWDIR)\include
-	copy ..\include\libbcc.h $(MINGWDIR)\include
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	cp $(GRX20STdos) $(INSTALLDIR)/lib
+	cp ../include/grx20.h ../include/grxkeys.h \
+	   ../include/libbcc.h $(INSTALLDIR)/include
+ifeq ($(INCLUDE_PRINTING_CODE),y)
+	cp ../addons/print/grxprint.h $(INSTALLDIR)/include
+endif
+ifeq ($(INCLUDE_GPC_SUPPORT),y)
+	mkdir -p $(INSTALLDIR)/units
+	cp ../pascal/grx.pas ../pascal/bgi/graph.pas $(INSTALLDIR)/units
+endif
+else
+	copy $(GRX20STdos) $(INSTALLDIR)\lib
+	copy ..\include\grx20.h $(INSTALLDIR)\include
+	copy ..\include\grxkeys.h $(INSTALLDIR)\include
+	copy ..\include\libbcc.h $(INSTALLDIR)\include
 ifeq ($(INCLUDE_PRINTING_CODE),y)
-	copy ..\addons\print\grxprint.h $(MINGWDIR)\include
+	copy ..\addons\print\grxprint.h $(INSTALLDIR)\include
 endif
 ifeq ($(INCLUDE_GPC_SUPPORT),y)
-	if not exist $(MINGWDIR)\units\nul mkdir $(MINGWDIR)\units
-	copy ..\pascal\grx.pas $(MINGWDIR)\units
-	copy ..\pascal\bgi\graph.pas $(MINGWDIR)\units
+	if not exist $(INSTALLDIR)\units\nul mkdir $(INSTALLDIR)\units
+	copy ..\pascal\grx.pas $(INSTALLDIR)\units
+	copy ..\pascal\bgi\graph.pas $(INSTALLDIR)\units
+endif
 endif
 
 uninstall:
-	if exist $(MINGWDIR)\lib\$(GRX20ln)    del $(MINGWDIR)\lib\$(GRX20ln)
-	if exist $(MINGWDIR)\include\grx20.h   del $(MINGWDIR)\include\grx20.h
-	if exist $(MINGWDIR)\include\grxkeys.h del $(MINGWDIR)\include\grxkeys.h
-	if exist $(MINGWDIR)\include\libbcc.h del $(MINGWDIR)\include\libbcc.h
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f $(INSTALLDIR)/lib/$(GRX20ln) $(INSTALLDIR)/include/grx20.h \
+	      $(INSTALLDIR)/include/grxkeys.h $(INSTALLDIR)/include/libbcc.h
 ifeq ($(INCLUDE_PRINTING_CODE),y)
-	if exist $(MINGWDIR)\include\grxprint.h del $(MINGWDIR)\include\grxprint.h
+	rm -f $(INSTALLDIR)/include/grxprint.h
 endif
 ifeq ($(INCLUDE_GPC_SUPPORT),y)
-	if exist $(MINGWDIR)\units\grx.pas del $(MINGWDIR)\units\grx.pas
-	if exist $(MINGWDIR)\units\graph.pas del $(MINGWDIR)\units\graph.pas
+	rm -f $(INSTALLDIR)/units/grx.pas $(INSTALLDIR)/units/graph.pas
+endif
+else
+	if exist $(INSTALLDIR)\lib\$(GRX20ln)    del $(INSTALLDIR)\lib\$(GRX20ln)
+	if exist $(INSTALLDIR)\include\grx20.h   del $(INSTALLDIR)\include\grx20.h
+	if exist $(INSTALLDIR)\include\grxkeys.h del $(INSTALLDIR)\include\grxkeys.h
+	if exist $(INSTALLDIR)\include\libbcc.h del $(INSTALLDIR)\include\libbcc.h
+ifeq ($(INCLUDE_PRINTING_CODE),y)
+	if exist $(INSTALLDIR)\include\grxprint.h del $(INSTALLDIR)\include\grxprint.h
+endif
+ifeq ($(INCLUDE_GPC_SUPPORT),y)
+	if exist $(INSTALLDIR)\units\grx.pas del $(INSTALLDIR)\units\grx.pas
+	if exist $(INSTALLDIR)\units\graph.pas del $(INSTALLDIR)\units\graph.pas
+endif
 endif
 
 install-bin: $(UTILPC) $(UTILPW)
-	copy ..\bin\bin2c.exe $(MINGWDIR)\bin
-	copy ..\bin\fnt2c.exe $(MINGWDIR)\bin
-	copy ..\bin\modetest.exe $(MINGWDIR)\bin
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	cp ../bin/bin2c.exe ../bin/fnt2c.exe \
+	   ../bin/modetest.exe $(INSTALLDIR)/bin
+else
+	copy ..\bin\bin2c.exe $(INSTALLDIR)\bin
+	copy ..\bin\fnt2c.exe $(INSTALLDIR)\bin
+	copy ..\bin\modetest.exe $(INSTALLDIR)\bin
+endif
 
 uninstall-bin:
-	if exist $(MINGWDIR)\bin\bin2c.exe del $(MINGWDIR)\bin\bin2c.exe
-	if exist $(MINGWDIR)\bin\fnt2c.exe del $(MINGWDIR)\bin\fnt2c.exe
-	if exist $(MINGWDIR)\bin\modetest.exe del $(MINGWDIR)\bin\modetest.exe
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f $(INSTALLDIR)/bin/bin2c.exe $(INSTALLDIR)/bin/fnt2c.exe \
+	      $(INSTALLDIR)/bin/modetest.exe
+else
+	if exist $(INSTALLDIR)\bin\bin2c.exe del $(INSTALLDIR)\bin\bin2c.exe
+	if exist $(INSTALLDIR)\bin\fnt2c.exe del $(INSTALLDIR)\bin\fnt2c.exe
+	if exist $(INSTALLDIR)\bin\modetest.exe del $(INSTALLDIR)\bin\modetest.exe
+endif
 
 ifdef GRX_DEFAULT_FONT_PATH
+ifeq ($(HAVE_UNIX_TOOLS),y)
+FONTPATHdos = $(GRX_DEFAULT_FONT_PATH)
+else
 FONTPATHdos = $(subst /,\,$(GRX_DEFAULT_FONT_PATH))
+endif
 install-fonts:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	mkdir -p $(FONTPATHdos)
+	cp ../fonts/* $(FONTPATHdos)
+else
 	if not exist $(FONTPATHdos)\nul mkdir $(FONTPATHdos)
 	copy ..\fonts\*.* $(FONTPATHdos)
+endif
 uninstall-fonts:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f $(FONTPATHdos)/*
+else
 	del $(FONTPATHdos)\*.*
 endif
+endif
                         
 dep:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f depend.tmp
+else
 	if exist depend.tmp del depend.tmp
+endif
 	gcc -MM $(CCOPT) $(INCDIR) $(ALL_O:.o=.c) >depend.tmp
 	sed 's#^.*: \(.*\)\.c#\1.o: \1.c#g'   <depend.tmp >depend.w32
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f depend.tmp
+else
 	if exist depend.tmp del depend.tmp
+endif
 
 depend.b: depend.new
 	sed "s#\.o:#.obj:#g" <depend.new >depend.b
 	sed "s#\.o:#.asm:#g" <depend.new >>depend.b
 
 $(GRX20ST): $(TAG) $(ALL_O)
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f $(GRX20STdos)
+else
 	if exist $(GRX20STdos) del $(GRX20STdos)
+endif
 	$(AR) -r $(GRX20ST) $(STD_Oa)
 	$(AR) -r $(GRX20ST) $(STD_Ob)
 	$(AR) -r $(GRX20ST) $(STD_Oc)
@@ -199,7 +270,12 @@
 
 $(WIN32_GCC_i386_STATIC):
 	$(MAKE) -f makefile.w32 clean
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	if [ ! -r $(WIN32_GCC_i386_STATIC) ]; then \
+	  rm -f $(SYSTEM_TAG_PREFIX).*; fi
+else
 	if not exist $(WIN32_GCC_i386_STATIC) del $(SYSTEM_TAG_PREFIX).*
+endif
 	echo WIN32_GCC_i386_STATIC_TARGET > $(WIN32_GCC_i386_STATIC)
 
 $(ALL_O): $(TAG)
diff -u -r grx246.orig/test/bgi/makefile.dj2 grx246/test/bgi/makefile.dj2
--- grx246.orig/test/bgi/makefile.dj2	Thu Jun  7 21:08:40 2001
+++ grx246/test/bgi/makefile.dj2	Mon Apr 26 03:58:47 2004
@@ -51,8 +51,12 @@
 	$(CC) -S $(CCOPT) $(INCDIR) $*.c
 
 clean:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f *.o *.exe
+else
 	if exist *.o del *.o
 	if exist *.exe del *.exe
+endif
 
 depend.new:
 	$(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:.exe=.c) >depend.new
diff -u -r grx246.orig/test/bgi/makefile.w32 grx246/test/bgi/makefile.w32
--- grx246.orig/test/bgi/makefile.w32	Sat Aug 10 00:04:46 2002
+++ grx246/test/bgi/makefile.w32	Mon Apr 26 03:58:47 2004
@@ -49,8 +49,12 @@
 	$(CC) -S $(CCOPT) $(INCDIR) $*.c
 
 clean:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f *.o *.exe
+else
 	if exist *.o del *.o
 	if exist *.exe del *.exe
+endif
 
 #depend.new:
 #	$(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:.exe=.c) >depend.new
diff -u -r grx246.orig/test/makefile.dj2 grx246/test/makefile.dj2
--- grx246.orig/test/makefile.dj2	Mon Jun 17 22:09:10 2002
+++ grx246/test/makefile.dj2	Mon Apr 26 03:58:47 2004
@@ -74,8 +74,12 @@
 	$(CC) -S $(CCOPT) $(INCDIR) $*.c
 
 clean:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f *.o *.exe
+else
 	if exist *.o del *.o
 	if exist *.exe del *.exe
+endif
 
 depend.new:
 	$(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:.exe=.c) >depend.new
diff -u -r grx246.orig/test/makefile.w32 grx246/test/makefile.w32
--- grx246.orig/test/makefile.w32	Mon Jun 17 22:08:38 2002
+++ grx246/test/makefile.w32	Mon Apr 26 03:58:47 2004
@@ -84,8 +84,12 @@
 	$(CC) -S $(CCOPT) $(INCDIR) $*.c
 
 clean:
+ifeq ($(HAVE_UNIX_TOOLS),y)
+	rm -f *.o *.exe
+else
 	if exist *.o del *.o
 	if exist *.exe del *.exe
+endif
 
 depend.new:
 	$(CC) -MM $(CCOPT) $(INCDIR) $(PROGS:.exe=.c) >depend.new
