Richard Henderson wrote:

>> +# The avr-mmcu.texi we want to compare against / check into svn should
>> +# have unix-style line endings.  To make this work on MinGW, remove \r.
>> +# \r is not portable to Solaris tr, therefore we have a special case
>> +# for ASCII.  We use \r for other encodings like EBCDIC.
>>   s-avr-mmcu-texi: gen-avr-mmcu-texi$(build_exeext)
>> -    $(RUN_GEN) ./$<  | sed -e 's:\r::g'>  avr-mmcu.texi
>> +    $(RUN_GEN) ./$<  >  tmp-avr-mmcu.texi
>> +    case `echo X|tr X '\101'` in                     \
>> +      A) tr -d '\015'<  tmp-avr-mmcu.texi>  tmp2-avr-mmcu.texi ;;     \
>> +      *) tr -d '\r'<  tmp-avr-mmcu.texi>  tmp2-avr-mmcu.texi ;;     \
>> +    esac
> 
> Why not do this inside gen-avr-mmcu-texi.c instead?
> 
> Instead of writing to stdout, open the file to write, and open
> it in binary mode.  Seems much easier than fighting with conversion
> after the fact.

Here is an updated patch that prints to binary file.

Moreover, the rewritten gen-tool now sorts the MCUs alphabetically
and thus the texi output differs and must be regenerated.

However, this just solves 1/2 of the problem:
SVN identifies texi as text file and if checked out under, e.g.
Windows, SVN will adjust the line endings for Windows again.

If it's appropriate I would also set svn:mime-type to something
like application/foo but that seems bit odd.

Johann

        * config/avr/gen-avr-mmcu-texi.c: Rewrite:
        - Output to binary file instead of as to stdout.
        - Take output file as command line parameter.
        - Sort MCUs.
        * config/avr/t-avr: Correct avr-mmcu.texi dependencies.
        (gen-avr-mmcu-texi): Use libiberty.
        (s-avr-mmcu-texi): Use new gen-avr-mmcu-texi interface.
        * doc/avr-mmcu.texi: Regenerate.
Index: config/avr/gen-avr-mmcu-texi.c
===================================================================
--- config/avr/gen-avr-mmcu-texi.c	(revision 188005)
+++ config/avr/gen-avr-mmcu-texi.c	(working copy)
@@ -20,25 +20,62 @@
 
 #include "avr-devices.c"
 
-int main (void)
+static const char*
+mcu_name[sizeof avr_mcu_types / sizeof avr_mcu_types[0]];
+
+static int
+comparator (const void *va, const void *vb)
+{
+  const char* const *a = (const char* const*) va;
+  const char* const *b = (const char* const*) vb;
+
+  return strcmp (*a, *b);
+} 
+
+static void
+print_mcus (FILE *fout, size_t n_mcus)
+{
+  size_t i;
+    
+  if (!n_mcus)
+    return;
+    
+  qsort (mcu_name, n_mcus, sizeof (char*), comparator);
+
+  fprintf (fout, "@*@var{mcu}@tie{}=");
+
+  for (i = 0; i < n_mcus; i++)
+    fprintf (fout, " @code{%s}%s", mcu_name[i], i == n_mcus-1 ? ".\n\n" : ",");
+}
+
+int main (int argc, char *argv[])
 {
   enum avr_arch arch = 0;
-  unsigned i, first = 1;
+  FILE *fout;
+  size_t i, n_mcus = 0;
   const struct mcu_type_s *mcu;
 
-  printf ("@c Copyright (C) 2012 Free Software Foundation, Inc.\n");
-  printf ("@c This is part of the GCC manual.\n");
-  printf ("@c For copying conditions, see the file "
-          "gcc/doc/include/fdl.texi.\n\n");
-
-  printf ("@c This file is generated automatically using\n");
-  printf ("@c gcc/config/avr/gen-avr-mmcu-texi.c from:\n");
-  printf ("@c    gcc/config/avr/avr-devices.c\n");
-  printf ("@c    gcc/config/avr/avr-mcus.def\n\n");
+  if (argc != 2
+      /* Write the texi output as binary so that line endings are the same
+         so matter what host we are on.  This is used in cmp -s in t-avr.  */
+      || !(fout = fopen (argv[1], "wb")))
+    {
+      fprintf (stderr, "\n%s: wrong usage\n", argv[0]);
+      return EXIT_FAILURE;
+    }
 
-  printf ("@c Please do not edit manually.\n\n");
+  fprintf (fout,
+           "@c Copyright (C) 2012 Free Software Foundation, Inc.\n"
+           "@c This is part of the GCC manual.\n"
+           "@c For copying conditions, see the file "
+           "gcc/doc/include/fdl.texi.\n\n"
+           "@c This file is generated automatically using\n"
+           "@c gcc/config/avr/gen-avr-mmcu-texi.c from:\n"
+           "@c    gcc/config/avr/avr-devices.c\n"
+           "@c    gcc/config/avr/avr-mcus.def\n\n"
+           "@c Please do not edit manually.\n\n");
 
-  printf ("@table @code\n\n");
+  fprintf (fout, "@table @code\n\n");
 
   for (mcu = avr_mcu_types; mcu->name; mcu++)
     {
@@ -46,28 +83,25 @@ int main (void)
         {
           arch = mcu->arch;
 
+          /* Start a new architecture:  Flush the MCUs collected so far.  */
+
+          print_mcus (fout, n_mcus);
+          n_mcus = 0;
+
           for (i = 0; i < sizeof (avr_texinfo) / sizeof (*avr_texinfo); i++)
-            {
-              if (arch == avr_texinfo[i].arch)
-                {
-                  if (mcu != avr_mcu_types)
-                    printf (".\n\n");
-                  printf ("@item %s\n%s\n", mcu->name, avr_texinfo[i].texinfo);
-                  printf ("@*@var{mcu}@tie{}=");
-                  first = 1;
-                  break;
-                }
-            }
+            if (arch == avr_texinfo[i].arch)
+              fprintf (fout, "@item %s\n%s\n",
+                       mcu->name, avr_texinfo[i].texinfo);
         }
       else if (arch == (enum avr_arch) mcu->arch)
         {
-          printf ("%s @code{%s}", first ? "" : ",", mcu->name);
-          first = 0;
+          mcu_name[n_mcus++] = mcu->name;
         }
     }
 
-  printf (".\n\n");
-  printf ("@end table\n");
+  print_mcus (fout, n_mcus);
+  fprintf (fout, "@end table\n");
+  fclose (fout);
 
   return EXIT_SUCCESS;
 }
