bug-make
[Top][All Lists]
Advanced

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

[bug #59243] Overcomplicated example of automatic dependency configurati


From: anonymous
Subject: [bug #59243] Overcomplicated example of automatic dependency configuration
Date: Fri, 9 Oct 2020 11:49:51 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?59243>

                 Summary: Overcomplicated example of automatic dependency
configuration
                 Project: make
            Submitted by: None
            Submitted on: Fri 09 Oct 2020 03:49:50 PM UTC
                Severity: 3 - Normal
              Item Group: Documentation
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: None
        Operating System: None
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

In section 4.14, the example of the pattern rule is unnecessarily
complicated:

%.d: %.c
        @set -e; rm -f $@; \
         $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
         sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
         rm -f $@.$$$$

The first rm command is redundant as redirecting the output of the sed command
with ">" will replace it anyway. Instead of creating another temporary file
with "$@.$$$$", one can simply pipe the preprocessor output to sed input,
making the second rm unnecessary as well. If a file must be created for some
reason, why confuse beginners with "$@.$$$$" instead of just "$@.temp". The
sed is also overengineered as is.

This example provides the same functionality:

%.d: %.c
    @printf "$@ " > $@
    @$(CC) $(CPPFLAGS) -MM $< >> $@

However, instead of spending 30 minutes to understand it, the developer only
needs 5, as this example would be much clearer.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59243>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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