MSYS mode (continue)

Charles Wilson cygwin@cwilson.fastmail.fm
Mon Jul 29 14:22:00 GMT 2013


On 7/29/2013 8:49 AM, Corinna Vinschen wrote:
> The question is, are they really necessary?  I seriously doubt that you
> have to patch inetutils beyond what's required for Cygwin, unless you
> want the kitchen sink to work with DOS paths.

They *were* necessary for msys-1, given the following:

1) msys itself was very old, and had only cygwin-1.3.4 era capabilities
2) the msys targetting compiler is to this day ALSO very old: it's based 
on gcc-3.4.4 if you can believe it.

Now, it is certainly true that in the new "era" with msys-on-cygwin, 
point #1 above is no longer applicable. And, because there really won't 
be an msys target compiler, just the plain old cygwin one (with -DMSYS 
[1] and, depending on how the msys hook dll gets loaded, perhaps 
-lmsys), then msys apps no longer have to work around old-gcc breakage.

But there are still some patches that will be necessary, and I'm afraid 
only experience will tell us which ones.  My set of 151 patches to 56 
packages [2] is probably the "outer limit"; some packages might be 
workable with no special msys changes, others might only need a small 
subset of what was previously necessary.

Let's go back to our favorite example, msys-make:

make/01-make-3.81-2-cygwin.patch
--------------------------------
	from cygwin's 3.81-2 package, so this is not interesting
	when we're discussing *differences* between the cygwin and
	"msys" versions

make/02-make-3.81-dos-path.patch
--------------------------------
* configure.in (PATH_SEPARATOR_CHAR): Define to the value of
   $PATH_SEPARATOR.
* make.h (PATH_SEPARATOR_CHAR): Define only if still undefined.
   Normally, it is defined in config.h.
* config/dospaths.m4 <ac_cv_dos_paths>: Define to yes on Cygwin
   as well.
* job.c (construct_command_argv_internal) [HAVE_DOS_PATHS]:
   Define sh_chars_sh for Windows platforms that emulate Unix.

This *might* be in make-3.82.90, I'm not sure. But for msys we need to 
ensure that ac_cv_dos_paths is "yes", regardless of whether it is yes or 
no on cygwin.

make/03-make-3.81-case_preserve.patch
--------------------------------
case-insensitive but case-preserving rule matching. Pretty sure "real" 
cygwin doesn't want, and doesn't have, this one.  Over in mingw/msys 
land we went round and round with "csmake" (case sensitive), "cpmake" 
(this one), and "regular" make, and finally decided that cpmake had the 
fewest drawbacks when working with "native" gcc...

make/04-make-3.81-msys.patch
--------------------------------
build system changes. In configure.in, the original AC_SUBSTs didn't do 
the right thing and needed to use a more modern idiom. In Makefile.am, 
the test driver section relied on symlinks, which are obviously broken 
in "old" msys.


I think we're all pretty much on the same page, that "msys" needs a 
special version of make. Does bash need to be different? probably. 
Perl...maybe???  inetutils (clients only) -- I think some of these 
changes^Wcripplings are necessary, regardless of the "environment" 
improvements that modernizing msys and its associated gcc bring.  But 
it'll just have to be on a case-by-case basis.  I've uploaded my entire 
msys patch collection [2] in case anyone is really crazy^Winterested...


[1] This will still be needed because of the msys-*behavioral* patches 
that are still going to be necessary, in some cases...

[2] http://mingw.cwilson.fastmail.fm/msys-patches.tar.xz

--
Chuck

-------------- next part --------------
2006-08-18  Eli Zaretskii  <address@hidden>

        * configure.in (PATH_SEPARATOR_CHAR): Define to the value of
        $PATH_SEPARATOR.

        * make.h (PATH_SEPARATOR_CHAR): Define only if still undefined.
        Normally, it is defined in config.h.

        * config/dospaths.m4 <ac_cv_dos_paths>: Define to yes on Cygwin as
        well.

        * job.c (construct_command_argv_internal) [HAVE_DOS_PATHS]: Define
        sh_chars_sh for Windows platforms that emulate Unix.


