2019-06-09  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* gettext-runtime/gnulib-lib/progname.c [MSDOS]: Define new macro
	GET_LAST_SLASH to find the last directory separator character.  On
	DOS-Like systems these are slash, backslash or colon.  For POSIX
	this is simple a slash.

	* gettext-tools/gnulib-lib/execute.c [__DJGPP__]: DJGPP specific
	implementation of execute.

	* gettext-tools/gnulib-lib/djgpp-spawn.h: New file.  Implements DJGPP
	specific stuff.

	* gettext-tools/gnulib-lib/libxml/nanohttp.c: Define SOCKET to int if
	not defined.

	* gettext-tools/gnulib-lib/libxml/xmlIO.c: For DJGPP define _wfopen,
	_wopen and _wstat as NO-OPs.
	(__xmlIOWin32UTF8ToWChar): For DJGPP return always NULL.
	(xmlInitPlatformSpecificIo): For DJGPP return native format of stat
	and open instead of UTF8 version.

	* gettext-tools/gnulib-lib/libxml/libxml.h [PIC, NOLIBTOOL]: Define
	LIBXML_STATIC only if not already defined.

	* gettext-tools/gnulib-lib/libgettextpo/progname.c [MSDOS]: Define new
	macro GET_LAST_SLASH to find the last directory separator character.
	On DOS-Like systems these are slash, backslash or colon.  For POSIX
	this is simple a slash.

	* gettext-tools/gnulib-lib/progname.c [MSDOS]: Define new macro
	GET_LAST_SLASH to find the last directory separator character.  On
	DOS-Like systems these are slash, backslash or colon.  For POSIX
	this is simple a slash.

	* gettext-tools/gnulib-lib/spawn-pipe.c: DJGPP specific implementation
	of create_pipe.

	* gettext-tools/gnulib-lib/spawni.c [__DJGPP__]: DJGPP specific
	implementation of __spawni.  Still not implemented; returns ENOSYS.

	* gettext-tools/gnulib-lib/tempname.c (__path_search): For DJGPP try
	TMP and TEMP also if TMPDIR does not exist or does not point to an
	existing directory.

	* gettext-tools/gnulib-lib/wait-process.c[__DJGPP__]: Include
	djgpp-spawn.h.
	(wait_subprocess): DJGPP specific implementation of wait_subprocess.
	Removes the tmp files used to implement the pipe.

	* gettext-tools/misc/autopoint.in: Appart of TMPDIR support TMP and
	TEMP also and default to the current working directory if neither is
	set.

	* gettext-tools/misc/gettextize.in: Appart of TMPDIR support TMP and
	TEMP also and default to the current working directory if neither is
	set.

	* gnulib-local/lib/libxml/nanohttp.c: Define SOCKET to int if not
	defined.

	* gnulib-local/lib/libxml/xmlIO.c: For DJGPP define _wfopen, _wopen
	and _wstat as NO-OPs; and _stat as stat.
	(__xmlIOWin32UTF8ToWChar): For DJGPP return always NULL.
	(xmlInitPlatformSpecificIo): For DJGPP return native format of stat
	and open instead of UTF8 version.

	* gnulib-local/lib/libxml/libxml.h [PIC, NOLIBTOOL]: Define
	LIBXML_STATIC only if not already defined.

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

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

	* gettext-tools/libgettextpo/getprogname.c (getprogname) [__DJGPP__]:
	Implementation of DJGPP support.

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

	* libtextstyle/lib/term-style-control.c (show_signal_marker) [SIGTSTP]:
	Only if SIGTSTP is defined.

	* gettext-tools/gnulib-lib/execute.c [__DJGPP__]: Include sys/file.h to
	provide _IOERR definition to be used in fseterr function.

	* gettext-runtime/gnulib-lib/stdint.in.h [__DJGPP__]:  For DJGPP, the
	typedef of gl_[u]int32_t must be signed long int as in stdint.h.

	* gettext-tools/gnulib-lib/stdint.in.h [__DJGPP__]:  For DJGPP, the
	typedef of gl_[u]int32_t must be signed long int as in stdint.h.

	* gettext-tools/libgettextpo/stdint.in.h [__DJGPP__]:  For DJGPP, the
	typedef of gl_[u]int32_t must be signed long int as in stdint.h.

	* libtextstyle/lib/stdint.in.h [__DJGPP__]:  For DJGPP, the
	typedef of gl_[u]int32_t must be signed long int as in stdint.h.

	* gettext-tools/gnulib-tests/inet_pton.c (inet_pton): Define
	EAFNOSUPPORT to some arbitrary value if not defined.

	* gettext-tools/gnulib-tests/test-bind.c (main): Run check only if
	HAVE_IPV4 and AF_INET are defined.

	* gettext-tools/gnulib-tests/test-connect.c (main): Run check only if
	HAVE_IPV4 and AF_INET are defined.

	* gettext-tools/gnulib-tests/test-errno.c: Run check only for those
	errnos that are defined by DJGPP.





diff -aprNU5 gettext-0.20.1.orig/gettext-runtime/gnulib-lib/getprogname.c gettext-0.20.1/gettext-runtime/gnulib-lib/getprogname.c
--- gettext-0.20.1.orig/gettext-runtime/gnulib-lib/getprogname.c	2019-03-20 20:59:14 +0000
+++ gettext-0.20.1/gettext-runtime/gnulib-lib/getprogname.c	2019-06-16 00:16:40 +0000
@@ -49,10 +49,14 @@
 # include <stdio.h>
 # include <fcntl.h>
 # 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 */
 char const *
 getprogname (void)
@@ -242,10 +246,12 @@ getprogname (void)
               return memcpy (namecopy, name, namelen);
             }
         }
     }
   return NULL;
+# elif __DJGPP__
+  return last_component (__crt0_argv ? __crt0_argv[0] : __dos_argv0);
 # else
 #  error "getprogname module not ported to this OS"
 # endif
 }
 
diff -aprNU5 gettext-0.20.1.orig/gettext-runtime/gnulib-lib/progname.c gettext-0.20.1/gettext-runtime/gnulib-lib/progname.c
--- gettext-0.20.1.orig/gettext-runtime/gnulib-lib/progname.c	2019-01-06 12:16:14 +0000
+++ gettext-0.20.1/gettext-runtime/gnulib-lib/progname.c	2019-06-16 00:16:40 +0000
@@ -25,10 +25,43 @@
 #include <errno.h> /* get program_invocation_name declaration */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+/* MS-DOS and similar non-Posix systems have some peculiarities:
+    - they use both `/' and `\\' as directory separator in file names;
+    - they can have a drive letter X: prepended to a file name;
+   These are all parameterized here.  */
+
+#ifdef MSDOS
+# if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define __gnuc_extension__  __extension__
+# else
+#  define __gnuc_extension__
+# endif
+# include <libc/unconst.h>
+# undef  IS_SLASH
+# define IS_SLASH(c)  ((c) == '/' || (c) == '\\' || (c) == ':')
+# define GET_LAST_SLASH(filename)              \
+  (__gnuc_extension__                          \
+    ({                                         \
+      char *_slash = NULL;                     \
+      if ((filename))                          \
+      {                                        \
+        _slash = unconst((filename), char *);  \
+        while (*_slash++)                      \
+          ;                                    \
+        while ((--_slash - (filename)))        \
+          if (IS_SLASH(*_slash))               \
+            break;                             \
+      }                                        \
+      _slash;                                  \
+    })                                         \
+  )
+#else
+# define GET_LAST_SLASH(filename)  (strrchr((filename), '/'))
+#endif
 
 /* String containing name the program is called with.
    To be initialized by main().  */
 const char *program_name = NULL;
 
