I have tried to build Make for DJGPP/MSDOS/FreeDOS and I had to fix a couple
of minor issues.  Please inspect the patch provided as suggestion.
1: src/load.c has to be added to the list of files to be compiled in builddos.bat
2: DJGPP does not provide guile support thus the call to guile_gmake_setup in
   main.c must be guarded by checking if HAVE_GUILE is defined.
3: "get_bad_stdin" exists two times.  One time as function defined in posixos.c.
   Another time as macro defined in os.h in the case that one of the macros
   VMS, WINDOWS32, _AMIGA, __MSDOS__ is defined.  Thus the compiling of that
   function should depend on that those macros have not been defined.
4: use environment variables instead of hard coded paths in builddos.bat
   and msdosdjgpp.mk so those files are usefull for all installations and
   not only for the one where they match.

After having fixed those issues as shown in the patch I was able to compile
Make on MS-DOS using latest DJGPP tools.  The DOS port of Make seems to
continue working flawlessly on DOS as far as I can say.  I have also checked
the changes on my linux box and I have experienced no issues due to the
propossed changes.


Kind regards,
Juan M. Guerrero



2016-06-12 Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* builddos.bat:  Use environment variable /dev/env/DJDIR instead
	of hard coded path c:/djgpp.
	Provide definition for LOCALEDIR.
	Typo. eyxpand replaced by expand.
	File "load.c" added to the list of files to be compiled.

	* src/main.c (main):  Call guile_gmake_setup only if HAVE_GUILE
	is defined.
 
	* posixos.c (get_bad_stdin) [VMS, WINDOWS32, _AMIGA, __MSDOS__]:  Compile
	only if not replaced by macro defined in os.h.

	* mk/msdosdjgpp.mk:  Use environment variable /dev/env/DJDIR instead
	of hard coded path c:/djgpp.





diff -aprNU3 make-4.3.orig/builddos.bat make-4.3/builddos.bat
--- make-4.3.orig/builddos.bat	2019-12-21 21:04:06 +0000
+++ make-4.3/builddos.bat	2020-01-29 22:23:44 +0000
@@ -49,14 +49,14 @@ gcc -c -I./src -I%XSRC%/src -I./lib -I%X
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/dir.c -o dir.o
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/file.c -o file.o
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/misc.c -o misc.o
-gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/main.c -o main.o
-gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -DINCLUDEDIR=\"c:/djgpp/include\" -O2 -g %XSRC%/src/read.c -o read.o
-gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -DLIBDIR=\"c:/djgpp/lib\" -O2 -g %XSRC%/src/remake.c -o remake.o
+gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -DLOCALEDIR=\"/dev/env/DJDIR/share/locale\" -O2 -g %XSRC%/src/main.c -o main.o
+gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -DINCLUDEDIR=\"/dev/env/DJDIR/include\" -O2 -g %XSRC%/src/read.c -o read.o
+gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -DLIBDIR=\"/dev/env/DJDIR/lib\" -O2 -g %XSRC%/src/remake.c -o remake.o
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/rule.c -o rule.o
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/implicit.c -o implicit.o
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/default.c -o default.o
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/variable.c -o variable.o
-gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/expand.c -o eyxpand.o
+gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/expand.c -o expand.o
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/function.c -o function.o
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/vpath.c -o vpath.o
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/hash.c -o hash.o
@@ -68,12 +68,13 @@ gcc -c -I./src -I%XSRC%/src -I./lib -I%X
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/remote-stub.c -o remote-stub.o
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/getopt.c -o getopt.o
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/getopt1.c -o getopt1.o
+gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/src/load.c -o load.o
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/lib/glob.c -o lib/glob.o
 gcc -c -I./src -I%XSRC%/src -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/lib/fnmatch.c -o lib/fnmatch.o
 @echo off
 echo commands.o > respf.$$$
 for %%f in (job output dir file misc main read remake rule implicit default variable) do echo %%f.o >> respf.$$$