--- old/make-3.81/configure.in	2006-04-01 12:36:40.000000000 +0300
+++ new/make-3.81/configure.in	2006-08-18 21:12:32.828125000 +0300
@@ -384,6 +384,8 @@
     ;;
 esac
 
+AC_DEFINE_UNQUOTED(PATH_SEPARATOR_CHAR,'$PATH_SEPARATOR',[Define to the character that separates directories in PATH.])
+
 # Include the Maintainer's Makefile section, if it's here.
 
 MAINT_MAKEFILE=/dev/null

--- old/make-3.81/make.h	2006-02-16 03:54:43.000000000 +0200
+++ new/make-3.81/make.h	2006-08-18 21:12:32.859375000 +0300
@@ -347,12 +347,14 @@
 #define S_(msg1,msg2,num)   ngettext (msg1,msg2,num)
 
 /* Handle other OSs.  */
-#if defined(HAVE_DOS_PATHS)
-# define PATH_SEPARATOR_CHAR ';'
-#elif defined(VMS)
-# define PATH_SEPARATOR_CHAR ','
-#else
-# define PATH_SEPARATOR_CHAR ':'
+#ifndef PATH_SEPARATOR_CHAR
+# if defined(HAVE_DOS_PATHS)
+#  define PATH_SEPARATOR_CHAR ';'
+# elif defined(VMS)
+#  define PATH_SEPARATOR_CHAR ','
+# else
+#  define PATH_SEPARATOR_CHAR ':'
+# endif
 #endif
 
 /* This is needed for getcwd() and chdir().  */