@@ -54,13 +87,21 @@ set_program_name (const char *argv0)
       fputs ("A NULL argv[0] was passed through an exec system call.\n",
              stderr);
       abort ();
     }
 
-  slash = strrchr (argv0, '/');
+  slash = GET_LAST_SLASH (argv0);
   base = (slash != NULL ? slash + 1 : argv0);
-  if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
+  if (base - argv0 >= 7 && (strncmp (base - 7, "/.libs/", 7) == 0
+#ifdef MSDOS
+     || strncmp (base - 7, "\\.libs/", 7) == 0
+     || strncmp (base - 7, "\\.libs\\", 7) == 0
+     || strncmp (base - 7, "/_libs/", 7) == 0
+     || strncmp (base - 7, "\\_libs/", 7) == 0
+     || strncmp (base - 7, "\\_libs\\", 7) == 0
+#endif
+     ))
     {
       argv0 = base;
       if (strncmp (base, "lt-", 3) == 0)
         {
           argv0 = base + 3;
diff -aprNU5 gettext-0.20.1.orig/gettext-runtime/gnulib-lib/stdint.in.h gettext-0.20.1/gettext-runtime/gnulib-lib/stdint.in.h
--- gettext-0.20.1.orig/gettext-runtime/gnulib-lib/stdint.in.h	2019-01-06 12:16:16 +0000
+++ gettext-0.20.1/gettext-runtime/gnulib-lib/stdint.in.h	2019-06-16 00:16:40 +0000
@@ -160,12 +160,17 @@ typedef unsigned short int gl_uint16_t;
 # define int16_t gl_int16_t
 # define uint16_t gl_uint16_t
 
 # undef int32_t
 # undef uint32_t
+#if __DJGPP__
+typedef long int gl_int32_t;
+typedef unsigned long int gl_uint32_t;
+#else  /* !__DJGPP__ */
 typedef int gl_int32_t;
 typedef unsigned int gl_uint32_t;
+#endif /* !__DJGPP__ */
 # define int32_t gl_int32_t
 # define uint32_t gl_uint32_t
 
 /* If the system defines INT64_MAX, assume int64_t works.  That way,
    if the underlying platform defines int64_t to be a 64-bit long long
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-lib/djgpp-spawn.h gettext-0.20.1/gettext-tools/gnulib-lib/djgpp-spawn.h
--- gettext-0.20.1.orig/gettext-tools/gnulib-lib/djgpp-spawn.h	1970-01-01 00:00:00 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-lib/djgpp-spawn.h	2019-06-16 00:16:40 +0000
@@ -0,0 +1,155 @@
+#include <config.h>
+#include <stdio.h>
+#include "cloexec.h"
+#include "xalloc.h"
+
+#define prepare_spawn(argv)                                        \
+(__gnuc_extension__                                                \
+  ({                                                               \
+     size_t _argc;                                                 \
+     char **_new_argv;                                             \
+                                                                   \
+     for (_argc = 0; (argv)[_argc]; _argc++)                       \
+       ;                                                           \
+                                                                   \
+     _new_argv = xmalloc((1 + _argc + 1) * sizeof(_new_argv[0]));  \
+     *_new_argv++ = "/dev/env/DJDIR/bin/sh";                       \
+                                                                   \
+     for (_argc = 0; (_new_argv[_argc] = argv[_argc]); _argc++)    \
+       ;                                                           \
+                                                                   \
+     _new_argv;                                                    \
+  })                                                               \
+)
+
+
+#define PIPE_STDIN   0
+#define PIPE_STDOUT  1
+
+#define PIPE_END_FILE_NAME_PATTERN  "gtXXXXXX"
+
+
+char tmp_file_name[2][L_tmpnam];  /*  0: pipe stdin, 1: pipe stdout.  */
+
+
+#define remove_tmp_file(name)                                                \
+(__gnuc_extension__                                                          \
+  ({                                                                         \
+     if ((name))                                                             \
+     {                                                                       \
+       if (unlink((name)))                                                   \
+         error(exit_on_error ? EXIT_FAILURE : 0, errno,                      \
+               _("removing of `%s' failed"), (name));                        \
+     }                                                                       \
+     else                                                                    \
+     {                                                                       \
+       if (tmp_file_name[PIPE_STDIN][0])                                     \
+       {                                                                     \
+         if (unlink(tmp_file_name[PIPE_STDIN]))                              \
+           error(exit_on_error ? EXIT_FAILURE : 0, errno,                    \
+                 _("removing of `%s' failed"), tmp_file_name[PIPE_STDIN]);   \
+       }                                                                     \
+       if (tmp_file_name[PIPE_STDOUT][0])                                    \
+       {                                                                     \
+         if (unlink(tmp_file_name[PIPE_STDOUT]))                             \
+           error(exit_on_error ? EXIT_FAILURE : 0, errno,                    \
+                 _("removing of `%s' failed"), tmp_file_name[PIPE_STDOUT]);  \
+       }                                                                     \
+     }                                                                       \
+  })                                                                         \
+)
+
+
+/* Duplicates a file handle, making the copy uninheritable.
+   Returns -1 for a file handle that is equivalent to closed.  */
+static int
+dup_noinherit(int fd)
+{
+  fd = dup_cloexec(fd);
+  if (fd < 0 && errno == EMFILE)
+    error(EXIT_FAILURE, errno, _("fcntl failed"));
+
+  return fd;
+}
+
+/* Returns a file descriptor equivalent to FD, except that the resulting file
+   descriptor is none of STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO.
+   FD must be open and non-inheritable.  The result will be non-inheritable as
+   well.
+   If FD < 0, FD itself is returned.  */
+static int
+fd_safer_noinherit(int fd)
+{
+  if (STDIN_FILENO <= fd && fd <= STDERR_FILENO)
+  {
+    /* The recursion depth is at most 3.  */
+    int nfd = fd_safer_noinherit(dup_noinherit(fd));
+    int saved_errno = errno;
+    close(fd);
+    errno = saved_errno;
+    return nfd;
+  }
+  return fd;
+}
+
+/* Duplicates a file handle, making the copy uninheritable and ensuring the
+   result is none of STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO.
+   Returns -1 for a file handle that is equivalent to closed.  */
+static int
+dup_safer_noinherit(int fd)
+{
+  return fd_safer_noinherit(dup_noinherit(fd));
+}
+
+/* Undoes the effect of TEMPFD = dup_safer_noinherit (ORIGFD);  */
+static void
+undup_safer_noinherit(int tempfd, int origfd)
+{
+  if (tempfd >= 0)
+  {
+    if (dup2(tempfd, origfd) < 0)
+      error(EXIT_FAILURE, errno, _("cannot restore fd %d: dup2 failed"), origfd);
+    close(tempfd);
+  }
+  else
+  {
+    /* origfd was closed or open to no handle at all.  Set it to a closed
+       state.  This is (nearly) equivalent to the original state.  */
+    close(origfd);
+  }
+}
+
+#ifdef _SPAWN_PIPE_H
+static int
+djgpp_pipe(int pipe_fd[2], int pipe_end)
+{
+  int fd;
+
+  strcpy(tmp_file_name[pipe_end], "/dev/env/TMPDIR/"PIPE_END_FILE_NAME_PATTERN);
+  if ((fd = mkstemp(tmp_file_name[pipe_end])) < 0)
+  {
+    strcpy(tmp_file_name[pipe_end], "/dev/env/TMP/"PIPE_END_FILE_NAME_PATTERN);
+    if ((fd = mkstemp(tmp_file_name[pipe_end])) < 0)
+    {
+      strcpy(tmp_file_name[pipe_end], "/dev/env/TEMP/"PIPE_END_FILE_NAME_PATTERN);
+      if ((fd = mkstemp(tmp_file_name[pipe_end])) < 0)
+        return -1;
+    }
+  }
+
+  if (pipe_end == PIPE_STDIN)
+  {
+    pipe_fd[PIPE_STDIN] = fd;
+    pipe_fd[PIPE_STDOUT] = -1;
+    tmp_file_name[PIPE_STDOUT][0] = '\0';
+  }
+  else if (pipe_end == PIPE_STDOUT)
+  {
+    pipe_fd[PIPE_STDOUT] = fd;
+    pipe_fd[PIPE_STDIN] = -1;
+    tmp_file_name[PIPE_STDIN][0] = '\0';
+  }
+
+  return 0;
+}
+#endif
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-lib/execute.c gettext-0.20.1/gettext-tools/gnulib-lib/execute.c
--- gettext-0.20.1.orig/gettext-tools/gnulib-lib/execute.c	2019-01-06 12:17:02 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-lib/execute.c	2019-06-16 00:16:40 +0000
@@ -39,10 +39,16 @@
 
 /* Native Windows API.  */
 # include <process.h>
 # include "w32spawn.h"
 
+#elif defined __DJGPP__
+
+/* DJGPP API.  */
+# include <process.h>
+# include "djgpp-spawn.h"
+
 #else
 
 /* Unix API.  */
 # include <spawn.h>
 
@@ -164,10 +170,96 @@ execute (const char *progname,
     }
   if (nulloutfd >= 0)
     close (nulloutfd);
   if (nullinfd >= 0)
     close (nullinfd);
+
+  /* Restore standard file handles of parent process.  */
+  if (null_stderr)
+    undup_safer_noinherit (orig_stderr, STDERR_FILENO);
+  if (null_stdout)
+    undup_safer_noinherit (orig_stdout, STDOUT_FILENO);
+  if (null_stdin)
+    undup_safer_noinherit (orig_stdin, STDIN_FILENO);
+
+  if (termsigp != NULL)
+    *termsigp = 0;
+
+  if (exitcode == -1)
+    {
+      if (exit_on_error || !null_stderr)
+        error (exit_on_error ? EXIT_FAILURE : 0, errno,
+               _("%s subprocess failed"), progname);
+      return 127;
+    }
+
+  return exitcode;
+
+#elif defined __DJGPP__
+
+  int orig_stdin = STDIN_FILENO;
+  int orig_stdout = STDOUT_FILENO;
+  int orig_stderr = STDERR_FILENO;
+  int exitcode;
+  int nullinfd;
+  int nulloutfd;
+
+  /* Add an element upfront that can be used when argv[0] turns out to be a
+     script, not a program.  */
+  char **new_prog_argv = prepare_spawn (prog_argv);
+
+  /* Save standard file handles of parent process.  */
+ if (null_stdin)
+    orig_stdin = dup_safer_noinherit (STDIN_FILENO);
+  if (null_stdout)
+    orig_stdout = dup_safer_noinherit (STDOUT_FILENO);
+  if (null_stderr)
+    orig_stderr = dup_safer_noinherit (STDERR_FILENO);
+  exitcode = -1;
+
+  /* Create standard file handles of child process.  */
+  nullinfd = -1;
+  nulloutfd = -1;
+  if ((!null_stdin
+       || ((nullinfd = open ("/dev/null", O_RDONLY | O_BINARY, 0)) >= 0
+           && (nullinfd == STDIN_FILENO
+               || (dup2 (nullinfd, STDIN_FILENO) >= 0
+                   && close (nullinfd) >= 0))))
+      && (!(null_stdout || null_stderr)
+          || ((nulloutfd = open ("/dev/null", O_RDWR | O_BINARY, 0)) >= 0
+              && (!null_stdout
+                  || nulloutfd == STDOUT_FILENO
+                  || dup2 (nulloutfd, STDOUT_FILENO) >= 0)
+              && (!null_stderr
+                  || nulloutfd == STDERR_FILENO
+                  || dup2 (nulloutfd, STDERR_FILENO) >= 0)
+              && ((null_stdout && nulloutfd == STDOUT_FILENO)
+                  || (null_stderr && nulloutfd == STDERR_FILENO)
+                  || close (nulloutfd) >= 0))))
+    /* Use spawnvpe and pass the environment explicitly.  This is needed if
+       the program has modified the environment using putenv() or [un]setenv().
+       On Windows, programs have two environments, one in the "environment
+       block" of the process and managed through SetEnvironmentVariable(), and
+       one inside the process, in the location retrieved by the 'environ'
+       macro.  When using spawnvp() without 'e', the child process inherits a
+       copy of the environment block - ignoring the effects of putenv() and
+       [un]setenv().  */
+    {
+      exitcode = spawnvpe (P_WAIT, prog_path, new_prog_argv, environ);
+      if (--new_prog_argv, exitcode < 0 && errno == ENOEXEC)
+        {
+          /* prog is not an native executable.  Try to execute it as a
+             shell script.  Note that prepare_spawn() has already prepended
+             a hidden element "/dev/env/DJDIR/bin/sh" to new_prog_argv.  */
+          exitcode = spawnvpe (P_WAIT, new_prog_argv[0], new_prog_argv, environ);
+        }
+      free (new_prog_argv);
+    }
+  if (nulloutfd >= 0)
+    close (nulloutfd);
+  if (nullinfd >= 0)
+    close (nullinfd);
 
   /* Restore standard file handles of parent process.  */
   if (null_stderr)
     undup_safer_noinherit (orig_stderr, STDERR_FILENO);
   if (null_stdout)
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-lib/getprogname.c gettext-0.20.1/gettext-tools/gnulib-lib/getprogname.c
--- gettext-0.20.1.orig/gettext-tools/gnulib-lib/getprogname.c	2019-03-20 21:00:06 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-lib/getprogname.c	2019-06-16 00:16:40 +0000
@@ -49,10 +49,14 @@
 # include <stdio.h>
 # include <fcntl.h>
 # 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 */
 char const *
 getprogname (void)
@@ -242,10 +246,12 @@ getprogname (void)
               return memcpy (namecopy, name, namelen);
             }
         }
     }
   return NULL;
