The avr backend auto-generates parts of GCC's texi documentation,
namely the supported -mmcu= options, which are about 200.

To generate the texi a small C program is used to print the texi
to stdout, and that output is then compared against the already
existing doc/avr-mmci.texi

If the output is the same like in that file, nothing happens.

If the output differs from that file, the user (someone building the
avr compiler) is nagged to update the existing documentation so that
the documentation says in sync with the compiler.

The part of t-avr reads:

s-avr-mmcu-texi: gen-avr-mmcu-texi$(build_exeext)
        $(RUN_GEN) $< | sed -e 's:\r::g' > avr-mmcu.texi
        @if cmp -s $(srcdir)/doc/avr-mmcu.texi avr-mmcu.texi; then \
          $(STAMP) $@;          \
        else                    \
          echo >&2 ;             \
          echo "***" >&2 ;     \
          echo "*** Verify that you have permission to grant a" >&2 ;  \
          echo "*** GFDL license for all new text in" >&2 ;            \
echo "*** avr-mmcu.texi,then copy it to $(srcdir)/doc/avr-mmcu.texi" >&2 ; \
          echo "***" >&2 ;     \
          false;                \
        fi

The problem is comparing the new texi file avr-mmcu.texi against the
already existing $(srcdir)/doc/avr-mmcu.texi and factor out different
line endings that depend on the build system like LF vs. CRLF.

What is the best way to do such a comparison on text level without
getting a complaint if the original texi was built on linux and the
user builds the compiler under, say, windows?

How to cope with different line endings in that case?

The sed -e 's:\r::g' from above that tries to fix line endings has the problem that not all sed implementations are the same, i.e. some just do
sed -e 's:r::g' and remove all r's.

I searched some time how to accomplish this but did not find a neat solution.

Can tr from roff be used? Is it a valid prerequisite for GCC?
Or open a binary file to write the test instead of printf+stdout?
And just omit the sed and don't care at all?
Is there a valid compare tool that compares text modulo line-endings?
Setting an svn: property so that the texi is binary and not text?

Thanks

Johann

Reply via email to