Index: config/avr/t-avr
===================================================================
--- config/avr/t-avr	(revision 188005)
+++ config/avr/t-avr	(working copy)
@@ -44,13 +44,23 @@ $(srcdir)/config/avr/avr-tables.opt: $(s
 	$(SHELL) $< $(AVR_MCUS) > $@
 
 gen-avr-mmcu-texi$(build_exeext): $(srcdir)/config/avr/gen-avr-mmcu-texi.c \
-  $(TM_H) $(AVR_MCUS) $(srcdir)/config/avr/avr-devices.c
-	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< -o $@
+  $(TM_H) $(AVR_MCUS) $(srcdir)/config/avr/avr-devices.c $(LIBIBERTY)
+	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< -o $@ $(LIBIBERTY)
 
-avr-devices.o: s-avr-mmcu-texi
+# Make sure that the -mmcu= documentation is in sync with the compiler.
+$(srcdir)/doc/avr-mmcu.texi: s-avr-mmcu-texi; @true
 
+# invoke.texi @includes avr-mmcu.texi.  Put this dependency here instead
+# of in the global Makefile so that developers of other backends are not
+# bothered with AVR stuff. 
+$(srcdir)/doc/invoke.texi: $(srcdir)/doc/avr-mmcu.texi
+
+# The avr-mmcu.texi we want to compare against / check into svn should
+# have unix-style line endings.  This is accomplished by gen-avr-mmcu-texi
+# that writes tmp-avr-mmcu.texi as binary file.
 s-avr-mmcu-texi: gen-avr-mmcu-texi$(build_exeext)
-	$(RUN_GEN) ./$< | sed -e 's:\r::g' > avr-mmcu.texi
+	$(RUN_GEN) ./$< tmp-avr-mmcu.texi
+	$(SHELL) $(srcdir)/../move-if-change tmp-avr-mmcu.texi avr-mmcu.texi
 	@if cmp -s $(srcdir)/doc/avr-mmcu.texi avr-mmcu.texi; then \
 	  $(STAMP) $@;		\
 	else			\
Index: doc/avr-mmcu.texi
===================================================================
--- doc/avr-mmcu.texi	(revision 187704)
+++ doc/avr-mmcu.texi	(working copy)
@@ -13,11 +13,11 @@
 
 @item avr2
 ``Classic'' devices with up to 8@tie{}KiB of program memory.
-@*@var{mcu}@tie{}= @code{at90s2313}, @code{at90s2323}, @code{at90s2333}, @code{at90s2343}, @code{attiny22}, @code{attiny26}, @code{at90s4414}, @code{at90s4433}, @code{at90s4434}, @code{at90s8515}, @code{at90c8534}, @code{at90s8535}.
+@*@var{mcu}@tie{}= @code{at90c8534}, @code{at90s2313}, @code{at90s2323}, @code{at90s2333}, @code{at90s2343}, @code{at90s4414}, @code{at90s4433}, @code{at90s4434}, @code{at90s8515}, @code{at90s8535}, @code{attiny22}, @code{attiny26}.
 
 @item avr25
 ``Classic'' devices with up to 8@tie{}KiB of program memory and with the @code{MOVW} instruction.
-@*@var{mcu}@tie{}= @code{ata6289}, @code{attiny13}, @code{attiny13a}, @code{attiny2313}, @code{attiny2313a}, @code{attiny24}, @code{attiny24a}, @code{attiny4313}, @code{attiny44}, @code{attiny44a}, @code{attiny84}, @code{attiny84a}, @code{attiny25}, @code{attiny45}, @code{attiny85}, @code{attiny261}, @code{attiny261a}, @code{attiny461}, @code{attiny461a}, @code{attiny861}, @code{attiny861a}, @code{attiny43u}, @code{attiny87}, @code{attiny48}, @code{attiny88}, @code{at86rf401}.
+@*@var{mcu}@tie{}= @code{at86rf401}, @code{ata6289}, @code{attiny13}, @code{attiny13a}, @code{attiny2313}, @code{attiny2313a}, @code{attiny24}, @code{attiny24a}, @code{attiny25}, @code{attiny261}, @code{attiny261a}, @code{attiny4313}, @code{attiny43u}, @code{attiny44}, @code{attiny44a}, @code{attiny45}, @code{attiny461}, @code{attiny461a}, @code{attiny48}, @code{attiny84}, @code{attiny84a}, @code{attiny85}, @code{attiny861}, @code{attiny861a}, @code{attiny87}, @code{attiny88}.
 
 @item avr3
 ``Classic'' devices with 16@tie{}KiB up to 64@tie{}KiB of  program memory.
@@ -25,23 +25,23 @@
 
 @item avr31
 ``Classic'' devices with 128@tie{}KiB of program memory.
-@*@var{mcu}@tie{}= @code{atmega103}, @code{at43usb320}.
+@*@var{mcu}@tie{}= @code{at43usb320}, @code{atmega103}.
 
 @item avr35
 ``Classic'' devices with 16@tie{}KiB up to 64@tie{}KiB of program memory and with the @code{MOVW} instruction.
-@*@var{mcu}@tie{}= @code{at90usb82}, @code{at90usb162}, @code{atmega8u2}, @code{atmega16u2}, @code{atmega32u2}, @code{attiny167}.
+@*@var{mcu}@tie{}= @code{at90usb162}, @code{at90usb82}, @code{atmega16u2}, @code{atmega32u2}, @code{atmega8u2}, @code{attiny167}.
 
 @item avr4
 ``Enhanced'' devices with up to 8@tie{}KiB of program memory.
-@*@var{mcu}@tie{}= @code{atmega8}, @code{atmega48}, @code{atmega48a}, @code{atmega48p}, @code{atmega88}, @code{atmega88a}, @code{atmega88p}, @code{atmega88pa}, @code{atmega8515}, @code{atmega8535}, @code{atmega8hva}, @code{at90pwm1}, @code{at90pwm2}, @code{at90pwm2b}, @code{at90pwm3}, @code{at90pwm3b}, @code{at90pwm81}.
+@*@var{mcu}@tie{}= @code{at90pwm1}, @code{at90pwm2}, @code{at90pwm2b}, @code{at90pwm3}, @code{at90pwm3b}, @code{at90pwm81}, @code{atmega48}, @code{atmega48a}, @code{atmega48p}, @code{atmega8}, @code{atmega8515}, @code{atmega8535}, @code{atmega88}, @code{atmega88a}, @code{atmega88p}, @code{atmega88pa}, @code{atmega8hva}.
 
 @item avr5
 ``Enhanced'' devices with 16@tie{}KiB up to 64@tie{}KiB of program memory.
-@*@var{mcu}@tie{}= @code{atmega16}, @code{atmega16a}, @code{atmega161}, @code{atmega162}, @code{atmega163}, @code{atmega164a}, @code{atmega164p}, @code{atmega165}, @code{atmega165a}, @code{atmega165p}, @code{atmega168}, @code{atmega168a}, @code{atmega168p}, @code{atmega169}, @code{atmega169a}, @code{atmega169p}, @code{atmega169pa}, @code{atmega32}, @code{atmega323}, @code{atmega324a}, @code{atmega324p}, @code{atmega324pa}, @code{atmega325}, @code{atmega325a}, @code{atmega325p}, @code{atmega3250}, @code{atmega3250a}, @code{atmega3250p}, @code{atmega328}, @code{atmega328p}, @code{atmega329}, @code{atmega329a}, @code{atmega329p}, @code{atmega329pa}, @code{atmega3290}, @code{atmega3290a}, @code{atmega3290p}, @code{atmega406}, @code{atmega64}, @code{atmega640}, @code{atmega644}, @code{atmega644a}, @code{atmega644p}, @code{atmega644pa}, @code{atmega645}, @code{atmega645a}, @code{atmega645p}, @code{atmega6450}, @code{atmega6450a}, @code{atmega6450p}, @code{atmega649}, @code{atmega649a}, @code{atmega649p}, @code{atmega6490}, @code{atmega16hva}, @code{atmega16hva2}, @code{atmega16hvb}, @code{atmega32hvb}, @code{atmega64hve}, @code{at90can32}, @code{at90can64}, @code{at90pwm216}, @code{at90pwm316}, @code{atmega32c1}, @code{atmega64c1}, @code{atmega16m1}, @code{atmega32m1}, @code{atmega64m1}, @code{atmega16u4}, @code{atmega32u4}, @code{atmega32u6}, @code{at90scr100}, @code{at90usb646}, @code{at90usb647}, @code{at94k}, @code{m3000}.
+@*@var{mcu}@tie{}= @code{at90can32}, @code{at90can64}, @code{at90pwm216}, @code{at90pwm316}, @code{at90scr100}, @code{at90usb646}, @code{at90usb647}, @code{at94k}, @code{atmega16}, @code{atmega161}, @code{atmega162}, @code{atmega163}, @code{atmega164a}, @code{atmega164p}, @code{atmega165}, @code{atmega165a}, @code{atmega165p}, @code{atmega168}, @code{atmega168a}, @code{atmega168p}, @code{atmega169}, @code{atmega169a}, @code{atmega169p}, @code{atmega169pa}, @code{atmega16a}, @code{atmega16hva}, @code{atmega16hva2}, @code{atmega16hvb}, @code{atmega16m1}, @code{atmega16u4}, @code{atmega32}, @code{atmega323}, @code{atmega324a}, @code{atmega324p}, @code{atmega324pa}, @code{atmega325}, @code{atmega3250}, @code{atmega3250a}, @code{atmega3250p}, @code{atmega325a}, @code{atmega325p}, @code{atmega328}, @code{atmega328p}, @code{atmega329}, @code{atmega3290}, @code{atmega3290a}, @code{atmega3290p}, @code{atmega329a}, @code{atmega329p}, @code{atmega329pa}, @code{atmega32c1}, @code{atmega32hvb}, @code{atmega32m1}, @code{atmega32u4}, @code{atmega32u6}, @code{atmega406}, @code{atmega64}, @code{atmega640}, @code{atmega644}, @code{atmega644a}, @code{atmega644p}, @code{atmega644pa}, @code{atmega645}, @code{atmega6450}, @code{atmega6450a}, @code{atmega6450p}, @code{atmega645a}, @code{atmega645p}, @code{atmega649}, @code{atmega6490}, @code{atmega649a}, @code{atmega649p}, @code{atmega64c1}, @code{atmega64hve}, @code{atmega64m1}, @code{m3000}.
 
 @item avr51
 ``Enhanced'' devices with 128@tie{}KiB of program memory.
-@*@var{mcu}@tie{}= @code{atmega128}, @code{atmega1280}, @code{atmega1281}, @code{atmega1284p}, @code{atmega128rfa1}, @code{at90can128}, @code{at90usb1286}, @code{at90usb1287}.
+@*@var{mcu}@tie{}= @code{at90can128}, @code{at90usb1286}, @code{at90usb1287}, @code{atmega128}, @code{atmega1280}, @code{atmega1281}, @code{atmega1284p}, @code{atmega128rfa1}.
 
 @item avr6
 ``Enhanced'' devices with 3-byte PC, i.e.@: with more than 128@tie{}KiB of program memory.

Reply via email to