bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

OS/2 patches (2)


From: Andreas Buening
Subject: OS/2 patches (2)
Date: Sun, 23 Jun 2002 01:13:37 +0200

Hello!

It was a little bit more difficult to apply the patches
to the current CVS than expected.

Changes to dir.c should be obvious:

----------------------------------
--- old/make-CVS/dir.c  Fri Jun  1 03:56:50 2001
+++ gnu/make-3.79.2a1/dir.c     Sat Jun 22 16:48:04 2002
@@ -500,6 +500,10 @@
   filename = downcase (filename);
 #endif
 
+#ifdef __EMX_
+  _fnlwr(filename); /* lower case for FAT drives */
+#endif
+
 #ifdef VMS
   filename = vmsify (filename,0);
 #endif
@@ -665,7 +669,7 @@
     return dir_file_exists_p ("[]", name);
 #else /* !VMS */
   dirend = strrchr (name, '/');
-#if defined (WINDOWS32) || defined (__MSDOS__)
+#if defined (WINDOWS32) || defined (__MSDOS__) || defined (__EMX__)
   /* Forward and backslashes might be mixed.  We need the rightmost one.  */
   {
     char *bslash = strrchr(name, '\\');
@@ -675,7 +679,7 @@
     if (!dirend && name[0] && name[1] == ':')
       dirend = name + 1;
   }
-#endif /* WINDOWS32 || __MSDOS__ */
+#endif /* WINDOWS32 || __MSDOS__ || __EMX__*/
   if (dirend == 0)
 #ifndef _AMIGA
     return dir_file_exists_p (".", name);
