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

Prefer more specific rules over more general ones #51

Open
sjackman opened this issue Jan 16, 2018 · 0 comments
Open

Prefer more specific rules over more general ones #51

sjackman opened this issue Jan 16, 2018 · 0 comments

Comments

@sjackman
Copy link
Contributor

sjackman commented Jan 16, 2018

When multiple pattern rules exist, GNU Make prefers the more specific rule over more general ones, that is to say, the pattern rule with the shortest stem (the shortest string matched by %). See the last few sentences of https://www.gnu.org/software/make/manual/html_node/Pattern-Match.html

In the following example, GNU make uses the combined sort | gzip rule, whereas biomake uses the separate sort and gzip rules.

all: words.sort.txt.gz

.SECONDARY:

words.txt: /usr/share/dict/words
	cp $< $@

%.sort.txt: %.txt
	sort -o $@ $<

%.txt.gz: %.txt
	gzip -c $< >$@

%.sort.txt.gz: %.txt
	sort $< | gzip >$@
❯❯❯ make -n
cp /usr/share/dict/words words.txt
sort words.txt | gzip >words.sort.txt.gz
❯❯❯ biomake -n
   cp /usr/share/dict/words words.txt
  sort -o words.sort.txt words.txt
 gzip -c words.sort.txt >words.sort.txt.gz
Target all not materialized - build required

The workaround in this case is to put the %.sort.txt.gz: %.txt rule above the other two rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants