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

convert multi-output recipes to pattern rules to avoid repetition #25

Merged
merged 1 commit into from
Dec 18, 2019

Conversation

bertsky
Copy link
Collaborator

@bertsky bertsky commented Dec 14, 2019

This converts rules that specify multiple targets with a recipe that builds them all at once – as most multi-executable modules have – into pattern rules, so make "knows" that all the targets are built together. Thus, the rule only fires once per module (instead of once per executable), and parallel building (make -j) becomes possible again.

We could have waited for GNU make 4.2 for this, which finally added new syntax to support such rule semantics (via :& instead of :). But pattern rules can do this, too. They are just more difficult to read and write.

(I encapsulated this in a parameterized function multirule which takes the original list of executables and replaces the $(BIN)/ part – which is assumed to always be present – with %, so the rule becomes a pattern rule, but no other target is likely to match it. This is only necessary for the actual recipe, the dependencies still must be specified normally.)

Copy link
Member

@kba kba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elegant, less readable than :& but more portable and short. LGTM

@stweil stweil merged commit f8af582 into OCR-D:master Dec 18, 2019
@stweil
Copy link
Collaborator

stweil commented Dec 18, 2019

Thank you.

@bertsky bertsky deleted the multi-output-rules branch August 21, 2020 10:55
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.

None yet

3 participants