@@ -689,7 +693,7 @@
     dirname = "/";
   else
     {
-#if defined (WINDOWS32) || defined (__MSDOS__)
+#if defined (WINDOWS32) || defined (__MSDOS__) || defined (__EMX__)
   /* d:/ and d: are *very* different...  */
       if (dirend < name + 3 && name[1] == ':' &&
          (*dirend == '/' || *dirend == '\\' || *dirend == ':'))
@@ -725,7 +729,7 @@
     dir = find_directory ("[]");
 #else
   dirend = strrchr (p, '/');
-# if defined (WINDOWS32) || defined (__MSDOS__)
+# if defined (WINDOWS32) || defined (__MSDOS__) || defined (__EMX__)
   /* Forward and backslashes might be mixed.  We need the rightmost one.  */
   {
     char *bslash = strrchr(p, '\\');
@@ -735,7 +739,7 @@
     if (!dirend && p[0] && p[1] == ':')
       dirend = p + 1;
   }
-# endif /* WINDOWS32 or __MSDOS__ */
+# endif /* WINDOWS32 or __MSDOS__ or __EMX__ */
   if (dirend == 0)
 # ifdef _AMIGA
     dir = find_directory ("");
@@ -751,7 +755,7 @@
        dirname = "/";
       else
        {
-#if defined (WINDOWS32) || defined (__MSDOS__)
+#if defined (WINDOWS32) || defined (__MSDOS__) || defined (__EMX__)
          /* d:/ and d: are *very* different...  */
          if (dirend < p + 3 && p[1] == ':' &&
              (*dirend == '/' || *dirend == '\\' || *dirend == ':'))
@@ -827,7 +831,7 @@
     dir = find_directory ("[]")->contents;
 #else
   dirend = strrchr (filename, '/');
-#if defined (WINDOWS32) || defined (__MSDOS__)
+#if defined (WINDOWS32) || defined (__MSDOS__) || defined (__EMX__)
   /* Forward and backslashes might be mixed.  We need the rightmost one.  */
   {
     char *bslash = strrchr(filename, '\\');
@@ -837,7 +841,7 @@
     if (!dirend && filename[0] && filename[1] == ':')
       dirend = filename + 1;
   }
-#endif /* WINDOWS32 || __MSDOS__ */
+#endif /* WINDOWS32 || __MSDOS__ || __EMX__ */
   if (dirend == 0)
 #ifdef _AMIGA
     dir = find_directory ("")->contents;
@@ -853,7 +857,7 @@
        dirname = "/";
       else
        {
-#if defined (WINDOWS32) || defined (__MSDOS__)
+#if defined (WINDOWS32) || defined (__MSDOS__) || defined (__EMX__)
          /* d:/ and d: are *very* different...  */
          if (dirend < filename + 3 && filename[1] == ':' &&
              (*dirend == '/' || *dirend == '\\' || *dirend == ':'))
@@ -876,6 +880,9 @@
 #endif
 #ifdef HAVE_CASE_INSENSITIVE_FS
   p = filename = downcase (p);
+#endif
+#ifdef __EMX_
+  _fnlwr(filename); /* lower case for FAT drives */
 #endif
 #ifdef VMS
   p = filename = vmsify (p, 1);
----------------------------------


If --disable-nls is used, _("...") delivers a const char*

----------------------------------
--- old/make-CVS/signame.c      Sun Apr 21 23:57:24 2002
+++ gnu/make-3.79.2a1/signame.c Sat Jun 22 19:02:48 2002
@@ -86,7 +86,7 @@
 signame_init ()
 {
   int i;
-  char *u = _("unknown signal");
+  char *u = (char*) _("unknown signal");
 
   undoc = xstrdup(u);
----------------------------------
 

File dates seem to have a time granularity of 2 sec, but
at least they are not in the future. I've used the code
from the last official make release:

----------------------------------
--- old/make-CVS/remake.c       Sat Apr 20 19:25:54 2002
+++ gnu/make-3.79.2a1/remake.c  Sat Jun 22 17:04:34 2002
@@ -1163,7 +1163,6 @@
        static FILE_TIMESTAMP adjusted_now;
 
        FILE_TIMESTAMP adjusted_mtime = mtime;
-
 #if defined(WINDOWS32) || defined(__MSDOS__)
        /* Experimentation has shown that FAT filesystems can set file times
           up to 3 seconds into the future!  Play it safe.  */
@@ -1173,7 +1172,17 @@
        FILE_TIMESTAMP adjustment = FAT_ADJ_OFFSET << FILE_TIMESTAMP_LO_BITS;
        if (ORDINARY_MTIME_MIN + adjustment <= adjusted_mtime)
          adjusted_mtime -= adjustment;
-#endif
+#else
+ #ifdef __EMX__
+       /* FAT filesystems round time to the nearest even second!
+          Allow for any file (NTFS or FAT) to perhaps suffer from this
+          brain damage.  */
+       FILE_TIMESTAMP adjustment = (((FILE_TIMESTAMP_S (adjusted_mtime) & 1) 
== 0
+                      && FILE_TIMESTAMP_NS (adjusted_mtime) == 0)
+                     ? (FILE_TIMESTAMP) 1 << FILE_TIMESTAMP_LO_BITS
+                     : 0);
+ #endif
+#endif /* WINDOWS32 || __MSDOS__ */
 
        /* If the file's time appears to be in the future, update our
           concept of the present and try once more.  */
----------------------------------


I've implemented support for /bin/sh as well as for cmd.exe
(standard shell of OS/2). Therefore default_shell is a char*.
$SHELL is defined by the following order: MAKESHELL,
SHELL (but not from environment), COMSPEC, OS2_SHELL, /bin/sh. 
I've also implemented a NO_CMD_DEFAULT macro to turn off
usage of cmd.exe. This is necessary for the make testsuite
because /bin/sh is required for the tests and the testsuite
ignores the environment.


----------------------------------
--- old/make-CVS/variable.c     Fri May 10 03:15:08 2002
+++ gnu/make-3.79.2a1/variable.c        Sat Jun 22 20:28:20 2002
@@ -455,7 +455,7 @@
 void
 define_automatic_variables ()
 {
-#ifdef WINDOWS32
+#if defined (WINDOWS32) || defined (__EMX__)
   extern char* default_shell;
 #else
   extern char default_shell[];
@@ -496,7 +496,58 @@
          (void) define_variable (shell_str, shlen, comp->value, o_env, 0);
       }
   }
-#endif
+
+#else /* NOT __MSDOS__ */
+
+# ifdef __EMX__
+  {
+    static char shell_str[] = "SHELL";
+    const int shlen = sizeof (shell_str) - 1;
+    struct variable *shell = lookup_variable (shell_str, shlen);
+    struct variable *replace = lookup_variable ("MAKESHELL", 9);
+
+    /* if $MAKESHELL is defined in the environment assume o_env_override */
+    if (replace && *replace->value && replace->origin == o_env)
+      replace->origin = o_env_override;
+
+    /* if $MAKESHELL is not defined use $SHELL but only if the variable
+       did not come from the environment */
+    if (!replace || !*replace->value)
+      if (shell && *shell->value && (shell->origin == o_env 
+         || shell->origin == o_env_override))
+       {
+         /* overwrite whatever we got from the environment */
+         free(shell->value);
+         shell->value = xstrdup (default_shell);
+         shell->origin = o_default;
+       }
+
+    /* Some people do not like cmd to be used as the default
+       if $SHELL is not defined in the Makefile.
+       With -DNO_CMD_DEFAULT you can turn off this behaviour */
+#  ifndef NO_CMD_DEFAULT
+    /* otherwise use $COMSPEC */
+    if (!replace || !*replace->value)
+      replace = lookup_variable ("COMSPEC", 7);
+
+    /* otherwise use $OS2_SHELL */
+    if (!replace || !*replace->value)
+      replace = lookup_variable ("OS2_SHELL", 9);
+#  else
+#   warning NO_CMD_DEFAULT: GNU make will not use CMD.EXE as default shell
+#  endif
+
+    if (replace && *replace->value)
+      /* overwrite $SHELL */
+      (void) define_variable (shell_str, shlen, replace->value,
+                             replace->origin, 0);
+    else
+      /* provide a definition if there is none */
+      (void) define_variable (shell_str, shlen, default_shell,
+                             o_default, 0);
+  }    
+# endif /* __EMX__ */
+#endif /* NOT __MSDOS__ */
 
   /* This won't override any definition, but it
      will provide one if there isn't one there.  */
@@ -505,8 +556,10 @@
 
   /* On MSDOS we do use SHELL from environment, since
      it isn't a standard environment variable on MSDOS,
-     so whoever sets it, does that on purpose.  */
-#ifndef __MSDOS__
+     so whoever sets it, does that on purpose. 
+     On OS/2 we do not use SHELL from environment but
+     we have already handled that problem above. */
+#if !defined(__MSDOS__) && !defined(__EMX__)
   /* Don't let SHELL come from the environment.  */
   if (*v->value == '\0' || v->origin == o_env || v->origin == o_env_override)
     {
----------------------------------


Additionally to NO_CMD_DEFAULT I also implemented a macro
NO_CHDIR2 so that chdir() is used instead of _chdir2()
(chdir() does not support drive letters). This is also necessary
to get the testsuite running because of the "Entering directory ..."
message of make. I also added a initialize_main() macro that has
to be called at the begin of main(). 

----------------------------------
--- old/make-CVS/make.h Fri May 10 03:15:08 2002
+++ gnu/make-3.79.2a1/make.h    Sat Jun 22 19:06:14 2002
@@ -357,7 +357,7 @@
 
 /* Handle other OSs.  */
 
-#if defined(__MSDOS__) || defined(WINDOWS32)
+#if defined(__MSDOS__) || defined(WINDOWS32) || defined(__EMX__)
 # define PATH_SEPARATOR_CHAR ';'
 #else
 # if defined(VMS)
@@ -541,3 +541,40 @@
 #ifdef HAVE_DMALLOC_H
 #include <dmalloc.h>
 #endif
+
+#ifndef initialize_main
+# ifdef __EMX__
+#  define initialize_main(pargc, pargv) \
+{ _wildcard(pargc, pargv); _response(pargc, pargv); }
+# else
+#  define initialize_main(pargc, pargv)
+# endif
+#endif
+
+
+#ifdef __EMX__
+# if !HAVE_STRCASECMP
+#  define strcasecmp stricmp
+# endif
+
+# if !defined chdir
+#  define chdir _chdir2
+# endif
+# if !defined getcwd
+#  define getcwd _getcwd2
+# endif
+
+/* NO_CHDIR2 causes make not to use _chdir2() and _getcwd2() instead of
+   chdir() and getcwd(). This avoids some error messages for the
+   make testsuite but restricts the drive letter support. */
+# ifdef NO_CHDIR2
+#  warning NO_CHDIR2: usage of drive letters restricted
+#  undef chdir
+#  undef getcwd
+# endif
+#endif
+
+#ifndef initialize_main
+# define initialize_main(pargc, pargv)
+#endif
+
----------------------------------


bye,
Andreas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]