+# elif __DJGPP__
+  return last_component (__crt0_argv ? __crt0_argv[0] : __dos_argv0);
 # else
 #  error "getprogname module not ported to this OS"
 # endif
 }
 
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-lib/libxml/nanohttp.c gettext-0.20.1/gettext-tools/gnulib-lib/libxml/nanohttp.c
--- gettext-0.20.1.orig/gettext-tools/gnulib-lib/libxml/nanohttp.c	2017-12-02 08:58:10 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-lib/libxml/nanohttp.c	2019-06-20 01:08:50 +0000
@@ -90,13 +90,17 @@
  */
 #ifndef _WINSOCKAPI_
 #if !defined(__BEOS__) || defined(__HAIKU__)
 #define closesocket(s) close(s)
 #endif
+#ifndef SOCKET
 #define SOCKET int
+#endif
+#ifndef INVALID_SOCKET
 #define INVALID_SOCKET (-1)
 #endif
+#endif
 
 #ifdef __BEOS__
 #ifndef PF_INET
 #define PF_INET AF_INET
 #endif
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-lib/libxml/xmlIO.c gettext-0.20.1/gettext-tools/gnulib-lib/libxml/xmlIO.c
--- gettext-0.20.1.orig/gettext-tools/gnulib-lib/libxml/xmlIO.c	2018-03-26 14:30:46 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-lib/libxml/xmlIO.c	2019-06-20 01:08:50 +0000
@@ -21,10 +21,15 @@
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
+#if defined (__DJGPP__)
+/*  _stat does not exist in DJGPP.  */
+#undef _stat
+#define _stat stat
+#endif
 #endif
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
 #ifdef HAVE_UNISTD_H
