Optimize and simplify Makefile for tools/#186
Merged
RetroAntho merged 1 commit intoalekmaul:developfrom Apr 9, 2023
Merged
Conversation
Collaborator
|
really interesting update, it is good factorisation :) Thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hi all,
Here a small update for the
tools/Makefileto optimize it.This optimized
Makefilesimplifies the code and reduces duplication by using the automatic variable$(MAKECMDGOALS)to pass the command goal (all, clean, or install) to the sub-Make processes. Here's a breakdown of the changes:The phony targets are listed together with the
SUBDIRSvariable, which makes theMakefilemore readable and easier to maintain.The all, clean, and install targets all depend on the subdirectories, so they can be listed together with the PHONY target, and then listed as prerequisites for each of the targets.
The rule to build each subdirectory is simplified using the$(MAKE) command and the automatic variable $ @, which represents the current subdirectory. The
$(MAKECMDGOALS)variable is used to pass the command goal to the sub-Make process, which avoids the need to duplicate the rules for each target.The
cdcommands in the clean and install targets are unnecessary because$(MAKE)changes the directory to the subdirectory automatically. Instead, we use the$@variable to pass the subdirectory name to the$(MAKE)command.By using these optimizations, we can make the
Makefilemore concise and easier to read and maintain.