--- old/make-3.81/config/dospaths.m4	2006-03-10 06:20:45.000000000 +0200
+++ new/make-3.81/config/dospaths.m4	2006-08-18 21:12:32.859375000 +0300
@@ -22,7 +22,7 @@
     AC_CACHE_CHECK([whether system uses MSDOS-style paths], [ac_cv_dos_paths],
       [
         AC_COMPILE_IFELSE([
-#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __EMX__ && !defined __MSYS__
+#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __EMX__ && !defined __MSYS__ && !defined __CYGWIN__
 neither MSDOS nor Windows nor OS2
 #endif
 ],

--- old/make-3.81/job.c	2006-03-20 07:03:04.000000000 +0200
+++ new/make-3.81/job.c	2006-08-19 09:25:07.687500000 +0300
@@ -2307,6 +2307,12 @@ construct_command_argv_internal (char *l
                              "login", "logout", "read", "readonly", "set",
                              "shift", "switch", "test", "times", "trap",
                              "umask", "wait", "while", 0 };
+# ifdef HAVE_DOS_PATHS
+  /* This is required if the MSYS/Cygwin ports (which do not define
+     WINDOWS32) are compiled with HAVE_DOS_PATHS defined, which uses
+     sh_chars_sh[] directly (see below).  */
+  static char *sh_chars_sh = sh_chars;
+# endif         /* HAVE_DOS_PATHS */
 #endif
   register int i;
   register char *p;
-------------- next part --------------
diff -rup make-3.81/implicit.c make-3.81-new/implicit.c
--- old/make-3.81/implicit.c	Wed May 28 23:57:40 2008
+++ new/make-3.81/implicit.c	Wed May 28 23:30:55 2008
@@ -27,7 +27,8 @@ Foundation, Inc., 51 Franklin St, Fifth 
 
 static int
 pattern_search PARAMS ((struct file *file, int archive,
-                        unsigned int depth, unsigned int recursions));
+                        unsigned int depth, unsigned int recursions,
+                        int strict_case));
 

 /* For a FILE which has no commands specified, try to figure out some
    from the implicit pattern rules.
@@ -36,16 +37,19 @@ pattern_search PARAMS ((struct file *fil
    or returns 0 if no implicit rule was found.  */
 
 int
-try_implicit_rule (struct file *file, unsigned int depth)
+try_implicit_rule (struct file *file, unsigned int depth, int strict_case)
 {
-  DBF (DB_IMPLICIT, _("Looking for an implicit rule for `%s'.\n"));
+  if (strict_case)
+    DBF (DB_IMPLICIT, _("Looking for an implicit rule for `%s'.\n"));
+  else
+    DBF (DB_IMPLICIT, _("Looking for a case-insensitive implicit rule for `%s'.\n"));
 
   /* The order of these searches was previously reversed.  My logic now is
      that since the non-archive search uses more information in the target
      (the archive search omits the archive name), it is more specific and
      should come first.  */
 
-  if (pattern_search (file, 0, depth, 0))
+  if (pattern_search (file, 0, depth, 0, strict_case))
     return 1;
 
 #ifndef	NO_ARCHIVES
@@ -55,7 +59,7 @@ try_implicit_rule (struct file *file, un
     {
       DBF (DB_IMPLICIT,
            _("Looking for archive-member implicit rule for `%s'.\n"));
-      if (pattern_search (file, 1, depth, 0))
+      if (pattern_search (file, 1, depth, 0, strict_case))
 	return 1;
     }
 #endif
@@ -198,7 +202,8 @@ get_next_word (char *buffer, unsigned in
 
 static int
 pattern_search (struct file *file, int archive,
-                unsigned int depth, unsigned int recursions)
+                unsigned int depth, unsigned int recursions,
+                int strict_case)
 {
   /* Filename we are searching for a rule for.  */
   char *filename = archive ? strchr (file->name, '(') : file->name;
@@ -698,13 +703,13 @@ pattern_search (struct file *file, int a
               /* @@ dep->changed check is disabled. */
               if (((f = lookup_file (name)) != 0 && f->is_target)
                   /*|| ((!dep->changed || check_lastslash) && */
-                  || file_exists_p (name))
+                  || (strict_case ? file_exists_p (name) : (access (name, F_OK) == 0)))
                 continue;
 
               /* This code, given FILENAME = "lib/foo.o", dependency name
                  "lib/foo.c", and VPATH=src, searches for "src/lib/foo.c".  */
               vname = name;
-              if (vpath_search (&vname, (FILE_TIMESTAMP *) 0))
+              if (vpath_search (&vname, (FILE_TIMESTAMP *) 0, strict_case))
                 {
                   DBS (DB_IMPLICIT,
                        (_("Found prerequisite `%s' as VPATH `%s'\n"),
@@ -735,7 +740,8 @@ pattern_search (struct file *file, int a
                   if (pattern_search (intermediate_file,
                                       0,
                                       depth + 1,
-                                      recursions + 1))
+                                      recursions + 1,
+                                      strict_case))
                     {
                       d->intermediate_file = intermediate_file;
                       d->intermediate_pattern = intermediate_file->name;
@@ -751,7 +757,8 @@ pattern_search (struct file *file, int a
                      so we won't go through the search again later.  */
                   if (intermediate_file->variables)
                     free_variable_set (intermediate_file->variables);
-                  file_impossible (name);
+                  if (strict_case==0)
+                    file_impossible (name);
                 }
 
               /* A dependency of this rule does not exist. Therefore,
diff -rup make-3.81/make.h make-3.81-new/make.h
--- old/make-3.81/make.h	Wed May 28 23:57:40 2008
+++ new/make-3.81/make.h	Wed May 28 23:30:55 2008
@@ -459,7 +459,7 @@ extern void install_default_implicit_rul
 
 extern void build_vpath_lists PARAMS ((void));
 extern void construct_vpath_list PARAMS ((char *pattern, char *dirpath));
-extern int vpath_search PARAMS ((char **file, FILE_TIMESTAMP *mtime_ptr));
+extern int vpath_search PARAMS ((char **file, FILE_TIMESTAMP *mtime_ptr, int strict_case));
 extern int gpath_search PARAMS ((char *file, unsigned int len));
 
 extern void construct_include_path PARAMS ((char **arg_dirs));
diff -rup make-3.81/remake.c make-3.81-new/remake.c
--- old/make-3.81/remake.c	Wed May 28 23:57:40 2008
+++ new/make-3.81/remake.c	Wed May 28 23:30:55 2008
@@ -39,7 +39,7 @@ Foundation, Inc., 51 Franklin St, Fifth 
 #include <io.h>
 #endif
 
-extern int try_implicit_rule PARAMS ((struct file *file, unsigned int depth));
+extern int try_implicit_rule PARAMS ((struct file *file, unsigned int depth, int strict_case));
 
 
 /* The test for circular dependencies is based on the 'updating' bit in
@@ -450,8 +450,10 @@ update_file_1 (struct file *file, unsign
 
   if (!file->phony && file->cmds == 0 && !file->tried_implicit)
     {
-      if (try_implicit_rule (file, depth))
+      if (try_implicit_rule (file, depth, 1))
 	DBF (DB_IMPLICIT, _("Found an implicit rule for `%s'.\n"));
+      else if (try_implicit_rule (file, depth, 0))
+	DBF (DB_IMPLICIT, _("Found an case-insensitive implicit rule for `%s'.\n"));
       else
 	DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));
       file->tried_implicit = 1;
@@ -958,8 +960,10 @@ check_dep (struct file *file, unsigned i
 
       if (!file->phony && file->cmds == 0 && !file->tried_implicit)
 	{
-	  if (try_implicit_rule (file, depth))
+	  if (try_implicit_rule (file, depth, 1))
 	    DBF (DB_IMPLICIT, _("Found an implicit rule for `%s'.\n"));
+	  else if (try_implicit_rule (file, depth, 0))
+	    DBF (DB_IMPLICIT, _("Found an case-insensitive implicit rule for `%s'.\n"));
 	  else
 	    DBF (DB_IMPLICIT, _("No implicit rule found for `%s'.\n"));
 	  file->tried_implicit = 1;
@@ -1230,7 +1234,7 @@ f_mtime (struct file *file, int search)
 	{
 	  /* If name_mtime failed, search VPATH.  */
 	  char *name = file->name;
-	  if (vpath_search (&name, &mtime)
+	  if (vpath_search (&name, &mtime, 1) || vpath_search (&name, &mtime, 0)
 	      /* Last resort, is it a library (-lxxx)?  */
 	      || (name[0] == '-' && name[1] == 'l'
 		  && library_search (&name, &mtime)))
@@ -1533,7 +1537,7 @@ library_search (char **lib, FILE_TIMESTA
       /* Now try VPATH search on that.  */
 
       file = libbuf;
-      if (vpath_search (&file, mtime_ptr))
+      if (vpath_search (&file, mtime_ptr, 1) || vpath_search (&file, mtime_ptr, 1))
 	{
 	  *lib = file;
 	  return 1;
diff -rup make-3.81/vpath.c make-3.81-new/vpath.c
--- old/make-3.81/vpath.c	Wed May 28 23:57:40 2008
+++ new/make-3.81/vpath.c	Wed May 28 23:51:23 2008
@@ -48,7 +48,7 @@ static struct vpath *general_vpath;
 
 static struct vpath *gpaths;
 

-static int selective_vpath_search PARAMS ((struct vpath *path, char **file, FILE_TIMESTAMP *mtime_ptr));
+static int selective_vpath_search PARAMS ((struct vpath *path, char **file, FILE_TIMESTAMP *mtime_ptr, int strict_case));
 
 /* Reverse the chain of selective VPATH lists so they
    will be searched in the order given in the makefiles
@@ -334,7 +334,7 @@ gpath_search (char *file, unsigned int l
    Otherwise we return 0.  */
 
 int
-vpath_search (char **file, FILE_TIMESTAMP *mtime_ptr)
+vpath_search (char **file, FILE_TIMESTAMP *mtime_ptr, int strict_case)
 {
   register struct vpath *v;
 
@@ -351,11 +351,11 @@ vpath_search (char **file, FILE_TIMESTAM
 
   for (v = vpaths; v != 0; v = v->next)
     if (pattern_matches (v->pattern, v->percent, *file))
-      if (selective_vpath_search (v, file, mtime_ptr))
+      if (selective_vpath_search (v, file, mtime_ptr, strict_case))
 	return 1;
 
   if (general_vpath != 0
-      && selective_vpath_search (general_vpath, file, mtime_ptr))
+      && selective_vpath_search (general_vpath, file, mtime_ptr, strict_case))
     return 1;
 
   return 0;
@@ -370,7 +370,8 @@ vpath_search (char **file, FILE_TIMESTAM
 
 static int
 selective_vpath_search (struct vpath *path, char **file,
-                        FILE_TIMESTAMP *mtime_ptr)
+                        FILE_TIMESTAMP *mtime_ptr,
+                        int strict_case)
 {
   int not_target;
   char *name, *n;
@@ -500,10 +501,19 @@ selective_vpath_search (struct vpath *pa
 	     Now NAME is the name of the directory to look in.  */
 	  *n = '\0';
 
-	  /* We know the directory is in the hash table now because either
-	     construct_vpath_list or the code just above put it there.
-	     Does the file we seek exist in it?  */
-	  exists_in_cache = exists = dir_file_exists_p (name, filename);
+	  if (strict_case)
+	    {
+	      /* We know the directory is in the hash table now because either
+	         construct_vpath_list or the code just above put it there.
+	         Does the file we seek exist in it?  */
+	      exists_in_cache = exists = dir_file_exists_p (name, filename);
+	    }
+	  else
+	    {
+	      /* If using a case insensitive search, avoid the case sensitive
+	         lookup function above and force a real filesystem check. */
+	      exists_in_cache = exists = 1;
+	    }
 #endif
 	}
 
-------------- next part --------------
diff -urN old/make-3.81/Makefile.am new/make-3.81/Makefile.am
--- old/make-3.81/Makefile.am	2006-04-01 02:36:40.000000000 -0400
+++ new/make-3.81/Makefile.am	2009-11-07 19:23:03.012300000 -0500
@@ -172,10 +172,17 @@
 	    case `cd $(srcdir); pwd` in `pwd`) : ;; \
 	      *) test -d tests || mkdir tests; \
 		 rm -f srctests; \
-		 if ln -s "$(srcdir)/tests" srctests; then \
+		 if /bin/false && ln -s "$(srcdir)/tests" srctests; then \
 		   for f in run_make_tests run_make_tests.pl test_driver.pl scripts; do \
 		     rm -f tests/$$f; ln -s ../srctests/$$f tests; \
-		   done; fi ;; \
+		   done; \
+	         else \
+	           mkdir srctests ;\
+	           lndir $(srcdir)/tests/ srctests ;\
+	           for f in run_make_tests run_make_tests.pl test_driver.pl scripts; do \
+	             rm -f tests/$$f; (cd tests && ln -s ../srctests/$$f .); \
+	           done; \
+	         fi ;; \
 	    esac; \
 	    echo "cd tests && $(PERL) ./run_make_tests.pl -make ../make$(EXEEXT) $(MAKETESTFLAGS)"; \
 	    cd tests && $(PERL) ./run_make_tests.pl -make ../make$(EXEEXT) $(MAKETESTFLAGS); \
diff -urN old/make-3.81/configure.in new/make-3.81/configure.in
--- old/make-3.81/configure.in	2009-11-07 19:22:43.044300000 -0500
+++ new/make-3.81/configure.in	2009-11-07 19:37:43.011500000 -0500
@@ -40,9 +40,8 @@
 
 # Specialized system macros
 AC_CANONICAL_HOST
-AC_AIX
+AC_USE_SYSTEM_EXTENSIONS
 AC_ISC_POSIX
-AC_MINIX
 
 # Needed for ansi2knr
 AM_C_PROTOTYPES
@@ -360,9 +359,14 @@
 #endif
  ], [AC_MSG_RESULT(yes)
 make_cv_sys_gnu_glob=yes], [AC_MSG_RESULT([no; using local copy])
-AC_SUBST(GLOBINC) GLOBINC='-I$(srcdir)/glob'
-AC_SUBST(GLOBLIB) GLOBLIB=glob/libglob.a
 make_cv_sys_gnu_glob=no])])
+if test "$make_cv_sys_gnu_glob" = no; then
+  GLOBINC='-I$(srcdir)/glob'
+  GLOBLIB=glob/libglob.a
+fi
+AC_SUBST(GLOBINC)
+AC_SUBST(GLOBLIB)
+
 # Tell automake about this, so it can build the right .c files.
 AM_CONDITIONAL(USE_LOCAL_GLOB, test "$make_cv_sys_gnu_glob" = no)
 


More information about the Cygwin-developers mailing list