@@ -188,10 +193,17 @@ static const char *IOerr[] = {
     "adddress in use",		/* EADDRINUSE */
     "already in use",		/* EALREADY */
     "unknown address familly",	/* EAFNOSUPPORT */
 };
 
+#if defined (__DJGPP__)
+/*  I/O function that expect UTF-8 strings as arguments are not supported by DJGPP.  */
+# define _wfopen(filename, mode)  (NULL)
+# define _wopen(filename, omode)  (-1)
+# define _wstat(path, buffer)     (-1)
+#endif
+
 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
 /**
  * __xmlIOWin32UTF8ToWChar:
  * @u8String:  uft-8 string
  *
@@ -200,10 +212,11 @@ static const char *IOerr[] = {
 static wchar_t *
 __xmlIOWin32UTF8ToWChar(const char *u8String)
 {
     wchar_t *wString = NULL;
 
+#if !defined (__DJGPP__)
     if (u8String) {
         int wLen =
             MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, u8String,
                                 -1, NULL, 0);
         if (wLen) {
@@ -215,10 +228,11 @@ __xmlIOWin32UTF8ToWChar(const char *u8St
                     wString = NULL;
                 }
             }
         }
     }
+#endif  /* !__DJGPP__ */
 
     return wString;
 }
 #endif
 
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-lib/progname.c gettext-0.20.1/gettext-tools/gnulib-lib/progname.c
--- gettext-0.20.1.orig/gettext-tools/gnulib-lib/progname.c	2019-01-06 12:17:06 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-lib/progname.c	2019-06-16 00:16:40 +0000
@@ -25,10 +25,43 @@
 #include <errno.h> /* get program_invocation_name declaration */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+/* MS-DOS and similar non-Posix systems have some peculiarities:
+    - they use both `/' and `\\' as directory separator in file names;
+    - they can have a drive letter X: prepended to a file name;
+   These are all parameterized here.  */
+
+#ifdef MSDOS
+# if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define __gnuc_extension__  __extension__
+# else
+#  define __gnuc_extension__
+# endif
+# include <libc/unconst.h>
+# undef  IS_SLASH
+# define IS_SLASH(c)  ((c) == '/' || (c) == '\\' || (c) == ':')
+# define GET_LAST_SLASH(filename)              \
+  (__gnuc_extension__                          \
+    ({                                         \
+      char *_slash = NULL;                     \
+      if ((filename))                          \
+      {                                        \
+        _slash = unconst((filename), char *);  \
+        while (*_slash++)                      \
+          ;                                    \
+        while ((--_slash - (filename)))        \
+          if (IS_SLASH(*_slash))               \
+            break;                             \
+      }                                        \
+      _slash;                                  \
+    })                                         \
+  )
+#else
+# define GET_LAST_SLASH(filename)  (strrchr((filename), '/'))
+#endif
 
 /* String containing name the program is called with.
    To be initialized by main().  */
 const char *program_name = NULL;
 
@@ -54,13 +87,21 @@ set_program_name (const char *argv0)
       fputs ("A NULL argv[0] was passed through an exec system call.\n",
              stderr);
       abort ();
     }
 
-  slash = strrchr (argv0, '/');
+  slash = GET_LAST_SLASH (argv0);
   base = (slash != NULL ? slash + 1 : argv0);