-for %%f in (expand function vpath hash strcache version ar arscan signame remote-stub getopt getopt1) do echo %%f.o >> respf.$$$
+for %%f in (expand function vpath hash strcache version ar arscan signame remote-stub getopt getopt1 load) do echo %%f.o >> respf.$$$
 for %%f in (lib\glob lib\fnmatch) do echo %%f.o >> respf.$$$
 rem gcc  -c -I./src -I%XSRC% -I./lib -I%XSRC%/lib -DHAVE_CONFIG_H -O2 -g %XSRC%/guile.c -o guile.o
 rem echo guile.o >> respf.$$$
diff -aprNU3 make-4.3.orig/mk/msdosdjgpp.mk make-4.3/mk/msdosdjgpp.mk
--- make-4.3.orig/mk/msdosdjgpp.mk	2019-12-21 21:04:06 +0000
+++ make-4.3/mk/msdosdjgpp.mk	2020-01-29 23:08:32 +0000
@@ -31,9 +31,9 @@ prog_SOURCES += $(loadavg_SOURCES) $(glo
 
 BUILT_SOURCES += $(lib)alloca.h $(lib)fnmatch.h $(lib)glob.h
 
-INCLUDEDIR = c:/djgpp/include
-LIBDIR = c:/djgpp/lib
-LOCALEDIR = c:/djgpp/share
+INCLUDEDIR = /dev/envDJDIR/include
+LIBDIR = /dev/envDJDIR/lib
+LOCALEDIR = /dev/envDJDIR/share
 
 MKDIR.cmd = command.com /c mkdir $(call P2W,$1)
 RM.cmd = command.com /c del /F /Q $(call P2W,$1)
diff -aprNU3 make-4.3.orig/src/main.c make-4.3/src/main.c
--- make-4.3.orig/src/main.c	2020-01-07 10:25:38 +0000
+++ make-4.3/src/main.c	2020-01-29 19:31:04 +0000
@@ -1340,8 +1340,10 @@ main (int argc, char **argv, char **envp
     define_variable_cname (".FEATURES", features, o_default, 0);
   }
 
+#ifdef HAVE_GUILE
   /* Configure GNU Guile support */
   guile_gmake_setup (NILF);
+#endif
 
   /* Read in variables from the environment.  It is important that this be
      done before $(MAKE) is figured out so its definitions will not be
diff -aprNU3 make-4.3.orig/src/posixos.c make-4.3/src/posixos.c
--- make-4.3.orig/src/posixos.c	2019-12-21 21:04:06 +0000
+++ make-4.3/src/posixos.c	2020-01-22 21:25:22 +0000
@@ -442,6 +442,7 @@ jobserver_acquire (int timeout)
 
 #endif /* MAKE_JOBSERVER */
 
+#if !defined(VMD) && !defined(WINDOWS32) && !defined(_AMIGA) && !defined(__MSDOS__)
 /* Create a "bad" file descriptor for stdin when parallel jobs are run.  */
 int
 get_bad_stdin (void)
@@ -471,6 +472,7 @@ get_bad_stdin (void)
 
   return bad_stdin;
 }
+#endif
 
 /* Set file descriptors to be inherited / not inherited by subprocesses.  */
 



2020-02-29 Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* lib/getprogname.c (getprogname) [__DJGPP__]:  Implementation of
	DJGPP support.






diff -aprNU3 make-4.3.orig/lib/getprogname.c make-4.3/lib/getprogname.c
--- make-4.3.orig/lib/getprogname.c	2020-01-07 10:26:40 +0000
+++ make-4.3/lib/getprogname.c	2020-02-29 18:37:26 +0000
@@ -51,6 +51,10 @@
 # include <sys/procfs.h>
 #endif
 
+#ifdef __DJGPP__
+# include <crt0.h>
+#endif
+
 #include "dirname.h"
 
 #ifndef HAVE_GETPROGNAME             /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */
@@ -245,6 +249,8 @@ getprogname (void)
         }
     }
   return NULL;
+# elif __DJGPP__
+  return last_component (__crt0_argv ? __crt0_argv[0] : __dos_argv0);
 # else
 #  error "getprogname module not ported to this OS"
 # endif

