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/