-  if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
+  if (base - argv0 >= 7 && (strncmp (base - 7, "/.libs/", 7) == 0
+#ifdef MSDOS
+     || strncmp (base - 7, "\\.libs/", 7) == 0
+     || strncmp (base - 7, "\\.libs\\", 7) == 0
+     || strncmp (base - 7, "/_libs/", 7) == 0
+     || strncmp (base - 7, "\\_libs/", 7) == 0
+     || strncmp (base - 7, "\\_libs\\", 7) == 0
+#endif
+     ))
     {
       argv0 = base;
       if (strncmp (base, "lt-", 3) == 0)
         {
           argv0 = base + 3;
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-lib/spawn-pipe.c gettext-0.20.1/gettext-tools/gnulib-lib/spawn-pipe.c
--- gettext-0.20.1.orig/gettext-tools/gnulib-lib/spawn-pipe.c	2019-01-06 12:17:06 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-lib/spawn-pipe.c	2019-06-16 00:16:40 +0000
@@ -44,10 +44,16 @@
 
 /* Native Windows API.  */
 # include <process.h>
 # include "w32spawn.h"
 
+#elif defined __DJGPP__
+
+/* DJGPP API.  */
+# include <process.h>
+# include "djgpp-spawn.h"
+
 #else
 
 /* Unix API.  */
 # include <spawn.h>
 
@@ -245,10 +251,135 @@ create_pipe (const char *progname,
     fd[0] = ifd[0];
   if (pipe_stdin)
     fd[1] = ofd[1];
   return child;
 
+#elif defined  __DJGPP__
+
+  /* DJGPP API.  */
+  int ifd[2];
+  int ofd[2];
+  int orig_stdin = STDIN_FILENO;
+  int orig_stdout = STDOUT_FILENO;
+  int orig_stderr = STDERR_FILENO;
+  int child;
+  int nulloutfd;
+  int stdinfd;
+  int stdoutfd;
+  int saved_errno = 0;
+
+  /* Add an element upfront that can be used when argv[0] turns out to be a
+     script, not a program.  */
+  char **new_prog_argv = prepare_spawn (prog_argv);
+
+  if (pipe_stdout)
+    if (djgpp_pipe (ifd, PIPE_STDOUT) < 0)
+      error (EXIT_FAILURE, errno, _("cannot create pipe"));
+  if (pipe_stdin)
+    if (djgpp_pipe (ofd, PIPE_STDIN) < 0)
+      error (EXIT_FAILURE, errno, _("cannot create pipe"));
+/* Data flow diagram:
+ *
+ *           write        system         read
+ *    parent  ->   ofd[1]   ->   ofd[0]   ->   child       if pipe_stdin
+ *    parent  <-   ifd[0]   <-   ifd[1]   <-   child       if pipe_stdout
+ *           read         system         write
+ *
+ */
+
+  /* Save standard file handles of parent process.  */
+  if (pipe_stdin || prog_stdin != NULL)
+    orig_stdin = dup_safer_noinherit (STDIN_FILENO);
+  if (pipe_stdout || prog_stdout != NULL)
+    orig_stdout = dup_safer_noinherit (STDOUT_FILENO);
+  if (null_stderr)
+    orig_stderr = dup_safer_noinherit (STDERR_FILENO);
+  child = -1;
+
+  /* Create standard file handles of child process.  */
+  nulloutfd = -1;
+  stdinfd = -1;
+  stdoutfd = -1;
+  if ((!pipe_stdin || dup2 (ofd[0], STDIN_FILENO) >= 0)
+      && (!pipe_stdout || dup2 (ifd[1], STDOUT_FILENO) >= 0)
+      && (!null_stderr
+	  || ((nulloutfd = open ("/dev/null", O_RDWR, 0)) >= 0
+	      && (nulloutfd == STDERR_FILENO
+		  || (dup2 (nulloutfd, STDERR_FILENO) >= 0
+		      && close (nulloutfd) >= 0))))
+      && (pipe_stdin
+	  || prog_stdin == NULL
+	  || ((stdinfd = open (prog_stdin, O_RDONLY, 0)) >= 0
+	      && (stdinfd == STDIN_FILENO
+		  || (dup2 (stdinfd, STDIN_FILENO) >= 0
+		      && close (stdinfd) >= 0))))
+      && (pipe_stdout
+	  || prog_stdout == NULL
+	  || ((stdoutfd = open (prog_stdout, O_WRONLY, 0)) >= 0
+	      && (stdoutfd == STDOUT_FILENO
+		  || (dup2 (stdoutfd, STDOUT_FILENO) >= 0
+		      && close (stdoutfd) >= 0)))))
+    /* The child process doesn't inherit ifd[0], ifd[1], ofd[0], ofd[1],
+       but it inherits all open()ed or dup2()ed file handles (which is what
+       we want in the case of STD*_FILENO) and also orig_stdin,
+       orig_stdout, orig_stderr (which is not explicitly wanted but
+       harmless).  */
+    /* Use spawnvpe and pass the environment explicitly.  This is needed if
+       the program has modified the environment using putenv() or [un]setenv().
+       On Windows, programs have two environments, one in the "environment
+       block" of the process and managed through SetEnvironmentVariable(), and
+       one inside the process, in the location retrieved by the 'environ'
+       macro.  When using spawnvp() without 'e', the child process inherits a
+       copy of the environment block - ignoring the effects of putenv() and
+       [un]setenv().  */
+    {
+      child = spawnvpe (P_WAIT, prog_path, prog_argv, environ);
+      if (child < 0 && errno == ENOEXEC)
+	{
+	  /* prog is not an native executable.  Try to execute it as a
+	     shell script.  Note that prepare_spawn() has already prepended
+	     a hidden element "sh.exe" to prog_argv.  */
+	  --prog_argv;
+	  child = spawnvpe (P_WAIT, prog_argv[0], prog_argv, environ);
+	}
+    }
+  if (child == -1)
+    saved_errno = errno;
+  if (stdinfd >= 0)
+    close (stdinfd);
+  if (stdoutfd >= 0)
+    close (stdoutfd);
+  if (nulloutfd >= 0)
+    close (nulloutfd);
+
+  /* Restore standard file handles of parent process.  */
+  if (null_stderr)
+    dup2 (orig_stderr, STDERR_FILENO), close (orig_stderr);
+  if (pipe_stdout || prog_stdout != NULL)
+    dup2 (orig_stdout, STDOUT_FILENO), close (orig_stdout);
+  if (pipe_stdin || prog_stdin != NULL)
+    dup2 (orig_stdin, STDIN_FILENO), close (orig_stdin);
+
+  if (pipe_stdin)
+    close (ofd[0]);
+  if (pipe_stdout)
+    close (ifd[1]);
+  if (child == -1)
+    {
+      if (exit_on_error || !null_stderr)
+	error (exit_on_error ? EXIT_FAILURE : 0, errno,
+	       _("%s subprocess failed"), progname);
+      errno = saved_errno;
+      return -1;
+    }
+
+  if (pipe_stdout)
+    fd[0] = open (tmp_file_name[PIPE_STDOUT], O_RDONLY, S_IRUSR);
+  if (pipe_stdin)
+    fd[1] = open (tmp_file_name[PIPE_STDIN], O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR);
+  return child;
+
 #else
 
   /* Unix API.  */
   int ifd[2];
   int ofd[2];
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-lib/spawni.c gettext-0.20.1/gettext-tools/gnulib-lib/spawni.c
--- gettext-0.20.1.orig/gettext-tools/gnulib-lib/spawni.c	2019-01-06 12:17:06 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-lib/spawni.c	2019-06-16 00:16:40 +0000
@@ -38,10 +38,17 @@
 #include <signal.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
+#ifdef __DJGPP__
+/*  Provide DJGPP specific prototypes of setresgid and setresuid.
+    These are placebos and do nothing but are required for porting.  */
+int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
+int setresuid(uid_t ruid, uid_t euid, uid_t suid);
+#endif
+
 #if _LIBC
 # include <not-cancel.h>
 #else
 # define close_not_cancel close
 # define open_not_cancel open
@@ -100,10 +107,23 @@ __spawni (pid_t *pid, const char *file,
 {
   /* Not yet implemented.  */
   return ENOSYS;
 }
 
+#elif defined __DJGPP__
+
+/* MSDOS/DJGPP API.  */
+int
+__spawni (pid_t *pid, const char *file,
+	  const posix_spawn_file_actions_t *file_actions,
+	  const posix_spawnattr_t *attrp, char *const argv[],
+	  char *const envp[], int use_path)
+{
+  /* Not yet implemented.  */
+  return ENOSYS;
+}
+
 #else
 
 
 /* The file is accessible but it is not an executable file.  Invoke
    the shell to interpret it as a script.  */
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-lib/stdint.in.h gettext-0.20.1/gettext-tools/gnulib-lib/stdint.in.h
--- gettext-0.20.1.orig/gettext-tools/gnulib-lib/stdint.in.h	2019-01-06 12:17:06 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-lib/stdint.in.h	2019-06-16 00:16:40 +0000
@@ -160,12 +160,17 @@ typedef unsigned short int gl_uint16_t;
 # define int16_t gl_int16_t
 # define uint16_t gl_uint16_t
 
 # undef int32_t
 # undef uint32_t
+#if __DJGPP__
+typedef long int gl_int32_t;
+typedef unsigned long int gl_uint32_t;
+#else  /* !__DJGPP__ */
 typedef int gl_int32_t;
 typedef unsigned int gl_uint32_t;
+#endif /* !__DJGPP__ */
 # define int32_t gl_int32_t
 # define uint32_t gl_uint32_t
 
 /* If the system defines INT64_MAX, assume int64_t works.  That way,
    if the underlying platform defines int64_t to be a 64-bit long long
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-lib/stdio-impl.h gettext-0.20.1/gettext-tools/gnulib-lib/stdio-impl.h
--- gettext-0.20.1.orig/gettext-tools/gnulib-lib/stdio-impl.h	2019-01-06 12:17:06 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-lib/stdio-impl.h	2019-06-16 00:16:40 +0000
@@ -28,10 +28,12 @@
 /* BSD stdio derived implementations.  */
 
 #if defined __NetBSD__                         /* NetBSD */
 /* Get __NetBSD_Version__.  */
 # include <sys/param.h>
+#elif defined __DJGPP__
+# include <libc/file.h>
 #endif
 
 #include <errno.h>                             /* For detecting Plan9.  */
 
 #if defined __sferror || defined __DragonFly__ || defined __ANDROID__
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-lib/tempname.c gettext-0.20.1/gettext-tools/gnulib-lib/tempname.c
--- gettext-0.20.1.orig/gettext-tools/gnulib-lib/tempname.c	2019-01-06 12:17:06 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-lib/tempname.c	2019-06-16 00:16:40 +0000
@@ -28,10 +28,16 @@
 #include <errno.h>
 #ifndef __set_errno
 # define __set_errno(Val) errno = (Val)
 #endif
 
+#ifdef MSDOS
+# define HAVE_DIFFERENT_TMPDIR  1
+#else
+# define HAVE_DIFFERENT_TMPDIR  0
+#endif
+
 #include <stdio.h>
 #ifndef P_tmpdir
 # define P_tmpdir "/tmp"
 #endif
 #ifndef TMP_MAX
@@ -136,30 +142,41 @@ __path_search (char *tmpl, size_t tmpl_l
   if (try_tmpdir)
     {
       d = __secure_getenv ("TMPDIR");
       if (d != NULL && direxists (d))
         dir = d;
+#if HAVE_DIFFERENT_TMPDIR
+      else if ((d = __secure_getenv ("TMP")) && direxists (d))
+	dir = d;
+      else if ((d = __secure_getenv ("TEMP")) && direxists (d))
+	dir = d;
+#endif
       else if (dir != NULL && direxists (dir))
         /* nothing */ ;
       else
         dir = NULL;
     }
   if (dir == NULL)
     {
       if (direxists (P_tmpdir))
         dir = P_tmpdir;
+#if !HAVE_DIFFERENT_TMPDIR
       else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
         dir = "/tmp";
+#else
+      else if (strcmp (P_tmpdir, ".") != 0 && direxists ("."))
+	dir = "./";
+#endif
       else
         {
           __set_errno (ENOENT);
           return -1;
         }
     }
 
   dlen = strlen (dir);
-  while (dlen > 1 && dir[dlen - 1] == '/')
+  while (dlen > 1 && ISSLASH (dir[dlen - 1]))
     dlen--;                     /* remove trailing slashes */
 
   /* check we have room for "${dir}/${pfx}XXXXXX\0" */
   if (tmpl_len < dlen + 1 + plen + 6 + 1)
     {
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-lib/wait-process.c gettext-0.20.1/gettext-tools/gnulib-lib/wait-process.c
--- gettext-0.20.1.orig/gettext-tools/gnulib-lib/wait-process.c	2019-03-20 21:00:08 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-lib/wait-process.c	2019-06-16 00:16:40 +0000
@@ -46,10 +46,14 @@
 
 /* The return value of spawnvp() is really a process handle as returned
    by CreateProcess().  Therefore we can kill it using TerminateProcess.  */
 # define kill(pid,sig) TerminateProcess ((HANDLE) (pid), sig)
 
+#elif defined __DJGPP__
+
+# include "djgpp-spawn.h"
+
 #endif
 
 
 /* Type of an entry in the slaves array.
    The 'used' bit determines whether this entry is currently in use.
@@ -299,10 +303,25 @@ wait_subprocess (pid_t child, const char
   int status;
 
   if (termsigp != NULL)
     *termsigp = 0;
   status = 0;
+# ifdef __DJGPP__
+  /* Child process already finished.  */
+
+  remove_tmp_file(NULL);
+  if (child == -1)
+    {
+      if (exit_on_error || !null_stderr)
+        error (exit_on_error ? EXIT_FAILURE : 0, errno,
+               _("%s subprocess failed"), progname);
+      return 127;
+    }
+
+  return WEXITSTATUS (child);
+
+# else
   for (;;)
     {
       int result = waitpid (child, &status, 0);
 
       if (result != child)
@@ -363,7 +382,8 @@ wait_subprocess (pid_t child, const char
         error (exit_on_error ? EXIT_FAILURE : 0, 0,
                _("%s subprocess failed"), progname);
       return 127;
     }
   return WEXITSTATUS (status);
+# endif
 #endif
 }
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-tests/inet_pton.c gettext-0.20.1/gettext-tools/gnulib-tests/inet_pton.c
--- gettext-0.20.1.orig/gettext-tools/gnulib-tests/inet_pton.c	2019-01-06 12:17:10 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-tests/inet_pton.c	2019-06-16 00:16:40 +0000
@@ -81,19 +81,24 @@ static int inet_pton6 (const char *src,
 int
 inet_pton (int af, const char *restrict src, void *restrict dst)
 {
   switch (af)
     {
+# if HAVE_IPV4
     case AF_INET:
       return (inet_pton4 (src, dst));
+# endif
 
 # if HAVE_IPV6
     case AF_INET6:
       return (inet_pton6 (src, dst));
 # endif
 
     default:
+# ifndef EAFNOSUPPORT
+#  define EAFNOSUPPORT  100000
+#endif
       errno = EAFNOSUPPORT;
       return (-1);
     }
   /* NOTREACHED */
 }
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-tests/test-bind.c gettext-0.20.1/gettext-tools/gnulib-tests/test-bind.c
--- gettext-0.20.1.orig/gettext-tools/gnulib-tests/test-bind.c	2019-01-06 12:17:10 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-tests/test-bind.c	2019-06-16 00:15:40 +0000
@@ -17,11 +17,13 @@
 #include <config.h>
 
 #include <sys/socket.h>
 
 #include "signature.h"
+#if HAVE_IPV4
 SIGNATURE_CHECK (bind, int, (int, const struct sockaddr *, socklen_t));
+#endif
 
 #include <errno.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <unistd.h>
@@ -30,10 +32,11 @@ SIGNATURE_CHECK (bind, int, (int, const
 #include "macros.h"
 
 int
 main (void)
 {
+#if HAVE_IPV4
   (void) gl_sockets_startup (SOCKETS_1_1);
 
   /* Test behaviour for invalid file descriptors.  */
   {
     struct sockaddr_in addr;
@@ -51,8 +54,9 @@ main (void)
       errno = 0;
       ASSERT (bind (99, (const struct sockaddr *) &addr, sizeof (addr)) == -1);
       ASSERT (errno == EBADF);
     }
   }
+#endif
 
   return 0;
 }
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-tests/test-connect.c gettext-0.20.1/gettext-tools/gnulib-tests/test-connect.c
--- gettext-0.20.1.orig/gettext-tools/gnulib-tests/test-connect.c	2019-01-06 12:17:10 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-tests/test-connect.c	2019-06-16 00:15:38 +0000
@@ -17,11 +17,13 @@
 #include <config.h>
 
 #include <sys/socket.h>
 
 #include "signature.h"
+#if HAVE_IPV4
 SIGNATURE_CHECK (connect, int, (int, const struct sockaddr *, socklen_t));
+#endif
 
 #include <errno.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <unistd.h>
@@ -30,10 +32,11 @@ SIGNATURE_CHECK (connect, int, (int, con
 #include "macros.h"
 
 int
 main (void)
 {
+#if HAVE_IPV4
   (void) gl_sockets_startup (SOCKETS_1_1);
 
   /* Test behaviour for invalid file descriptors.  */
   {
     struct sockaddr_in addr;
@@ -53,8 +56,9 @@ main (void)
       ASSERT (connect (99, (const struct sockaddr *) &addr, sizeof (addr))
               == -1);
       ASSERT (errno == EBADF);
     }
   }
+#endif
 
   return 0;
 }
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/gnulib-tests/test-errno.c gettext-0.20.1/gettext-tools/gnulib-tests/test-errno.c
--- gettext-0.20.1.orig/gettext-tools/gnulib-tests/test-errno.c	2019-01-06 12:17:10 +0000
+++ gettext-0.20.1/gettext-tools/gnulib-tests/test-errno.c	2019-06-16 00:15:36 +0000
@@ -46,11 +46,13 @@ int e20 = ENOTDIR;
 int e21 = EISDIR;
 int e22 = EINVAL;
 int e23 = ENFILE;
 int e24 = EMFILE;
 int e25 = ENOTTY;
+#ifdef ETXTBSY
 int e26 = ETXTBSY;
+#endif
 int e27 = EFBIG;
 int e28 = ENOSPC;
 int e29 = ESPIPE;
 int e30 = EROFS;
 int e31 = EMLINK;
@@ -69,34 +71,72 @@ int e67 = ENOLINK;
 int e71 = EPROTO;
 int e72 = EMULTIHOP;
 int e74 = EBADMSG;
 int e75 = EOVERFLOW;
 int e84 = EILSEQ;
+#ifdef ENOTSOCK
 int e88 = ENOTSOCK;
+#endif
+#ifdef EDESTADDRREQ
 int e89 = EDESTADDRREQ;
+#endif
+#ifdef EMSGSIZE
 int e90 = EMSGSIZE;
+#endif
+#ifdef EPROTOTYPE
 int e91 = EPROTOTYPE;
+#endif
+#ifdef ENOPROTOOPT
 int e92 = ENOPROTOOPT;
+#endif
+#ifdef EPROTONOSUPPORT
 int e93 = EPROTONOSUPPORT;
+#endif
 int e95 = EOPNOTSUPP;
 int e95a = ENOTSUP;
 int e97 = EAFNOSUPPORT;
+#ifdef EADDRINUSE
 int e98 = EADDRINUSE;
+#endif
+#ifdef EADDRNOTAVAIL
 int e99 = EADDRNOTAVAIL;
+#endif
+#ifdef ENETDOWN
 int e100 = ENETDOWN;
+#endif
+#ifdef ENETUNREACH
 int e101 = ENETUNREACH;
+#endif
 int e102 = ENETRESET;
 int e103 = ECONNABORTED;
+#ifdef ECONNRESET
 int e104 = ECONNRESET;
+#endif
+#ifdef ENOBUFS
 int e105 = ENOBUFS;
+#endif
+#ifdef EISCONN
 int e106 = EISCONN;
+#endif
+#ifdef ENOTCONN
 int e107 = ENOTCONN;
+#endif
+#ifdef ETIMEDOUT
 int e110 = ETIMEDOUT;
+#endif
+#ifdef ECONNREFUSED
 int e111 = ECONNREFUSED;
+#endif
+#ifdef EHOSTUNREACH
 int e113 = EHOSTUNREACH;
+#endif
+#ifdef EALREADY
 int e114 = EALREADY;
+#endif
+#ifdef EINPROGRESS
 int e115 = EINPROGRESS;
+#endif
 int e116 = ESTALE;
 int e122 = EDQUOT;
 int e125 = ECANCELED;
 int e130 = EOWNERDEAD;
 int e131 = ENOTRECOVERABLE;
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/libgettextpo/getprogname.c gettext-0.20.1/gettext-tools/libgettextpo/getprogname.c
--- gettext-0.20.1.orig/gettext-tools/libgettextpo/getprogname.c	2019-03-20 21:01:00 +0000
+++ gettext-0.20.1/gettext-tools/libgettextpo/getprogname.c	2019-06-16 00:16:40 +0000
@@ -49,10 +49,14 @@
 # include <stdio.h>
 # include <fcntl.h>
 # 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 */
 char const *
 getprogname (void)
@@ -242,10 +246,12 @@ getprogname (void)
               return memcpy (namecopy, name, namelen);
             }
         }
     }
   return NULL;
+# elif __DJGPP__
+  return last_component (__crt0_argv ? __crt0_argv[0] : __dos_argv0);
 # else
 #  error "getprogname module not ported to this OS"
 # endif
 }
 
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/libgettextpo/stdint.in.h gettext-0.20.1/gettext-tools/libgettextpo/stdint.in.h
--- gettext-0.20.1.orig/gettext-tools/libgettextpo/stdint.in.h	2019-01-06 12:18:00 +0000
+++ gettext-0.20.1/gettext-tools/libgettextpo/stdint.in.h	2019-06-16 00:16:40 +0000
@@ -160,12 +160,17 @@ typedef unsigned short int gl_uint16_t;
 # define int16_t gl_int16_t
 # define uint16_t gl_uint16_t
 
 # undef int32_t
 # undef uint32_t
+#if __DJGPP__
+typedef long int gl_int32_t;
+typedef unsigned long int gl_uint32_t;
+#else  /* !__DJGPP__ */
 typedef int gl_int32_t;
 typedef unsigned int gl_uint32_t;
+#endif /* !__DJGPP__ */
 # define int32_t gl_int32_t
 # define uint32_t gl_uint32_t
 
 /* If the system defines INT64_MAX, assume int64_t works.  That way,
    if the underlying platform defines int64_t to be a 64-bit long long
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/misc/autopoint.in gettext-0.20.1/gettext-tools/misc/autopoint.in
--- gettext-0.20.1.orig/gettext-tools/misc/autopoint.in	2019-05-11 21:23:16 +0000
+++ gettext-0.20.1/gettext-tools/misc/autopoint.in	2019-06-16 00:16:40 +0000
@@ -39,11 +39,11 @@ datarootdir="@datarootdir@"
 func_tmpdir ()
 {
   # Use the environment variable TMPDIR, falling back to /tmp. This allows
   # users to specify a different temporary directory, for example, if their
   # /tmp is filled up or too small.
-  : ${TMPDIR=/tmp}
+  : ${TMPDIR=${TMP=${TEMP=.}}}
   {
     # Use the mktemp program if available. If not available, hide the error
     # message.
     tmp=`(umask 077 && mktemp -d "$TMPDIR/gtXXXXXX") 2>/dev/null` &&
     test -n "$tmp" && test -d "$tmp"
diff -aprNU5 gettext-0.20.1.orig/gettext-tools/misc/gettextize.in gettext-0.20.1/gettext-tools/misc/gettextize.in
--- gettext-0.20.1.orig/gettext-tools/misc/gettextize.in	2019-05-11 21:22:34 +0000
+++ gettext-0.20.1/gettext-tools/misc/gettextize.in	2019-06-16 00:16:40 +0000
@@ -39,11 +39,11 @@ datarootdir="@datarootdir@"
 func_tmpdir ()
 {
   # Use the environment variable TMPDIR, falling back to /tmp. This allows
   # users to specify a different temporary directory, for example, if their
   # /tmp is filled up or too small.
-  : ${TMPDIR=/tmp}
+  : ${TMPDIR=${TMP=${TEMP=.}}}
   {
     # Use the mktemp program if available. If not available, hide the error
     # message.
     tmp=`(umask 077 && mktemp -d "$TMPDIR/gtXXXXXX") 2>/dev/null` &&
     test -n "$tmp" && test -d "$tmp"
diff -aprNU5 gettext-0.20.1.orig/gnulib-local/lib/libxml/nanohttp.c gettext-0.20.1/gnulib-local/lib/libxml/nanohttp.c
--- gettext-0.20.1.orig/gnulib-local/lib/libxml/nanohttp.c	2017-12-02 08:58:10 +0000
+++ gettext-0.20.1/gnulib-local/lib/libxml/nanohttp.c	2019-06-20 01:08:50 +0000
@@ -90,13 +90,17 @@
  */
 #ifndef _WINSOCKAPI_
 #if !defined(__BEOS__) || defined(__HAIKU__)
 #define closesocket(s) close(s)
 #endif
+#ifndef SOCKET
 #define SOCKET int
+#endif
+#ifndef INVALID_SOCKET
 #define INVALID_SOCKET (-1)
 #endif
+#endif
 
 #ifdef __BEOS__
 #ifndef PF_INET
 #define PF_INET AF_INET
 #endif
diff -aprNU5 gettext-0.20.1.orig/gnulib-local/lib/libxml/xmlIO.c gettext-0.20.1/gnulib-local/lib/libxml/xmlIO.c
--- gettext-0.20.1.orig/gnulib-local/lib/libxml/xmlIO.c	2018-03-26 14:30:46 +0000
+++ gettext-0.20.1/gnulib-local/lib/libxml/xmlIO.c	2019-06-20 01:08:50 +0000
@@ -21,10 +21,15 @@
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
+#if defined (__DJGPP__)
+/*  _stat does not exist in DJGPP.  */
+#undef _stat
+#define _stat stat
+#endif
 #endif
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
 #ifdef HAVE_UNISTD_H
@@ -188,10 +193,17 @@ static const char *IOerr[] = {
     "adddress in use",		/* EADDRINUSE */
     "already in use",		/* EALREADY */
     "unknown address familly",	/* EAFNOSUPPORT */
 };
 
+#if defined (__DJGPP__)
+/*  I/O function that expect UTF-8 strings as arguments are not supported by DJGPP.  */
+# define _wfopen(filename, mode)  (NULL)
+# define _wopen(filename, omode)  (-1)
+# define _wstat(path, buffer)     (-1)
+#endif
+
 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
 /**
  * __xmlIOWin32UTF8ToWChar:
  * @u8String:  uft-8 string
  *
@@ -200,10 +212,11 @@ static const char *IOerr[] = {
 static wchar_t *
 __xmlIOWin32UTF8ToWChar(const char *u8String)
 {
     wchar_t *wString = NULL;
 
+#if !defined (__DJGPP__)
     if (u8String) {
         int wLen =
             MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, u8String,
                                 -1, NULL, 0);
         if (wLen) {
@@ -215,10 +228,11 @@ __xmlIOWin32UTF8ToWChar(const char *u8St
                     wString = NULL;
                 }
             }
         }
     }
+#endif  /* !__DJGPP__ */
 
     return wString;
 }
 #endif
 
diff -aprNU5 gettext-0.20.1.orig/libtextstyle/lib/getprogname.c gettext-0.20.1/libtextstyle/lib/getprogname.c
--- gettext-0.20.1.orig/libtextstyle/lib/getprogname.c	2019-04-01 22:07:42 +0000
+++ gettext-0.20.1/libtextstyle/lib/getprogname.c	2019-06-16 00:16:40 +0000
@@ -49,10 +49,14 @@
 # include <stdio.h>
 # include <fcntl.h>
 # 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 */
 char const *
 getprogname (void)
@@ -242,10 +246,12 @@ getprogname (void)
               return memcpy (namecopy, name, namelen);
             }
         }
     }
   return NULL;
+# elif __DJGPP__
+  return last_component (__crt0_argv ? __crt0_argv[0] : __dos_argv0);
 # else
 #  error "getprogname module not ported to this OS"
 # endif
 }
 
