Skip to content

Optimize and simplify Makefile for tools/#186

Merged
RetroAntho merged 1 commit intoalekmaul:developfrom
kobenairb:makefile_tools
Apr 9, 2023
Merged

Optimize and simplify Makefile for tools/#186
RetroAntho merged 1 commit intoalekmaul:developfrom
kobenairb:makefile_tools

Conversation

@kobenairb
Copy link
Copy Markdown
Contributor

Hi all,

Here a small update for the tools/Makefile to optimize it.

This optimized Makefile simplifies 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 SUBDIRS variable, which makes the Makefile more 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 cd commands 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 Makefile more concise and easier to read and maintain.

@RetroAntho
Copy link
Copy Markdown
Collaborator

really interesting update, it is good factorisation :) Thank you

@RetroAntho RetroAntho merged commit 52bd624 into alekmaul:develop Apr 9, 2023
@kobenairb kobenairb deleted the makefile_tools branch April 10, 2023 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants