Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading explanation on dependencies #4

Closed
AdrianWeaver opened this issue Jun 18, 2023 · 4 comments
Closed

Misleading explanation on dependencies #4

AdrianWeaver opened this issue Jun 18, 2023 · 4 comments

Comments

@AdrianWeaver
Copy link

In the README.md you wrote

A rule can have dependencies, some stuff to be fulfilled before execution, named pre-requisits.

Then adding :
A pre-requisit can be either a file or another rule. In the last case, the dependency rule is executed first. If the pre-requisit doesn't match neither a file or a target's name, the Makefile halts and prints an error.

That is actually misleading.
The purpose of a makefile is actually to make... well.... files.
So it does not really matter if the dependency is a file or a rule.
In case the dependency is a rule, the rule will be called.
In case the dependency is a file, the makefile will try to find a rule that makes this file. In case such rule does not exist, it will print an error.

@Nuno-Jesus
Copy link
Owner

I see your point, but It does matter if the name is a target or a file, since it will have different behaviors whenever the file is present or not, as you said.

@AdrianWeaver
Copy link
Author

True, however I still find the way you explain it is misleading.
You explain how it works for rules. You should also explain how it works for files instead of saying "if it doesnt match a file or a target's name.
Because it's either another rule (maybe to put in relation with .PHONY) or it's a file.

So saying doesn't match neither a file or a target's name does hide somehow the fact that make will consider anything as a file and try to find a rule for it.

The error printed being "I don't know the rule to make this file I don't know about"

@Nuno-Jesus
Copy link
Owner

Nuno-Jesus commented Jun 18, 2023

So I am missing the point where I state "Makefiles consider pre-requisits as files." Possible cases:

  • The file exists -> if the file hadn't any recent modification since the last build, the pre-requisit is fulfilled and the Makefile goes on to the next pre-requisit (if any)
  • The file exists but changed since the last build -> look for a target that matches the file's name to re-build
  • The file doesn't exist -> same as before
  • The files doesn't exist and there is no target with a matching name -> halt

Is that it?

@AdrianWeaver
Copy link
Author

That's it though some conditions there could be packed together

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

No branches or pull requests

2 participants