diff -aprNU5 gettext-0.20.1.orig/libtextstyle/lib/libxml/nanohttp.c gettext-0.20.1/libtextstyle/lib/libxml/nanohttp.c
--- gettext-0.20.1.orig/libtextstyle/lib/libxml/nanohttp.c	2019-04-28 11:38:28 +0000
+++ gettext-0.20.1/libtextstyle/lib/libxml/nanohttp.c	2019-06-20 01:08:50 +0000
@@ -90,13 +90,17 @@
  */
 #ifndef _WINSOCKAPI_
 #if !defined(__BEOS__) || defined(__HAIKU__)
 #define closesocket(s) close(s)
 #endif
+#ifndef SOCKET
 #define SOCKET int
+#endif
+#ifndef INVALID_SOCKET
 #define INVALID_SOCKET (-1)
 #endif
+#endif
 
 #ifdef __BEOS__
 #ifndef PF_INET
 #define PF_INET AF_INET
 #endif
diff -aprNU5 gettext-0.20.1.orig/libtextstyle/lib/libxml/xmlIO.c gettext-0.20.1/libtextstyle/lib/libxml/xmlIO.c
--- gettext-0.20.1.orig/libtextstyle/lib/libxml/xmlIO.c	2019-04-28 11:38:28 +0000
+++ gettext-0.20.1/libtextstyle/lib/libxml/xmlIO.c	2019-06-20 01:08:50 +0000
@@ -21,10 +21,15 @@
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
+#if defined (__DJGPP__)
+/*  _stat does not exist in DJGPP.  */
+#undef _stat
+#define _stat stat
+#endif
 #endif
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
 #ifdef HAVE_UNISTD_H
