Make the Makefile more robust, readable and safe #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Makefile has been modified to make use of the features of Make
with the general objective of increasing robustness, readability
and safety of the code through a reduction in redundancy and an
increase in automatic work.
The dependencies have been grouped to express clearly that they can
be of one of 2 kinds: hardware-dependant assembly or higher-level
source. Thanks to this, the dependency tree that the Makefile defines
becomes clearer (main depends on source and source depends on asm).
The use of Pattern Rules (Static or not) and variables (Automatic
or not) make the code more readable and robuster by expressing
redundancy in a non-literal way.
Extending the tool to support a new hardware (i.e. adding to the
project a new
.S
file and some code in asm-opt) now only requires toadd the name of the extension in
${ASM}
and this will cascade downthe tree. This is more robust than the previous solution which required
multiple modifications. This new approach fixes a mistake on line 13
where the rule
asm-opt.o : aarch64-asm.h
was NOT defined whilebeing required from line 335 in
asm-opt.c
!all
andclean
are declared as phony variables to increase robustness.'-O2'
was removed from the call to the compiler as it is a compilerflag and we believe that it should be in
${CFLAGS}
.Thanks to the previous change, the
rm -f *.o
command in theclean
rule was made safer so it is now unable to delete
.o
files that itcouldn't have created.
A
${NAME}
variable is used to further reduce redundancy.