@@ -188,10 +193,17 @@ static const char *IOerr[] = {
     "adddress in use",		/* EADDRINUSE */
     "already in use",		/* EALREADY */
     "unknown address familly",	/* EAFNOSUPPORT */
 };
 
+#if defined (__DJGPP__)
+/*  I/O function that expect UTF-8 strings as arguments are not supported by DJGPP.  */
+# define _wfopen(filename, mode)  (NULL)
+# define _wopen(filename, omode)  (-1)
+# define _wstat(path, buffer)     (-1)
+#endif
+
 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
 /**
  * __xmlIOWin32UTF8ToWChar:
  * @u8String:  uft-8 string
  *
@@ -200,10 +212,11 @@ static const char *IOerr[] = {
 static wchar_t *
 __xmlIOWin32UTF8ToWChar(const char *u8String)
 {
     wchar_t *wString = NULL;
 
+#if !defined (__DJGPP__)
     if (u8String) {
         int wLen =
             MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, u8String,
                                 -1, NULL, 0);
         if (wLen) {
@@ -215,10 +228,11 @@ __xmlIOWin32UTF8ToWChar(const char *u8St
                     wString = NULL;
                 }
             }
         }
     }
+#endif  /* !__DJGPP__ */
 
     return wString;
 }
 #endif
 
diff -aprNU5 gettext-0.20.1.orig/libtextstyle/lib/stdint.in.h gettext-0.20.1/libtextstyle/lib/stdint.in.h
--- gettext-0.20.1.orig/libtextstyle/lib/stdint.in.h	2019-03-11 19:40:30 +0000
+++ gettext-0.20.1/libtextstyle/lib/stdint.in.h	2019-06-16 00:16:40 +0000
@@ -160,12 +160,17 @@ typedef unsigned short int gl_uint16_t;
 # define int16_t gl_int16_t
 # define uint16_t gl_uint16_t
 
 # undef int32_t
 # undef uint32_t
+#if __DJGPP__
+typedef long int gl_int32_t;
+typedef unsigned long int gl_uint32_t;
+#else  /* !__DJGPP__ */
 typedef int gl_int32_t;
 typedef unsigned int gl_uint32_t;
+#endif /* !__DJGPP__ */
 # define int32_t gl_int32_t
 # define uint32_t gl_uint32_t
 
 /* If the system defines INT64_MAX, assume int64_t works.  That way,
    if the underlying platform defines int64_t to be a 64-bit long long
diff -aprNU5 gettext-0.20.1.orig/libtextstyle/lib/term-style-control.c gettext-0.20.1/libtextstyle/lib/term-style-control.c
--- gettext-0.20.1.orig/libtextstyle/lib/term-style-control.c	2019-04-27 08:23:04 +0000
+++ gettext-0.20.1/libtextstyle/lib/term-style-control.c	2019-06-16 00:16:40 +0000
@@ -629,13 +629,15 @@ show_signal_marker (int sig)
     switch (sig)
       {
       /* The kernel's action when the user presses the INTR key.  */
       case SIGINT:
         full_write (STDERR_FILENO, "^C", 2); break;
+#ifdef SIGTSTP
       /* The kernel's action when the user presses the SUSP key.  */
       case SIGTSTP:
         full_write (STDERR_FILENO, "^Z", 2); break;
+#endif
       /* The kernel's action when the user presses the QUIT key.  */
       case SIGQUIT:
         full_write (STDERR_FILENO, "^\\", 2); break;
       default: break;
       }
